CS Python Final Exam Flashcards
When to use a For loop
When the number of iterations is known
When to use a while loop
While the statement is true
What would for x in range(2,6) print?
2
3
4
5
range(a, c) function
it prints a and b BUT NOT C
Is for i in range(0,10) the same as for i in range(10) ?
yes
what is the name of the panel in ear sketch that contains all of the assembled audio clips?
Digital Audio Workstation
Which of the following is NOT an example of Top Down design?
a) separating a large problem into a smaller one
b) writing code for one part of a function before tackling the whole thing
c) using descriptive names for variables
d) breaking a large code into smaller functions
c) using descriptive names for variables
Top down design makes it easier to solve a problem as it
breaks the problem down into smaller parts
The input() function in python returns the user input as a …
string
Variables allow us to
store information to use in our programs
If programmers write an if statement and the condition is false, what does turtle do?
Turtle skips the command under the if statement
What is missing? What should be written?
import tkinter as tk
m = tk.Tk()
#Widgets added here
The last line of code,
m.mainloop()
How do you name a window in tkinter?
title = tk.Tk()
How do you import tkinter
import tkinter
How many possible values are there for a boolean variable?
2
What are the possible values are there for boolean variablse?
True, false
Which of the following expressions generates true when x is between 10 and 20 inclusive
a. (x <= 20) and (x >= 10)
b. (x == 10) and (x <= 20)
c. (10 < x < 20)
d. (10 <= x <= 20)
a
How many lines will this program print?
while True:
print(“hi”)
an infinite number of lines
What is the value of num when this loop completes?
num = 0
for i in range(2, 8, 2):
num = num+ i
12
What happens to statements after a return line?
They will not be executed
What are two ways to print E ?
my_string = “ABCDE”
print(my_string[-1])
print(my_string[4])
What is the index of the letter A in my_string?
my_string = “ABCDE”
0
How do I print BCDE ?
my_string = “ABCDE”
print(my_string[1:])
Which operator allows you to create a string that is the result of putting two different strings together, side by side?
+
What is a string?
It is a sequence of characters and is immutable
What is an integer?
A number that does not have a decimal point
What is a float?
an integer followed by a decimal point
What does case sensitive mean?
It means that upper case and lower case are different e.g.) a is not equal to A
not equal to sign in coding
!=
some logical operators are …
and, or, not
How to make a show info message box
messagebox.showinfo(“title”, “inside text”)
What does the following print?
print(10 > 9)
True
What does the following print?
print(10 == 9)
False
What is a function name
Everything following the def
What is a function call
When you call the function you defined, can have parameters within it