CS Python Final Exam Flashcards

You may prefer our related Brainscape-certified flashcards:
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?

A

True, false

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)

A

a

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

A

12

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”

A

0

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?

A

+

25
Q

What is a string?

A

It is a sequence of characters and is immutable

26
Q

What is an integer?

A

A number that does not have a decimal point

27
Q

What is a float?

A

an integer followed by a decimal point

28
Q

What does case sensitive mean?

A

It means that upper case and lower case are different e.g.) a is not equal to A

29
Q

not equal to sign in coding

A

!=

30
Q

some logical operators are …

A

and, or, not

31
Q

How to make a show info message box

A

messagebox.showinfo(“title”, “inside text”)

32
Q

What does the following print?
print(10 > 9)

A

True

33
Q

What does the following print?
print(10 == 9)

A

False

34
Q

What is a function name

A

Everything following the def

35
Q

What is a function call

A

When you call the function you defined, can have parameters within it