Python Basics – Functions, Conditionals
This flashcard set covers foundational Python programming concepts including functions, parameters, conditional statements (if, else, comparisons), Boolean logic (and, or, not), and syntax correction. Ideal for beginners, it helps reinforce the logic and structure needed to write and debug simple Python programs.
3.1 Lesson Practice
A ____________ is a set of commands which can be run by calling it by name.
function
Rate to track your progress ✦
Key Terms
3.1 Lesson Practice
A ____________ is a set of commands which can be run by calling it by name.
function
3.1 Lesson Practice
A _____________ is a piece of information sent to a function.
parameter
3.1 Lesson Practice
Consider the following code:
x = random.randint (1, 100)
The randint is a ____________.
function
3.1 Lesson Practice
Which of the following is NOT a function?
math
3.2 Lesson Practice
For questions 1-3, consider the following code:
What is output if the user types in 9? Click all that apply.
C
D
A
3.2 Lesson Practice
What is output if the user types in 8? Click all that apply
C
3.2 Lesson Practice
What is output if the user types in 13? Click all that apply.
A
D
B
3.2 Code Practice: Question 3
password = input("Enter the password:")
if(password=="Ada Lovelace"):
print("Correct!")
if(password!="Ada Lovelace"):
print("Not Correc...
3.2 Code Practice: Question 1
n = float(input("Enter a number: "))
if (n>45.6):
print("Greater than 45.6")
if(n<45.6):
print("Less than 45.6")
3.2 Code Practice: Question 2
a = float(input('Enter a number: ')) i
f(a >= 90):
print('Great!')
3.2 Code Practice: Question 3
password = input("Enter the password:")
if(password=="Ada Lovelace"):
print("Correct!")
if(password!="Ada Lovelace"):
print("Not Correc...
3.3 Lesson Practice
Consider the following code:
if (x > 5 AND x <= 10): print(OK)
Click all the mistakes that apply:
The print (OK) should be print ("OK")
AND should be and
3.3 Lesson Practice
The blue section of the following Venn diagram could represent which of the following Boolean statements?
not
3.3 Lesson Practice
The following code will not compile. Which of the options below would allow the code to compile and run as intended?
if (x >= -10 and <= 10): print("In range")
if (x >= -10 and x <= 10):
3.3 Code Practice: Question 1
day = int(input("Enter today's day numerically: "))
if(day 15 or day 30):
3.3 Code Practice: Question 2
r = int(input("Enter the red: "))
g = int(input("Enter the green: "))
b = int(input("Enter the blue: "))
if(r <= 0 or r >= 255):
...
3.4 Lesson Practice
What is the output?
x = 9 % 2
if (x == 1):
print ("ONE")
else:
print ("TWO")
ONE
3.4 Lesson Practice
For questions 2-4, consider the following code:
What is the output if month = 9 and day = 14?
First half of the month
3.4 Lesson Practice
What is output if month = 11 and day = 14?
Not in September
3.4 Lesson Practice
What is output if month = 9 and day = 21?
Second half of the month
3.4 Code Practice: Question 1
color = input("What color? ")
if (color == "yellow"):
print("Correct!")
else:
print("Nope")
3.4 Code Practice: Question 2
num = int(input("Numerator: "))
den = int(input("Denominator: "))
if(den == 0):
print("Error - cannot divide by zero.")
else:
print(...
3.5 Lesson Practice
If the user enters 5 what is output? _____________
A
3.5 Lesson Practice
If the user enters 26 what is output? _____________
B
3.5 Lesson Practice
If the user enters 3 what is output? _____________
C
3.5 Lesson Practice
If the user enters 48 what is output? _____________
E
3.5 Lesson Practice
Consider the following code:
color = input("What color? ")
if (color "green"):
print ("Correct")
else: print ("Nope")
elif (color "red"):
print ("Correct")
What happens when it is run?
There is an error, the else should be after the elif
3.5 Lesson Practice
What is output?
x = 21
if (x > 21):
print (1)
elif (x < 21):
print (2)
else:
print (3)
3
3.5 Code Practice
grade = int(input("What grade are you in? "))
if (grade 9):
3.5 Lesson Practice
Consider the following code:
color = input("What color? ")
if (color "green"):
print ("Correct")
else: print ("Nope")
elif (color "red"):
print ("Correct")
What happens when it is run?
There is an error, the else should be after the elif
3.5 Lesson Practice
What is output?
x = 21
if (x > 21):
print (1)
elif (x < 21):
print (2)
else:
print (3)
3
3.5 Code Practice
grade = int(input("What grade are you in? "))
if (grade 9):
Related Flashcard Decks
| Term | Definition |
|---|---|
3.1 Lesson Practice | function |
3.1 Lesson Practice | parameter |
3.1 Lesson Practice | function |
3.1 Lesson Practice | math |
3.2 Lesson Practice | C |
3.2 Lesson Practice | C |
3.2 Lesson Practice | A |
3.2 Code Practice: Question 3 | password = input("Enter the password:") |
3.2 Code Practice: Question 1 | n = float(input("Enter a number: ")) |
3.2 Code Practice: Question 2 | a = float(input('Enter a number: ')) i |
3.2 Code Practice: Question 3 | password = input("Enter the password:") |
3.3 Lesson Practice | The print (OK) should be print ("OK") |
3.3 Lesson Practice | not |
3.3 Lesson Practice | if (x >= -10 and x <= 10): |
3.3 Code Practice: Question 1 | day = int(input("Enter today's day numerically: ")) if(day 15 or day 30): print("It's payday!") if(day != 15 and day != 30): print("Sorry, not a payday.") |
3.3 Code Practice: Question 2 | r = int(input("Enter the red: ")) |
3.4 Lesson Practice | ONE |
3.4 Lesson Practice | First half of the month |
3.4 Lesson Practice | Not in September |
3.4 Lesson Practice | Second half of the month |
3.4 Code Practice: Question 1 | color = input("What color? ") |
3.4 Code Practice: Question 2 | num = int(input("Numerator: ")) |
3.5 Lesson Practice | A |
3.5 Lesson Practice | B |
3.5 Lesson Practice | C |
3.5 Lesson Practice | E |
3.5 Lesson Practice Consider the following code: color = input("What color? ") if (color "green"): print ("Correct") else: print ("Nope") elif (color "red"): print ("Correct") What happens when it is run? | There is an error, the else should be after the elif |
3.5 Lesson Practice | 3 |
3.5 Code Practice | grade = int(input("What grade are you in? ")) if (grade 9): print("Freshman") elif( grade 10): print("Sophomore") elif( grade 11): print("Junior") elif( grade 12): print("Senior") else: print("Not in High School") |
3.5 Lesson Practice Consider the following code: color = input("What color? ") if (color "green"): print ("Correct") else: print ("Nope") elif (color "red"): print ("Correct") What happens when it is run? | There is an error, the else should be after the elif |
3.5 Lesson Practice | 3 |
3.5 Code Practice | grade = int(input("What grade are you in? ")) if (grade 9): print("Freshman") elif( grade 10): print("Sophomore") elif( grade 11): print("Junior") elif( grade 12): print("Senior") else: print("Not in High School") |