1/16
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
what is an algorithm?
a precise, step-by-step
solution to a problem
what is a Counting type (int)?
0-9, can be positive or negative, is discrete (meaning no decimals)
How do you declare an int?
Examples:
age = 18
bank balance = 0
Net worth = -7
What is a Floating-point arithmetic type (a float)?
similar to a decimal number in math (3.4, 4.33, -1.22)
What function gives the absolute value, and how do you use it?
abs()
Example: abs(-3.2) (you’d get 3.2)
what function gives you the minimum from a list of numbers?
min()
Example: min(2,3,6,2,1) (you’d get 1)
what function gives you the maximum from a list of numbers?
max()
Example: max(2,3,6,2,1) (you’d get 6)
What characters can a variable contain?
lowercase, uppercase, underscore, digits 0-9
How do you use the print statement for strings?
print(‘hola’)
print(“hola”)
How do you use the print statement for int/float?
print(0)
print(2.3)
how to concatenate strings and variables in a print statement
(how to have both a string and a variable in the same line, for example “Anna is 24 years old”)
age = 25
print("Anna is", age, "years old.")
OR
print("I am " + str(age) + " years old.")
do NOT do:
print("Anna is " + 25 + “years old”) (25 gotta be in a variable first)
How to keep output on the same line
end= ‘ ‘
example:
print(‘hello there.’ , end= ‘ ‘)
print(‘my name is….’ , end= ‘ ‘)
print(‘Santos’)
would print, (Hello there. my name is… Santos)
How to get user input in python:
use the input() function
Example:
name = input(‘What is your name?: ‘)
(then the user inputs and their name is stored in the variable)
The three type conversion functions: (changing from int to float to string)
int()
float()
str()
if u got time try to:
Requests the user’s name
2. Requests the user’s age
3. Computes the user’s age one year from
now and prints the message shown
if u dont got time mark this as correct (in the settings of the flashcards you can turn on manual override it might restart u tho mb)
name = input('Enter your name: ')
age = int(input('Enter your age: '))
line = name + ', you will be ' + str(age+1) + ' next year!'
print(line)
How to manipulate floating point output (digits)
f’{variable.digitsuneed & f}’
example
pi = 3.18273737373
print(pi reduced to 3 digits: “ , f’{pi.3f}’)
What is an f string?
fastest way to keep variables inside strings
example:
tempereture = 3
print(f“its like {temperture} degrees outside rn”)