CS Python Final Exam Flashcards

(35 cards)

1
Q

When to use a For loop

A

When the number of iterations is known

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When to use a while loop

A

While the statement is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What would for x in range(2,6) print?

A

2
3
4
5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

range(a, c) function

A

it prints a and b BUT NOT C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Is for i in range(0,10) the same as for i in range(10) ?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the name of the panel in ear sketch that contains all of the assembled audio clips?

A

Digital Audio Workstation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

c) using descriptive names for variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Top down design makes it easier to solve a problem as it

A

breaks the problem down into smaller parts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The input() function in python returns the user input as a …

A

string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Variables allow us to

A

store information to use in our programs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If programmers write an if statement and the condition is false, what does turtle do?

A

Turtle skips the command under the if statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is missing? What should be written?
import tkinter as tk
m = tk.Tk()
#Widgets added here

A

The last line of code,
m.mainloop()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you name a window in tkinter?

A

title = tk.Tk()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you import tkinter

A

import tkinter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How many possible values are there for a boolean variable?

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the possible values are there for boolean variablse?

17
Q

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)

18
Q

How many lines will this program print?
while True:
print(“hi”)

A

an infinite number of lines

19
Q

What is the value of num when this loop completes?
num = 0
for i in range(2, 8, 2):
num = num+ i

20
Q

What happens to statements after a return line?

A

They will not be executed

21
Q

What are two ways to print E ?
my_string = “ABCDE”

A

print(my_string[-1])
print(my_string[4])

22
Q

What is the index of the letter A in my_string?
my_string = “ABCDE”

23
Q

How do I print BCDE ?
my_string = “ABCDE”

A

print(my_string[1:])

24
Q

Which operator allows you to create a string that is the result of putting two different strings together, side by side?

25
What is a string?
It is a sequence of characters and is immutable
26
What is an integer?
A number that does not have a decimal point
27
What is a float?
an integer followed by a decimal point
28
What does case sensitive mean?
It means that upper case and lower case are different e.g.) a is not equal to A
29
not equal to sign in coding
!=
30
some logical operators are ...
and, or, not
31
How to make a show info message box
messagebox.showinfo("title", "inside text")
32
What does the following print? print(10 > 9)
True
33
What does the following print? print(10 == 9)
False
34
What is a function name
Everything following the def
35
What is a function call
When you call the function you defined, can have parameters within it