Part 1
Part 2
Part 3
Part 4
Part 5
100

What are the values that the variable num contains through the iterations of the following for loop?

for num in range(4)

 

0, 1, 2, 3

100

When will the following loop terminate?

while keep_on_going != 999 :

When keep_on_going refers to a value equal to 999

100

The first line in the function definition is known as the function _____.

header

100

What is the result of the following statement?

x = random.randint(5, 15) * 2

A random integer from 5 to 15, multiplied by 2, assigned to the variable x

100

Assume that the customer file references a file object, and the file was opened using the ‘w’ mode specifier. How would you write the string ‘Mary Smith’ to the file?

customer.write(‘Mary Smith’)

200

_____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.

input validation

200

Which of the following represents an example to calculate the sum of the numbers (accumulator)?

total += number

200

The _____ of a local variable is the function in which the variable is created.

scope

200

What will be displayed after the following code is executed?

def pass_it(x, y):

    z = x*y

    result = get_result(z)

    return(result)

def get_result(number):

    z = number + 2

    return(z)

num1 = 3

num2 = 4

answer = pass_it(num1, num2)

print(answer)

14

200

When a file has been opened using the ‘r’ mode specifier, which method will return the file’s contents as a string?

read

300

What is the structure that causes a statement or a set of statements to execute repeatedly?

repetition

300

What will be displayed after the following code is executed?

for num in range(0, 20, 5):

    num += num

print(num)

30

300

What will be the output after the following code is executed?

def pass_it(x, y):

    z = x + ", " + y

    return(z)

name2 = "Tony"

name1 = "Gaddis"

fullname = pass_it(name1, name2)

print(fullname)

Gaddis, Tony

300

What does the following statement mean?

num1, num2 = get_num()

The function get_num() is expected to return a value each for num1 and num2.

300

What will be the output after the following code is executed?

def pass_it(x, y):

    z = y**x

    return(z)

num1 = 3

num2 = 4

answer = pass_it(num1, num2)

print(answer)

64

400

count = 4

while count < 12:

    print("counting")

    count = count + 2

counting 

counting

counting

counting

400

What will be displayed after the following code is executed?

total = 0

for count in range(4,6):

    total += count

    print(total)

4

9

400

A(n) _____ variable is accessible to all the functions in a program file.

global

400

What happens when a piece of data is written to a file?

Data is copied from a variable in RAM to a file.

400

school has following rules for grading system:

a. Below 25 - F

b. 25 to 45 - E

c. 45 to 50 - D

d. 50 to 60 - C

e. 60 to 80 - B

f. Above 80 - A

Ask user to enter marks and print the corresponding grade.                            

Answer 

print ("Enter marks")

marks = int(input())

if marks<25:  print ("F")

elif marks>=25 and marks<45:  print ("E")

elif marks>=45 and marks<50:  print ("D")

elif marks>=50 and marks<60:  print ("C")

elif marks>=60 and marks<80:  print ("B")

else:  print ("A")

500

What does the following program do?

student = 1

while student <= 3:

    total = 0

    for score in range(1, 4):

        score = int(input("Enter test score: "))

        total += score

    average = total/3

    print("Student ", student, "average: ", average)

    student += 1

It accepts 3 test scores for each of 3 students and outputs the average for each student.

500

What is a group of statements that exists within a program for the purpose of performing a specific task?

function

500

What will be the output after the following code is executed?

def pass_it(x, y):

    z = x , ", " , y

num1 = 4

num2 = 8

answer = pass_it(num1, num2)

print(answer)

none

500

Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist?

'w'

500

A student will not be allowed to sit in exam if his/her attendence is less than 75%.
Take following input from user
Number of classes held
Number of classes attended.
And print
percentage of class attended
Is student is allowed to sit in exam or not.                            

print ("Number of classes held")

noh = int(input())

print ("Number of classes attended")

noa = int(input())

atten = (noa/float(noh))*100

print ("Attendence is",atten)

if atten >= 75:  print ("You are allowed to sit in exam")

else:  print ("Sorry, you are not allowed. Attend more classes from next time.")

M
e
n
u