Instrukcja wejścia
a=int(input(“Podaj a=”)) - dla liczb całkowitych
a=float(input(“Podaj a=”)) - dla liczb rzeczywistych
a=input(“Podaj a=”) - dla danych tekstowych
Instrukcja wyjścia
print(a) - wyświetla wartość zmiennej a
print(“a”) - wyświetla tekst, czyli literę a
print(“a=”,a) - wyświetla tekst i wartość zmiennej a
print("%d+%d=%d" %(a,b,a+b)) #napis formatowany(%-formattting)
print("{:4d}|%{ }" .format(n,i)) #napis formatowany(str.format))
a=2
print(f'a={a}') #napis formatowany(f-string)
Instrukcja warunkowa
if warunek:
instrukcje
elif:
instrukcje
else:
instrukcje
Pętla for
for zmienna in zakres:
instrukcje
Pętla while
while warunek:
instrukcje
Funkcje
def nazwa(parametry):
instrukcje
return wartość