1/33
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
#function
Creates a note that doesn't show in the code when it is run
Example #this is an example of what a hash does
Int - Converts a variable into a WHOLE number
*NOTE: Integers will always round down
variable1 = int(input("What is your age: "))
variable2 = int(2.5)
*NOTE: Integers will always round down
print("Hello \nWorld")
Output Hello World
print("Hello \tWorld")
Output Hello World
name = "Olivia"
age = 16
print(f"My name is {name} and I am {age}.")
Output
My name is Olivia and I am 16.
Allows the user to input data into the coding
*NOTE: Inputs will always be a string at first unless otherwise stated by the code
name = input("Enter your name: ")
print(name)
Output
(whatever the person put in)
age = 15
print(age)
Output
15
height = float(input("Enter your height (m): "))
print(f"{height:.2f}")
*NOTE: The {height:.2f} means that the float that was input is rounded to two decimal places (always rounded DOWN)
a = 1
b = 2
a, b = b, a
print(a)
print(b)d = True
print(d)
f = False
print(f)
Output
True
False
==
sees if the condition is met (is it true)
!=
sees if the condition is not met (it is false)
sequence, selection, iteration
Selection Example
If it is raining, then stay inside, else put on a hat
looping/repetition
While... Do... Repeat... Until... For 1 to ... do....
Brushing Hair (until tangle free)
while answer == "yes":
..........
else: print("We don't accept that at the moment and you will not be getting your food/drink.")
Range in for loop
()
Sequence of Numbers brackets in for loop
[]
*NOTE: range [1, 10] will only print numbers 1 to 9
Dictionary brackets in for loop
{}
To the power of
**
divide and round down (as an int)
//
remainder amount
%
division (auto converts to float)
/