Section 1

Preview this deck

A while loop will execute once for each expression in the conditional.

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 14, 2020

Cards (49)

Section 1

(49 cards)

A while loop will execute once for each expression in the conditional.

Front

False

Back

Which of the following can be involved in an expression?

Front

Variables, Other Expressions, Values, Conditional Operators, Mathematical Operators

Back

1. Function.call() 2. print() 3. file.(close) 4. method() 5. "function".method() 6. (input)

Front

1. method call 2. function call 3. not a call 4. function call 5. method call 6. not a call

Back

Which of the following types are sequences?

Front

File, Dictionary, List, Tuple, String

Back

Which of the following have a body?

Front

While loop, if statement, function definition, for loop

Back

Choose which of the following are valid Python variable names. Note that they do not have to be good variable names, just valid.

Front

BankAccount,stor_txt,_27_

Back

The input function does which of the following

Front

Writes output to the console, retrieves input from the user, returns a string, consumes arguments

Back

Like an if statement and a function call, the for Loop might cause the execution to not follow the sequential order of lines.

Front

True

Back

Which of the following are possible subtypes for a list?

Front

Boolean, List, Integer, String, Dictionary

Back

Dictionaries will always have at least one key and one value.

Front

False

Back

Printing is the same thing as returning.

Front

False

Back

You must import the json module before you can use the load function.

Front

True

Back

The print function does which of the following?

Front

Consumes arguments, writes output to console

Back

Which of the following two snippets of code are equal?

Front

from json import load file = open("scores.txt") load(file) import json file = open("scores.txt") json.load(file)

Back

Keys can be added to a dictionary after the dictionary has been created.

Front

True

Back

A for loop will process a file sentence-by-sentence.

Front

False

Back

Humans discovered programming languages in the 1940s and have been decoding them ever since.

Front

False

Back

Mark each of the following email titles if they are GOOD titles when seeking help from a senior colleague.

Front

"What is a TypeError and how do I get rid of it?" , "How do I update a variable?"

Back

Unlike Lists, Tuples are immutable, meaning Tuples cannot be changed after they are created.

Front

True

Back

Lists can be composed of Dictionaries.

Front

True

Back

Which of the following types are sequences?

Front

File, Dictionary, List, Tuple, String

Back

The given program does not correctly close the file: def has_a_cat(filename): a_file = open(filename) return "cat" in a_file.read() a_file.close() has_a_cat("story.txt")

Front

True

Back

How many values can be used at a time with each of the following operators? +,not,and,!=

Front

2,1,2,2

Back

Every function created with the def keyword must have AT LEAST ONE parameter.

Front

False

Back

Expressions are always evaluated from left to right.

Front

False

Back

The body of a for loop will contain one statement for each element of the iteration list.

Front

False

Back

Variable names are important because computers understand the meaning of names and change their value accordingly.

Front

False

Back

Tuples are composed of key/value pairs.

Front

False

Back

The open function consumes a String representing a path and returns a String of the file's contents.

Front

False

Back

Read or Write

Front

price = 0 ; write print(price) ; read adjusted = price * tax ; read price = price * 0.9 ; read and write

Back

List comprehensions cannot express everything that a for loop can

Front

True

Back

The print function can only print literal values.

Front

False

Back

Dictionaries are useful because you can have duplicate keys.

Front

False

Back

How many branches do each of these code snippets have? if conditional: print(4) print(4) if conditional: print(1) else: print(3) if conditional1: if conditional2: print(4) print(3) print(2)

Front

2,2,3

Back

Dictionaries cannot be composed of Lists.

Front

False

Back

Once a function returns a variable, that variable is available outside of the function.

Front

False

Back

What is the value of tax after this program executes? if False: tax = 5 print(tax)

Front

No value, because an error occurs since the value has not been defined

Back

You should not put error messages into help seeking emails because it can clutter up the email.

Front

False

Back

Variables in Python are used to solve for unknown values, like in Algebra.

Front

False

Back

A while loop will always execute at least once.

Front

False

Back

When the following code is executed, what will be the value of the variable named greeting? def make_greeting(name): print("Hello", name) greeting = make_greeting("Mr. Anderson")

Front

None

Back

Normally, statements are executed from top to bottom.

Front

True

Back

The print function is necessary to call a function.

Front

False

Back

You can nest if statements inside of other if statements, but not inside functions.

Front

False

Back

Variables change their value over time according to the instructions in a program

Front

True

Back

The Iteration Variable will take on each value of the List Variable, one at a time.

Front

True

Back

name = input("What is your name?") def fix_capitalization(name): return name.title().strip() def print_message(name): print("Hello", name, "how are you?") Which of the following lines of code will have the data flow correctly through both functions in order to print the message with the fixed capitalization?

Front

name = fix_capitalization(name) print_message(name) print_message(fix_capitalization(name))

Back

The statement count = count + 1 will cause an error because no number can be greater than itself.

Front

False

Back

Strings are composed of only letters and symbols.

Front

False

Back