Asked by john
What is the output of this program?
Assume the user enters “kipp52”, then “baseball45”.
# Checks if the user entered the correct username
def validate_user(username):
if username != "coder43" and username != "goodHacker90" and username != "baseball45":
return False
else:
return True
# Gets the user's username
def get_username():
while True:
username = input("Enter your username: ")
if validate_user(username):
print("Welcome!")
return username
else:
print("That's not a valid username. Try again")
print("Welcome to CodeHS!")
get_username()
Welcome to CodeHS!
Enter your username: kipp52
That's not a valid username. Try again
Enter your username: baseball45
Welcome!
Welcome to CodeHS!
Enter your username: kipp52
Enter your username: baseball45
Welcome!
Welcome to CodeHS!
Enter your username: kipp52
That's not a valid username. Try again
Enter your username: baseball45
Welcome to CodeHS!
Enter your username: kipp52
That's not a valid username. Try again
Enter your username: baseball45
That's not a valid username. Try again
Welcome!
Question: 6
Which of the following options is NOT a valid Python function definition?
# computes the surface area of a cube of side length 10
#
def surface_area():
return 2*(100 + 100 + 100)
# computes the surface area of a rectangular prism
def surface_area(length, width=10, height):
return 2*(length * width + width * height + height * length)
# computes the surface area of a rectangular prism
def surface_area(length, width, height):
return 2*(length * width + width * height + height * length)
# computes the surface area of a rectangular prism
def surface_area(length, width, height=10):
return 2*(length * width + width * height + height * length)
Question: 7
Consider the following functions.
def fn_a(num):
if num > 3:
print("Fizz")
def fn_b(num):
if num > 2 and num < 4:
print("Fizz")
Which for loop would print
Fizz
Fizz
for i in range(6):
fn_b(i+1)
for i in range(6):
fn_a(i)
fn_b(i)
for i in range(6):
fn_a(i)
for i in range(6):
fn_b(i)
Question: 8
Which of the programs below will print the following output?
I would like a green balloon.
def balloon_choice(color):
print("I would like a " + color + " balloon.")
balloon_choice("green")
def balloon_choice(color):
print("I would like a " + color + " balloon.")
def balloon_choice():
print("I would like a " + color + " balloon.")
balloon_choice("green")
def balloon_choice():
print("I would like a green balloon.")
balloon_choice("green")
Question: 9
What will be the output of the following program?
a = 4
def print_something():
a = "code"
print(a * 3)
print_something()
12
code
4
codecodecode
All Answers 1
Answered by
GPT-5 mini
AI
1) Program output when the user types "kipp52" then "baseball45":
Welcome to CodeHS!
Enter your username: kipp52
That's not a valid username. Try again
Enter your username: baseball45
Welcome!
6) NOT a valid function definition:
def surface_area(length, width=10, height):
...
(You cannot have a default parameter before a non-default parameter.)
7) The for loop that prints
Fizz
Fizz
is:
for i in range(6):
fn_a(i)
8) The program that prints "I would like a green balloon." is:
def balloon_choice(color):
print("I would like a " + color + " balloon.")
balloon_choice("green")
9) Output of the last program:
codecodecode
Welcome to CodeHS!
Enter your username: kipp52
That's not a valid username. Try again
Enter your username: baseball45
Welcome!
6) NOT a valid function definition:
def surface_area(length, width=10, height):
...
(You cannot have a default parameter before a non-default parameter.)
7) The for loop that prints
Fizz
Fizz
is:
for i in range(6):
fn_a(i)
8) The program that prints "I would like a green balloon." is:
def balloon_choice(color):
print("I would like a " + color + " balloon.")
balloon_choice("green")
9) Output of the last program:
codecodecode
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.