print(“Hello”)
It writes out hello
Print means to write and show it and “hello” is what is being shown
What is the code for a loop?
For i in range():
For is the for loop and range is the amount of time you want to loop
What does if else statement do?
The code helps the computer make a decision
If something happens then do this. This basically gives the computer a choice to make when something happens
Print(hello)
There isn’t “”
When printing something you need a parenthesis and quotation marks
What is a variable
A variable is used to store information
We use a variable to = to something to store information so code is more efficient
What does” number = input(“choose a number”)” do?
it would let you put a input
Input means to allow the user to put a input
What does the third number in for i in range(): mean?
It skip counts by that number
When printing numbers in a loop the first number is the starting number and the second number is the ending number. It normally counts by 1 but the third number is what determines the number it skip counts by
What is elif?
Elif is the secondary option if the if is false
If something is false then you read the next line of code which has elif which if “if” is wrong then try this
Num=input(“enter a number”)
If Num=<5:
Print(“small”)
Else:
Print(“big”)
You didn’t convert the num into an integer
In python the default is a string which is why we put quotation marks. But in this case there is numbers so it have to be an integer.
What is a float?
Decimal
There is integer for number string for works and float to represent fraction or decimal
What does this code do?
Num=input(“choose a number between 1-10”)
Num=int(num)
If num =<5:
Print(“small”)
Else:
Print(“big”)
It would let you choose a number between 1-10 and the code determines if it’s small or big
The code allows you to give the computer a input and the code changed to a integer and the if statement reads the number u inputted and would see if its big or small
How do you write a code that prints “blue” 5 times
For i in range(5):
print(“blue”)
For i in range(5): repeats 5 times Print blue would repeatedly print blue 5 times
What happens if the if statement is false and the elif statements are also false?
The computer would use else
When all the if and elif statements are false then it would use else as a backup option.
Food=input(“what is your favorite food?”)
If food == “pizza” or “fries”:
Print(“me too”)
Else:
Print(“cool”)
There needs to be food == “fries” also
You need to include that the variable is equal to something in order for the code to work
What is a comparison operator
Anything used to compare things like =, ==, =< and etc
If we want something to be the same as another thing or more than something and less than something we use things like = to compare