Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Variables:
- examplevar = "string"
- examplevar = 25 #integer
- examplevar = 2.5 #float
- examplevar = True #boolean
- #Strings:
- vari = "Hello " + "there" #concatenated
- vari = f"{25} tomatoes" #formatted
- #Input & Output:
- name = input("Enter your name:") #input
- print(name) #output
- #Type Conversion:
- str()
- int()
- float()
- num = 20/5 #dividing an int always results in a float (implicit conversion)
- num = 20+2.5 #operations between an int and a float always result in a float
- bool()
- #Comparison:
- > #greater
- <= #less or equal
- == #equal
- != #inequal
- #Logical operations:
- op = True or False #=True
- op = True and False #=False
- #Loops:
- for num in range(10): #for loop
- print(num)
- while num < 5: #while loop
- num = num+1
- #Conditional statements:
- if num >= 5
- print("one")
- elif num >=3:
- print("two")
- else:
- print("three")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement