The exact spelling, symbols and order of the code
Syntax
5+2
Integer
name = "Harry"
print(name)
Harry
Daily Double
number = 6
if number >= 6:
print("6 it is!")
else:
print("Cool!")
A note that the computer ignores
Comment
6.2+1.1
Float
age = 12
print(10)
10
grade = 77
if grade >=90:
print("A")
elif grade >77:
print("B")
else:
print("D")
D
A storage container for information
Variable
"Hello World" + " !"
String
age = 6
new_age = age + 2
print(age)
6
if choice == "A":
story += "The pig went outside"
print(story)
else:
story += "The pig went to sleep"
print(story)
There was a pig. The pig went outside
When the computer encounters something unexpected
Error
Daily Double!
name = input("name: ")
age = int(input("age: ")) #Enters 20
name = age
print(name)
greeting = "Hello there"
name = input("What is your name? ") #Enter Harry
print(greeting + " " + name + " " + "How are you?")
Hello there Harry How are you?
number = 14
if number == 14:
number -=10
if number > 5:
number += 5
print(number)
4
Information that a function needs to know in order to run
Argument
int(str(int("8")))+float("6.2")
Float
print("Hi")
age = int(input("age: ")) #Enters 10
if age > 10:
print("Hi there")
else:
print("Hello there")
Hi
Hello there
food = input("Name: ") #enter cheese
if food == "Cheese":
print("I see")
else:
print("Cheese is good!)
Cheese is good!