Tech Smart Test 2

Ace your homework & exams now with Quizwiz!

What symbol is used in Python to raise one number to the power of another number? (exponentiation operator) // ** %% ++

**

What value is printed out by this code? x = 0 if x < 0: x += 1 print(x)

0

Which of the following values for num would cause this condition to be True? if 1 < num <= 100: print("Valid guess") 1 100 1000 None of the above

100

What is the chance that the secret item will be "bell"? Give your answer as a fraction. import random secret = random.randint(1, 6) if secret == 1: secret_item = "pin" elif secret == 2: secret_item == "toy" elif secret == 3: secret_item = "cookie" else: secret_item == "bell"

3/6

What value is printed out by this code? x = 100 if x > 0: x -= 1 print(x)

99

Boolean

A True or False value

Comment

A note that the computer ignores

Logic error

An error that doesn't cause an error message.

Runtime error

An error that occurs while the program is running.

Syntax error

An error that prevents the program from running.

If statement

An if statement, or conditional, is a code structure that makes a decision. It is composed of a line that asks a question, and then one or more indented lines that run or are skipped based on the answer to that question.

22 What is the easiest way to find out what functions are available in the math library? Check the documentation Import the math library Call "print_all_functions()" There is no way of knowing what is in the math library

Check the documentation

Style

Code formatting that does not affect how the program runs.

Logical operator

Combines or modifies a boolean

The expression below evaluates to what boolean value? (True and False) or (False and True)

False

PEP 8

The official guidelines for Python code formatting

Which of the following is true about the decision-making lines (clauses) in conditionals? They always contain a keyword and a colon They always contain a condition They are always indented They are always surrounded by blank lines

They always contain a keyword and a colon

and operator

True if all parts are True

or operator

True if one or more parts are True

Replace the _ symbol in the following code with the operator that gets the remainder after division (modulo). even = num_2 == 0

even = num % 2 == 0

Choose the expression that best represents the sentence: "I will only go to the movie if both my friends are going and I have no homework." not (friend1 or friend2) and homework not (friend1 and friend2) and homework friend1 or friend2 or not homework friend1 and friend2 and not homework

friend1 and friend2 and not homework

Highlight the condition in the following code. Do not highlight any extra characters. my_var = 0 if my_var > 99: print ("This number has at least 3 digits..")

my_var = 0 if my_var > 99: print ("This number has at least 3 digits..")

Which of the following is a function from the random library? None sqrt solve randint

randint

Which of the following is a function from the math library? None sqrt solve randint

sqrt

Fix the error in this code that stops it from running. user_day = input("Enter a date: ") day = "September 21" if day = user_day: print ("Oh! How did you know the secret date?")

user_day = input("Enter a date: ") day = "September 21" if day == user_day: print ("Oh! How did you know the secret date


Related study sets

Chapter 5: Growth & Development of the Preschooler

View Set

Chapter 45 Care of a Patient With a Gastrointestinal Disorder

View Set

20/21_GRPS_ELECTIVE_Computer Applications - Office 2016_A_IC UNIT 1

View Set

Chapter 29 Questions - Sexual Assault

View Set

Interpersonal Communication Exam #1

View Set