Python study material 5315

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

secondary memory

A USB memory stick is an example of which of the following components of computer architecture?

true

A boolean expression is an expression that is either true or false.

delimiter

A character or string used to indicate where a string should be split.

aliasing

A circumstance where two or more variables refer to the same object is called _________.

both A and C. (.exe and .dll

A compiler will process source code and generate a(n) ____________ file

false

A for loop over an empty list will cause an error.

true

A function call is like a detour in the flow of execution. It executes then goes back the point of call.

infinite loop

A loop in which the terminating condition is never satisfied or for which there is no terminating condition.

true

A program is a sequence of stored instructions

true.

A program is a sequence of stored instructions

slice

A segment of a string is called a __________.

true

A sequence of instructions in a programming language is call Code

false

A special character used in files and strings to indicate the end of a line is called a nextline.

invocation

A statement that calls a method.

false

An iteration variable is used in a loop to help accumulate a sum, also know as an accumulator."

true

As opposed to a string, a list can hold any type items

false

The break statement within a loop will cause the iteration to continue.

true

The continue statement within a loop will cause the iteration to continue.

2

What does the following Python code return? (Note that this is a bit of a trick question and the code has what many would consider to be a flaw/bug so read carefully). def addtwo(a, b): added = a + b return a x = addtwo(2, 7) print(x)

5

What does the following Python program print out last? tot = 0 for i in [5, 4, 3, 2, 1] : tot = tot + 1 print(tot)

hello there

What does the following code print out? def thing(): print('Hello') print('There')

sum all the elements in a list

What is a good description of the following bit of Python code?; zork = 0for thing in [9, 41, 12, 3, 74, 15] : zork = zork + thingprint ('After , ' + str(zork))

else

What is the Python reserved word that is used in a two-way decision structure when the executed logical test is false?

friend

What is the iteration variable in the following Python code: friends = [ 'Joseph' , 'Glenn' , 'Sally' ]for friend in friends : print('Happy New Year:, ' + friend)print('Done!')

1,4,9,16

What is the output of below code: numbers = [1, 2, 3, 4] sol = 0 for val in numbers: sol = val * val print(sol)

python java c

What is the output of below code: prog = ["python", "java", "c#"] for i in prog: print(i)

10

What is the output of below code: sum = 0 for val in range(1,5): sum = sum + val print(sum)

Negative Number followed by Two digit Negative Number

What is the output of below code:num = -33if num > 0: print("Positive Number")else: print("Negative Number") #nested if if -33<=num: print("Two digit Negative Number")

four digit number

What is the output of below code:num = 1000if 9 < num < 99: print("Two digit number")elif 99 < num < 999: print("Three digit number")elif 999 < num < 9999: print("Four digit number")else: print("number is <= 9 or >= 9999")

8

What is the output of the following code? k=10 k -= 2 print(k)

false

What is the output of the following code? mylist = [10,222.5,"Python",150] print(150 not in mylist

2.0

What is the output of the following code? print(100/50)

9

What is the output of the following code? print(3**2)

1

What is the output of the following code? print(7%3)

2

What is the output of the following code? print(7//3)

13

What is the value of the expression 1 + 2 * 2 3 ?

:

What signifies the beginning of a statement block or suite in Python?

string index out of range

What type of error is caused by reading a string via bracket operator and the wrong index?

nothing

What will be printed when the following loop is executed? n = 0 while n > 0 : print('Lather') print('Rinse') print('Dry off!')

98

What will be the value of x when the following statement is executed: x = int(98.6)

-1

What will the following code print out? smallest_so_far = -1for the_num in [9, 41, 12, 3, 74, 15] :if the_num < smallest_so_far :smallest_so_far = the_numprint(smallest_so_far)

small all done

What will the following code print out? x = 0 if x < 2 : print('Small') elif x < 10 : print('Medium') else : print('LARGE') print('All done')

20

What will the following program print out >>> x = 15: >>> x= x + 5; >>> print (x)

true

When reading in a string with the bracket operator [], you must start the reference at 0 like any index."

syntax

When the computer does not understand the statement that you entered, it is a ____________ error.

true

When you are typing code directly at the chevron >>> you are coding interactively

true

When you have multiple lines in an if block, you terminate that block by de-indent the next line past the if block to the same level of indent as the original if statement.

def

Which Python keyword indicates the start of a function definition?

pop()

Which function is way to remove an element from a list by index?

()

Which of the following elements of a mathematical expression in Python is evaluated first?

do while

Which of the following is not a valid loop in Python?

central processing unit

Which of the parts of a computer actually executes the program instructions?

Both A and B (if and break)

Which of these words are reserved words in Python?

finally

Which one of the following is not a way to control program flow in a Python loop?

random()

Which one of these functions was NOT covered in Chapter 1 or 2?

while

Which reserved word indicates the start of an indefinite loop in Python?

true

Writing and reading files within your program is working directly with secondary memory.

false

You can use a variable in an expression without first declaring it.

indent/space problem

You look at the text: If x == 6 : pint('is 6') print('is still 6') print('Third 6') it looks perfect but python is giving you and 'indentation error' on the second print statement. what is the most likely reason?

counter

You use a ______________ which is a variable used in a loop to count the number of times something happened

counter

You use a ______________ which is a variable used in a loop to count the number of times something happened.

user-defined

a ________ function is created by the programmer and can use built in functions

false

a function can be passed an parameter which is placed inside an argument in the function

true

a function definition specifies the name of a new function and the sequence of statements that execute when the function is called.

true

a function definition specifies the name of a new function and the sequence of statements that execute when the function..

true

a function is a named sequence of statements that performs a computation

try, except

a good practice in working with files in your code is the use of ___ and ____ to reduce abnormal endings of your program.

text file

a sequence of characters stored in permanent storage like a hard drive is called a

pythonic

a technique that works elegantly in python is called

built in

python comes with functions called ________ functions.

for, definite

the _____________ loop is best for a list of things to loop through and is considered a ______________loop.

argument

the expression in parantheses at the end of a function is called the

false.

the random function generates true random numbers not pseudorandom numbers.

catching

to prevent an exception from terminating a program using the try and except statements is called ____ an error.

false.

true or false: strings are mutable

false

variable names can be arbitrarilry long. they can contain both letters and numbers.

false

what boolean will be the output of the following 12: != 12

true

what boolean will be the output of the following: 2 < x <10 when x = 5?

indent the next line

what do we do to a python statement that is immediately after an if statement to indicate that the statement is to be executed only when the if statement is true

Even Number

what is the output of the below code: num = 42 if num %2 == 0: print ("even number") else: print("odd number")

true

what is the output of the following code? x = 100 y = 100 print(x==y or x)

quit()

what is the proper way to say goodbye in python

bonjour michael

what will he following python program print out?def greet(lang): if lang =='es' return 'hola' elif lang=='fr' return 'bonjour'..etc

file handle

when opening a file successfully the operating system returns back a ______ ________

true

when you have multiple lines in an if block, you terminate that block by de-indent the next line past the if block to the same level of indent as the original if statement.

print ('world')

which line of the following python program is useless? def stuff() print('hello') return print('world')

print

which of the following is not a python reserved word?

=

which of these operators is not a comparison or logical operator

INTERPRETER

"An ____________ reads the source code of the program as written by the programmer, parses the source code, and interprets the instructions on the fly."

true

"In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type"

variable

"In the following code, x = 42. What is x ?

concatenation

"The + operator works with strings, but it is not addition in the mathematical sense. This is called _____________."

true

"Using string comparison, is the following statement true or false: Banana comes before apple"

len

"When working with strings, you can return the length using the ______________ function."

false

Conditional code is when the code block executes from top to bottom

true

What Boolean will be the output of the following: a= 12 b = a-10 a > b

-1

For the following code: astr = 'Hello Bob' istr = 0 try: istr = int(astr) except: istr = -1 What will the value be for istr after this code executes?

false

For the following code: if x < 2: print('Below 2') elif x >= 2: print'Two or more') else: print('Something else'). If the value of x is set to a number, print('Something else') will print out."

equivalent, identical

Having the same value is ___________ while _____________ is being the same object.

infinite times

How many times will this code Python loop: n = 5 while n > 0 : print(n) print(All done)

false

In Python, a variable must be declared before it is assigned a value"

a statement that controls the flow of execution depending on some condition.

In a python program, a conditional statement is,

number

In the following code, print(98.6). What is 98.6 ?"

false

In the following code, using the friends list requires the use of friend as the iteration variable. friends = [' Joseph', 'Glenn', 'Sally'] for friend in friends: print(' Happy New Year:', friend) print(' Done!')"

false

Lists are immutable in Python.

false

Python and C# are both compliers

false

Python is a strongly typed language in which you must declare your variables before use.

input

Python provides a built-in function called _________ that gets input from the keyboard.

py

Python scripts (files) have names that end with what type of file extension?

true

Repeative code is when the code block executes over and over until it is finished.

false

Sequential code is when questions are asked of the program to determine flow.

true

one of python's strengths is working with files and reading data

false

The for loop is considered the indefinite loop and the while loop is a definite loop.

false

The max() funciton only works with number list.

C

The python interpreter was written in the _________ programming language.

true

The slice of this statement is: fruit = 'apple'; fruit[:3] returns 'app'.

false

The sum() funciton will work with numbers and letters

TRUE

Variable names can contain an underscore _ but should not start with one unless writing library code.

true

We call the while statement an indefinite loop because it simply loops until some condition becomes False.

you de-indent a line of code to the same indent level as the def keyword

in python, how do you indicate the end of the block of code that makes up the function?

built in function

in python, what is the input() feature best described as?

x

in the following python code which of the following is an argument function. x= banana y = max(x) print(y)

false

it is not possible to allow end users to select files in python

import

working with some built in functions require the ________ call at the beginning of the program.

false

writing code and running it interactively stores the information processed in secondary memory


संबंधित स्टडी सेट्स

Domain #3 - Immediate and Emergency Care

View Set

Neuro Review Q's - Alicia Review 11/6

View Set

Ch 13 Special Senses Eyes and Ears

View Set

WEEK 6: Hormonal Control and Reproduction - OBJECTIVES

View Set

Unit Quizzes 1, 2 & 3 health 320

View Set