Question: Question 1 1 pts def check _ negative ( num ) : if num < 0 : # Line 1 return the number is negative

Question 11 pts
def check_negative(num):
if num <0: # Line 1
return "the number is negative" # Line 2
return "the number is positive" # Line 3
print("thank you") # Line 4
print("all done") # Line 5
check_negative(220)
When the function check_negative is called, how many lines of the function body are executed? (NOTE: do not count the function call and the function header)
Group of answer choices
5
1
3
2
4
Flag question: Question 2
Question 22 pts
Select all the correct options for determining if integer x is an even number.
Group of answer choices
if x %2!=1:
print("Even")
if x %2!=0:
print("Even")
if x %2==1:
print("Even")
if x %2==0:
print("Even")
Flag question: Question 3
Question 32 pts
Which of the following code snippets will cause an error? Select all that apply.
subject ="CS 220"
## Option 1
if subject =="CS 220":
print('Welcome!')
print('Awesome!')
## Option 2
if subject =="CS 220":
print('Welcome!')
print('Awesome')
## Option 3
if subject =="CS 220":
print('Welcome!')
print('Awesome')
## Option 4
print('Welcome!')
if subject =="CS 220":
print('Awesome')
Group of answer choices
Option 4
Option 1
Option 2
Option 3
Flag question: Question 4
Question 42 pts
Which of the following Python code snippets correctly categorizes a number based on the conditions below?
If the number is less than 10, it prints "Low".
If the number is between 10 and 20(inclusive), it prints "Medium".
If the number is greater than 20, it prints "High".
Select all correct answers:
Group of answer choices
if number <=10:
print("Low")
elif number >10 and number <=20:
print("Medium")
else:
print("High")
if number <10:
print("Low")
elif number >=10 and number <=20:
print("Medium")
else:
print("High")
if number >10:
print("Low")
elif number >=10 and number <=20:
print("Medium")
elif number >20:
print("High")
if number <10:
print("Low")
elif number >=10 and number <=20:
print("Medium")
elif number >20:
print("High")
Flag question: Question 5
Question 52 pts
Given the code below, what describes the values of the number x that will cause the code to print condition true? Select all correct answers
if x >=10 or x <=20:
print("condition true")
print("all done")
Group of answer choices
All values of x
10 to 20(both inclusive)
None of the others
Any value of x less than 10
Flag question: Question 6
Question 62 pts
Which of the following will give the same result as G(x,y) in all cases?
def G(x, y):
if x:
return False
else:
if y:
return False
else:
return True
Group of answer choices
not x and not y
x or y
x != y
x and y
Flag question: Question 7
Question 71 pts
Which of the following condition correctly refactors the code block below?
def unfactored(x,y,z):
if x ==2:
if y <1:
if z >=3:
return True
Group of answer choices
x ==2 or y <1 and z >=3
x ==2 and y <1 and z >=3
x ==2 and y <1 or z >=3
x ==2 or y <1 or z >=3
Flag question: Question 8
Question 81 pts
When given the same input, do the following functions always produce the same output?
Option 1:
def check_function(x, y, z):
return x ==2 or y ==1 or z ==0
Option 2:
def check_again(x, y, z):
if x ==2:
if y ==1:
return True
else:
return False
else:
return False
Group of answer choices
The functions above will produce different outputs for some arguments.
The functions above will not run due to a syntax error.
The functions above will produce the same output for all arguments.
The functions above will not run if z=0 due to a runtime error.
Flag question: Question 9
Question 91 pts
Consider the following code:
x =1
total =0
while x <10:
total += x
x +=2
What will be the value of total after the loop finishes?
Group of answer choices
30
25
15
20
Flag question: Question 10
Question 102 pts
What can replace the ??? so that we get the desired output for this code? Select all correct options.
Code:
number =20
while ??? :
print(number)
number -=3
Output:
20
17
14
11
8
Group of answer choices
number >=8
number >=7
number >7
number >8
Flag question: Question 11
Question 112 pts
Given the following code:
y = int(input("enter a number: "))
while y !=0:
y = y -3
print(y)
Which of the following inputs will result in an infinite loop?
Select all that apply.
Group of ans

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!