Unit 1 Mod 1.1-1.2
Unit 1 Mod 1.3-1.4
Unit 2 Mod 2.1-2.2
Unit 2 Mod 2.3-2.4
Unit 3
100

What is the output after the code runs?

x="six"

x=7

x="eight"

print(x)

eight

100

What datatype does the input Function return?

String

100

count = 1

while count >= 1:
    print("loop")
    count +=1

forever loop

100

What is the index of the first character in a list?

0

100

What type of loop should you use to repeat a code process as long as a condition resolves as `True`?

While

200

The following code produces what type of error?

numerator = 4 

denominator = 0

answer= numerator/denominator

print("The answer is" +str(answer))

RunTime Error

200

1. greet(name)
2. name = input("enter your name: ")
3. greet(name)
4. def greet(person):
5.      print("Hi,", person)
6. greet(name)

Which line or lines need to be removed from the above code so the program prints a greeting without error?

Lines 1 and 3

200

time = 3

while True:
    print('time is', time)
    if time == 3:
        time = 4
    else:
        break

"time is 3" & "time is 4"

200

Write the code that will place another "2" integer to the end of the following list?

numbers = [1, 1, 2]

numbers.append(2)

200

What function can you use to test whether an absolute or relative path to a folder is valid?

os.path.exists(path)

300

def add_nums(num = 1):
    return num + num


What is the correct output of calling the function above using the following code:

print(add_nums(25))

50

300

What is the output of the following code? 

gpa = 3.62
print("Your GPA is", gpa, ".")

Your GPA is 3.62 .

300

Write the code that will print the word "tac", given the following variable declaration?

word = "cat"

print(word[::-1])

300

What is the result of the following code?

numbers = [2, 3, 2]
total = 0
while numbers:
    total += numbers.pop()

numbers is an empty list and total is 7

300

Create the tuple, T, with one element (25).

T = (25,)

400

What is the output of the following code?

name = 16
if name.startswith("n"):
    print("Hello")
else:
    print("Goodbye")

An error message

400

What is the value of x after the following code is run?

x = 2

y = 1

x += y + 1

4

400

Write the Python code that results in output of a sorted scores list WITHOUT changing the original scores list below?

scores = [ 0, 5, 2, 11, 1, 9, 7]

print(sorted(scores))

400

After we open a file (first_test) using:

test1 = open('test1.txt', 'r')

we can read the file into memory with what Python code?

test_data = test1.read()

400

What is the result of the following code? 

(Name, Grade) = ("Anne", 95)
print(Name, Grade)

Anne 95

500

PriNt("Hello World!") will not output the message "Hello World!".

What type of error will it result in?

NameError
500

answer = input("enter your answer: ") 

print("You entered " + answer)

If user input is 38, what is the output of the above code?


You entered 38

500

Write the code that will delete the "5" in the following numbers list?

numbers = [7, 1, 5, 8, 0]

del numbers[2]

500

To move the pointer in an open file to the first character, what should you use?

.seek(0)

500

What is the output of the following code? 

year = 2017
price = 2.42011
print('The national average gas price in %i was $ %3.2f' % (year, price))

he national average gas price in 2017 was $ 2.42

M
e
n
u