Python Midterm

studied byStudied by 1 person
0.0(0)
get a hint
hint

John von Neumann is known for the observation that the number of transistors that fit on a computer chip doubles every year

1 / 180

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

181 Terms

1

John von Neumann is known for the observation that the number of transistors that fit on a computer chip doubles every year

False

New cards
2

The term hertz can be used to describe a computer's speed.

True

New cards
3

Information in secondary memory is lost if the power is turned off.

False

New cards
4

What components are part of the von Neumann model?

control unit, arithmetic logic unit, memory, input and output

New cards
5

Who developed the Python programming language?

Guido van Rossum

New cards
6

Python is a general-purpose programming language, appropriate for solving problems in many areas of computing.

True

New cards
7

The Python programming language was so named after a snake was discovered in the creator's office.

False

New cards
8

Python 3 is backwards compatible to Python 2.

False

New cards
9

Python embodies elements of which programming paradigm?


Procedural programming

Object-oriented programming

Functional programming

New cards
10

Which of the following is NOT a principle embraced by the Python programming language?

Verbose is better than succinct

New cards
11

Thonny is best described as which of the following?

Integrated Development Environment(IDE)

New cards
12

The output of a Python program run in Thonny appears in the shell window.

True

New cards
13

Thonny displays code using syntax highlighting.

True

New cards
14

Running a program that contains errors will cause the Thonny development environment to terminate.

False

New cards
15

Thonny has a package manager that lets you install and update external Python packages.

True

New cards
16

A Python program must be enclosed in curly braces { } to be executed.

False

New cards
17

Which of the following statements is true??

The print statement is a call to a function.

New cards
18

A Python program must compiled into an executable form before it can be run.

False

New cards
19


What is syntax coloring?

Showing certain elements of program code in different color

New cards
20

What does the term case sensitive mean?

The difference between upper and lowercase letters matter

New cards
21

Why don't we use natural languages (like English) to program a computer?

Natural languages are semantically ambiguous

New cards
22

What is the syntax of a language?

The rule that determine how words and symbols can be combined

New cards
23

In a programming language, a syntactically valid statement has only one meaning.

True

New cards
24

A program that runs without generating a runtime error will produce correct results.

False

New cards
25

Which of the following would cause a syntax error?

Misspelling a keyword

New cards
26

Which of the following would cause a runtime error?

Dividing by zero

New cards
27

Computing the wrong answer is an example of what kind of error?

logic error

New cards
28

Debugging is the process of:

Finding the root cause of an error and fixing it

New cards
29

The code you write is called Python bytecode.

False

New cards
30

To run a Python program, the interpreter combines your code with any library code your program uses.

True

New cards
31

Python bytecode is not associated with any particular type of computer processor.

True

New cards
32

The Python package installer is called pip.

True

New cards
33

A graphical representation of the logic of an algorithm.

flowchart

New cards
34

A step-by-step procedure for solving a problem.

algorithm

New cards
35

The data needed by an algorithm to accomplish its task.

input

New cards
36

The level at which an instruction is expressed.

granularity

New cards
37

A language that humans use to communicate, such as French or English.

natural language

New cards
38

The data produced by an algorithm.

output

New cards
39

A language that is independent of any particular programming language.

pseudocode

New cards
40

What output does the following code produce?

print(‘apple’ , ‘banana’)

apple banana

New cards
41

What output is produced by the following code?

print(15+30)

45

New cards
42

What output does the following code produce?

print('Ready', end=' ')
print('Set', end='')
print('Go')

Ready SetGo

New cards
43

What output is produced by the following code?

print('Jan', 'Feb', 'Mar', sep='-')

Jan-Feb-Mar

New cards
44

What output is produced by the following code?

print('oak', 'elm', 'pine', end='!', sep='#')

oak#elm#pine!

New cards
45

What operator is used to perform string concatenation in Python?

+

New cards
46

What output does the following code produce?

print('Total: ' + 100 + 20)

No output. This line would produce an error. (You cant concatenate a string and an integer)

New cards
47

What issue must be addressed when printing a long character string?

A regular string literal cannot span across multiple lines. (use triple quote)

New cards
48

If a variable called pioneer refers to the string 'Grace Murray Hopper', what is the result of the expression len(pioneer)?

19

New cards
49

If a variable called business refers to the string 'Time Warner', what is the result of the expression business[6]?

‘a’

New cards
50

If a variable called son refers to the string 'Justin', what is the result of the expression son[-3]?

‘t’

New cards
51

You cannot change the contents of Python character string once it has been created.

True

New cards
52

If a variable called jedi refers to the string 'Yoda', what is the result of the expression jedi * 3?

YodaYodaYoda

New cards
53

Python comments begin with a hash mark (#) and extend to the end of the line

True

New cards
54

A comment in a Python program is ignored by the interpreter.

True

New cards
55

A Python comment cannot appear on a line that contains an executable statement.

False

New cards
56

A Python block comment begins with a double slash (//).

False

New cards
57

What is a docstring?

A character string used as a comment in a program.

New cards
58

Python variables that represent integers are NOT object reference variables.

False

New cards
59

In dynamically typed languages, variables are declared to store a specific type of data.

False

New cards
60

Which of the following identifiers follows the convention for naming Python variables?

total_value

New cards
61

Which of the following is NOT a valid Python identifier?

1stPlace

New cards
62

The value of a variable can change throughout a program.

True

New cards
63

Python variables are created using an assignment statement.

True

New cards
64

Suppose the integer variable hours contains a value that represents a number of hours. Which of the following expressions will compute how many 24-hour periods are represented by that value, without worrying about any leftover hours.

hour // 24

New cards
65

If the variable num contains a positive integer, what are the only two possible results of the expression num % 2?

0 and 1

New cards
66

What is the result of the expression 43 % 5?

3

New cards
67

What is the result of the expression 7 // 2?

3

New cards
68

The math module contains a constant that represents the value pi to several digits.

True

New cards
69

The expression x ^ y raises the value x to the power y.

False

New cards
70

If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n.

False

New cards
71

If either or both operands to the division operator (//) are floating-point values, then the result will be a floating-point value.

True

New cards
72

The value assigned to a variable could be a floating point number.

True

New cards
73

In Python, the assignment statement is also an expression.

False

New cards
74

The value assigned to a variable must be numeric.

False

New cards
75

What value is assigned to the variable num by the following statement if the current value of num is 4?

num = num * 2

8

New cards
76

The assignment operator has higher precedence than the arithmetic operators.

False

New cards
77

The input function will produce an error if the value read is not numeric.

False

New cards
78

The inputint, and float functions are all built-in functions.

True

New cards
79

The input function always returns the read data as a character string.

True

New cards
80

What is text that requests user input called?

prompt

New cards
81

Which of the following does the input function NOT do when it is called?

convert the user input to an integer

New cards
82

What will happen if the variable total has the value 5 when the following code is executed?

if total > 8:
print('collywobbles')

The word collywobbles is not printed and processing continues

New cards
83

Which value of num will cause the print statement in the following code to be executed?

if num < 15:
if num + 7 >= 20:
print('There you go!')

13

New cards
84

3

What output is printed by the following code if it is executed when appetizer is 3 and entree is 12?

if appetizer > 1:
if entree < 7:
print('ketchup')
else:
print('mustard')
else:
if appetizer < 0:
print('mayonnaise')
else:
print('relish')

mustard

New cards
85

Which of the following statements is true?

The statements in the body of an if must be indented

New cards
86

Of the options given, what values of the variables heightsize, and widthwould cause the following code to set the variable weight to 100?

if height < size:
weight = 50
if width < 20:
print('short')
else:
if width > 100:
weight = 100
println('tall')

height = 15, size = 10, width = 110

New cards
87

An if statement cannot have both an elif and an else clause.

False

New cards
88

The relational operators all return boolean results.

True

New cards
89

The result of a relational operator can be assigned to a variable.

True

New cards
90

The arithmetic operators have a lower precedence than the relational operators.

False

New cards
91

Which of the following is a relational operator?

<=

New cards
92

Which of the following expressions could be used to determine if a is not less than b?

a>=b

New cards
93

In Python, the relational operators can be used to put character strings in alphabetical order.

True

New cards
94

The less than operator (<) should not be used to compare floating point values.

False

New cards
95

A character string can be used as the condition of an if statement.

True

New cards
96

Strings containing non-alphabetic characters cannot be compared using the relational operators.

False

New cards
97

Which of the following conclusions is NOT true when using relational operators to compare character strings?

‘reset’ come before ‘reserve’

New cards
98

Which of the following conclusions is NOT true when using relational operators to compare character strings?

‘fantastic’ comes before ‘Great’

New cards
99

When using relational operators to compare character strings, 'ZEBRA'comes before 'ALLIGATOR'.

False

New cards
100

When using relational operators to compare character strings, 'Music'comes before 'music'.

True

New cards

Explore top notes

note Note
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 55 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 13 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 284 people
Updated ... ago
5.0 Stars(7)
note Note
studied byStudied by 13700 people
Updated ... ago
4.9 Stars(60)

Explore top flashcards

flashcards Flashcard91 terms
studied byStudied by 23 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard110 terms
studied byStudied by 219 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard76 terms
studied byStudied by 52 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard89 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard25 terms
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard22 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard66 terms
studied byStudied by 13 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard25 terms
studied byStudied by 170 people
Updated ... ago
4.7 Stars(33)