Free FOUNDATIONS-OF-PROGRAMMING-PYTHON Practice Test Questions and Answers (2026)

View Mode
Q: 1
What determines which lines of code are executed when the condition is true in a Python if statement?
Options
Q: 2
Which type of loop repeatedly checks a condition to determine whether to continue?
Options
Q: 3
Which components are required in every Python while loop?
Options
Q: 4
What happens when theRunbutton is clicked in a Python development environment?
Options
Q: 5
Which keyword is used to exit a loop prematurely in Python?
Options
Q: 6

SIMULATION Fix the indexing error in this function that should return the last character of a string. def get_last_character(text): return text[len(text)]

Your Answer
Q: 7

SIMULATION Write a complete function password_strength(password) that returns "Strong" if the password is at least 8 characters long and contains both letters and numbers, "Weak" otherwise. For example, password_strength("abc123def") should return "Strong". def password_strength(password): # TODO: Return "Strong" or "Weak" based on password criteria if len(password) < 8: return "Weak" has_letter = False has_number = False for char in password: if char.isalpha(): has_letter = True elif char.isdigit(): has_number = True # TODO: Add your return logic here based on has_letter and has_number pass

Your Answer
Q: 8

SIMULATION Fix the indentation error in this function that should return a greeting message. def greet(name): return "Hello " + name

Your Answer
Q: 9

SIMULATION Complete the function calculate_tip(bill, tip_percent) that calculates and returns the tip amount based on the bill and tip percentage. For example, calculate_tip(50, 20) should return 10.0. def calculate_tip(bill, tip_percent): # TODO: Calculate and return the tip amount pass

Your Answer
Q: 10

SIMULATION Complete the function is_positive(number) that returns True if the number is greater than 0, and False otherwise. def is_positive(number): # TODO: Return True if number > 0, False otherwise pass

Your Answer
Question 1 of 20

Premium Access Includes

  • Quiz Simulator
  • Exam Mode
  • Progress Tracking
  • Question Saving
  • Flash Cards
  • Drag & Drops
  • 3 Months Access
  • PDF Downloads
Get Premium Access
Scroll to Top

FLASH OFFER

Days
Hours
Minutes
Seconds

avail 10% DISCOUNT on YOUR PURCHASE