CNIT 155 Exam 1 Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is the output of the following code? n = 20 while (n <= 25): print(n, "\n") n = n+1

20, 21, 22, 23, 24, 25

The expression 3**3 - (6-2)/2 has the value____. is it an integer value or float value?____

25, float

Whats the output? count = 0 for n in range(6): if n%2 != 0: count = count + 2 print(count)

6

Whats the output? count = 0 loop = 0 while count < 4: loop = loop + 1 countt = count + 2 count = count + loop print(count)

6

What is max(3,5,1,7,4)?

7

Which of he following have the highest precedence?

Arithmetic operators

Computers can create true random numbers (T/F)

False

if is a legal Python identifier (T/F)

False

What does the following code fragment output? x = 14 if x >=21 elif x>= 21: print("Hello") elif x > 14: print("HI. How are you?") else: print("Well met")

Hi, how are you?

Which of the following is an example of De Morgan's Law?

Not (not A or not B) = A and B

What is printed when the following code is executed? for university in ('PU', 'IU', 'Butler') print(university, "is a university")

PU is a university IU is a university Butler is a university

If you enter a bunch of letters in response to the input the function, the input function returns a string (T/F)

True

In python, the division operator (/) gives a float result, even if both of the numbers are integers (T/F)

True

String can be used as a sequence in a for loop (T/F)

True

The input function returns a Boolean if the user types in True (T/F)

True

The int function can be used to convert a string of digits into an integer (T/F)

True

While loops are pretest loops (T/F)

True

in is a reserved word in Python (T/F)

True

sum_total is a legal python identifier (T/F)

True

Which of the following is a correct syntax for a while loop?

While (condition): Block of statements

Which of the following statements about a programs main function is not true?

by convention it is the first function to be called

Analyze the following code: count = 0 while count < 100: #Point A print("Welcome to Python!") count += 1 #Point B #Point C

count < 100 is always True at Point B

How many times will the following code print "Welcome to Python? count = 0 while count < 10 print("Welcome to Python")

infinite number of times

What is printed by the last line of the following code: x = 10 y = input("enter a letter:") print(y) Assume the user enters the letter z in response to the prompt.

nothing, an error occurs

The input function is used to ___ and returns a __

prompt for text input from user, string

Which of the following range function syntax is incorrect?

range(1,2.5,4.5)

Which of the following range function will result in a for loop counting backwards?

range(3, 0, -1)

If we want score to be a random number in the range of [10.0, 50.0), which statement would be correct (assume the random library has been imported)?

score = 40.0 * random() + 10.0

The input function takes a ___ as a parameter values and returns a(n)___

string, string

Which character starts a comment in a Python program?

#


Conjuntos de estudio relacionados

Vocabulary Workshop (Level E) Units 11-12

View Set

Ch. 8: Designing Pay Levels, Mix and Pay Structures - MGT 461

View Set

Biomechanics Chapter 4 Human Strength and Power

View Set

Taxes, Retirement, and Other Insurance Concepts

View Set

SyS: Lección 2 - Definiciones y conceptos básicos

View Set