fork download
  1. #zmienne
  2. zmienna = 6
  3.  
  4. print("dzisiaj jest czwartek")
  5.  
  6. print("6 + 8 = ", end='')
  7. print(6 + 8)
  8. print(zmienna)
  9.  
  10. #funkcje
  11. def pole_prostokata(bok1, bok2):
  12. return bok1 * bok2
  13.  
  14. print(pole_prostokata(10, 4))
  15.  
  16. #instrukcja warunkowa
  17. #prosta
  18. x = 6
  19. if x % 3 == 0:
  20. print("liczba jest podzielna przez 3")
  21.  
  22. #złożona
  23. if x > 0:
  24. print("liczba jest dodatnia")
  25. elif x == 0:
  26. print("liczba jest równa zero")
  27. else:
  28. print("liczba jest ujemna")
  29.  
  30. #pobieranie od użytkownika danych
  31. x = int(input("podaj pierwszą liczbę: "))
  32. y = int(input("podaj drugą liczbę: "))
  33.  
  34. print(x + y)
  35.  
  36. #pętla for
  37. for i in range(1, 7, 2):
  38. print(i, end=' ')
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
Success #stdin #stdout 0.1s 14088KB
stdin
2
3
stdout
dzisiaj jest czwartek
6 + 8 = 14
6
40
liczba jest podzielna przez 3
liczba jest dodatnia
podaj pierwszą liczbę: podaj drugą liczbę: 5
1 3 5