Advertisement
cfabio

Python Syntax

Dec 16th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. name = "fabio"
  2. if name == "fabio":
  3.     print("yes")
  4. else:
  5.     print("no")
  6.  
  7. inputVar = input()
  8. #empty string is evaluated as false
  9. if not inputVar:
  10.     print('empty string')
  11.  
  12. if bool(inputVar) == False:
  13.     print('empty string')
  14.    
  15. spam = 0
  16. while spam < 5:
  17.     print('Hello world')
  18.     spam += 1
  19.  
  20.  
  21. #conversion function
  22. myNum = int(input())
  23. print('number in input was: ' + str(myNum))
  24.  
  25. #goes till 4
  26. for i in range(5):
  27.     print('hello' + str(i))
  28.    
  29. for i in range(1, 5):
  30.     print('hello' + str(i))
  31.  
  32. #step of 2
  33. for i in range(1, 5, 2):
  34.     print('hello' + str(i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement