Quiz
Assessment 1
Question 1
The extension for a file containing the code of a Python program is _____
a..python
b..pyt
c..pthon
d.*.py
Question 2
What is the output from this execution?
#this code will add two number
#input
number1=345
number2=123
number3=100
#processing
total=number1+number2+number3
#output
#print('The numbers that were added ', number1, number2, number3)
print('The total of the addition :', total)
a.syntax error
b.The total of the addition : 568
c.no output is generated.
d.The numbers that were added 345 123 100
The total of the addition : 568
Question 3
What will be the output from the following code?
#input
fDistance=float(input('Input the distance travelled (km) : '))
fHours=float(input('Input the hours travelled (hours) : '))
#processing
fSpeed=fDistance/fHours
#output
print('Your speed is (km/h) : %.2f ' %fSpeed)
a.Input the distance travelled (km) : 560
Input the hours travelled (hours) : 3
Your speed is (km/h) : 186.67
b.syntax error
c. Input the distance travelled (km) : 560
Input the hours travelled (hours) : 3
Your speed is (km/h) : 186
d. Input the distance travelled (km) : 560
Input the hours travelled (hours) : 3
Your speed is (km/h) : 187
Question 4
What is the output from the following code?
import math
#input
nRadius=int(input('Input the Radius of the wheel (cm) : '))
#processing
fCircumference=math.pi*nRadius*2.0
#output
print('Circumference : ', fCircumference)
a. Input the Radius of the wheel (cm) : 10
Circumference : 62.83185307179586
b. Input the Radius of the wheel (cm) : 10
Circumference : 62.83
c. Input the Radius of the wheel (cm) : 10
Circumference : 62
d. syntax error
Question 5
Python programs are saved in files with the ____ extension.
a..exe
b..py
c..python
d..ui
Question 6
IDLE is the abbreviation for __________
a.Integrated Development Environment
b.Incredible Development Environment
c.Integrated Distribution Environment
d.Integrated Development Experience
Question 7
In Python, a physical line comment starts with the ___ character.
a.{ }
b.#
c.*****
d.@@@
Question 8
The data operation used in this program is _____
#this is the processing
thetotal=a//b
theremain=a%b
a. remainder division
b. normal division
c. integer division
d. quotient division
Question 9
What formatting is used for the user input?
#This is comment
#this is input
nNumber1=int(input('Please enter the number of learners in the school : '))
nNumber2=int(input('Please enter the number of educators in the school :
'))
#this is the processingn
Total= nNumber1+nNumber2
#this is the output
print('The total number of people at school is : ', nTotal)
a.input
b.int
c.#
d.no formatting used
Question 10
What is the output from the code executed?
#add 2 numbers and show the result
#input
myMoney=1200.50
yourMoney=23000.78
#processing
thetotal=myMoney+yourMoney
#output
print('The value money is :', thetotal)
a.The value money is : 24201.28
b.The value money is : 24200
c.24201.28
d.The value money is : 24201
Question 11
For the provided input, what is the output?
#This is the input
a=int(input('Please enter the number of masks issued to the school : '))
b=int(input('Please enter the number of learners in the school: '))
#this is the processing
thetotal=a//b
theremain=a%b
#this is the output
print('Each learner receives : ', thetotal)
print('The remainder is:', theremain)
a.Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Each learner receives : 0
The remainder is: 300
b.Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Each learner receives : 30
The remainder is: 3
c.Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Each learner receives : 3
The remainder is: 0
d.Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Each learner receives : 300
The remainder is: 0
Question 12
What is the output from the following code execution?
#input
nMark1=int(input('Please input the mark for your first assignment : '))
nMark2=int(input('Please input the mark for your second assignment : '))
nMark3=int(input('Please input the mark for your third assignment : '))
nMark4=int(input('Please input the mark for your fourth assignment : '))
#processing
nTotal=nMark1+nMark2+nMark3+nMark4
nAverage=nTotal/4.0
#output
print('Your total is : ',nTotal)
print('Your average is : ', nAverage)
a.
Please input the mark for your first assignment : 67
Please input the mark for your second assignment : 76
Please input the mark for your third assignment : 80
Please input the mark for your fourth assignment : 90
Your total is : 313
Your average is : 78.25
b.
Please input the mark for your first assignment : 67
Please input the mark for your second assignment : 76
Please input the mark for your third assignment : 80
Please input the mark for your fourth assignment : 90
Your total is : 313
Your average is : 78
c.
Please input the mark for your first assignment : 67
Please input the mark for your second assignment : 76
Please input the mark for your third assignment : 80
Please input the mark for your fourth assignment : 90
Your total is : 313
Your average is : 79
d.
Please input the mark for your first assignment : 67
Please input the mark for your second assignment : 76
Please input the mark for your third assignment : 80
Please input the mark for your fourth assignment : 90
Your total is : 313.00
Your average is : 78.25
Question 13
If the data type of a value in a variables does not match the format code, then ____ will occur.
a. an exception
b. an event handler
c.
an auto conversion
d. an error message
Question 14
What is the output from this code?
#this code will add two number
#input
number1=345
number2=123
number3=100
#processing
total=number1+number2+number3
#output
#print('The numbers that were added ', Number1, Number2, Number3)
print('The total of the addition :', Total)
a. no output is generated.
b. NameError: name 'Total' is not defined
c.NameError: name 'Number1' is not defined
d.The total of the addition : 568
Question 15
For the given input, the output will be ____
#How many books does each learner receive?
#This is the input
a=int(input('Please enter the number of books issued to the school : '))
b=int(input('Please enter the number of learners in the school: '))
#this is the processing
thetotal=a//b
theremain=a%b
#this is the output
print('The value is:', thetotal)
print('The remainder is:', theremain)
a.Please enter the number of books issued to the school : 400
Please enter the number of learners in the school: 55
The value is: 17
The remainder is: 5
b. Please enter the number of books issued to the school : 400
Please enter the number of learners in the school: 55
The value is: 7
The remainder is: 15
c. Please enter the number of books issued to the school : 400
Please enter the number of learners in the school: 55
The value is: 7
The remainder is: 0
d. Please enter the number of books issued to the school : 400
Please enter the number of learners in the school: 55
The value is: 0
The remainder is: 15.8987654
Assessment 2
Question 1
In the following code, the data type for the variable drinkCoffee is ______
if myCoffee.upper() =='Y':
drinkCoffee = True
else:
drinkCoffee = False
a. integer
b. upper
c. boolean
d. float
Question 2
What is the output from the following execution?
myTeam=['Matthew', 'Mark', 'Luke', 'John']
myName = input('What is your name? ')
if myName.lower() in myTeam:
print('welcome ' + myName+ ' you are on the team')
else:
print('Sorry, ' + myName+ ' you are not on the team!')
a. What is your name? Luke
sorry, luke you are not on the team!
b. What is your name? Luke
Sorry, Luke you are not on the team!
c. What is your name? Luke
welcome, Luke you are on the team!
d. What is your name? Luke
welcome, luke you are on the team!
Question 3
What is the output from the execution?
nMyNumber = 37
nYourNumber = int(input('Input your integer number :'))
if nMyNumber ==nYourNumber
print('Correct well done!')
else:
print('Sorry try again!')
a. syntax error
b. No output is generated.
c. Input your integer number :54
Correct well done!
d. Input your integer number :54
Sorry try again!
Question 4
Logical operators can be used to _____
a. combine variables.
b. combine four logical expressions.
c. combine constants.
d. combine two or more logical expressions.
Question 5
What is the output from the following execution? The input age is 20.
nCost=0
nAge=int(input('Please enter your age : '))
if (nAge < 15):
nCost=0
elif (nAge < 21):
nCost=10
elif (nAge < 65):
nCost=35
else:
nCost=0
print('The cost is : ', nCost)
a. Please enter your age : 20
The cost is : 10
b. Please enter your age : 20
The cost is : 35
c. Please enter your age : 20
The cost is : 20
d. Please enter your age : 20
The cost is : 0
Question 6
If the logical expression of the IF … ELSE statement is evaluated to true then _____
a. the IF code block is executed.
b. no code blocks are executed.
c. all code blocks are executed.
d. the ELSE code block is executed.
Question 7
The ELSE part of the IF.. ELSE statement is ____
a. required.
b. mandatory.
c. compulsory.
d. optional.
Question 8
What is the output from the execution of this code?
#input
theWeather='Rain'
#process
if (theWeather == 'rain'):
#output
print('Please use an umbrella')
a. Please use an umbrella!!!!!
b. Please use an umbrella
c. no output is generated.
d. syntax error
Question 9
What is the output from the following code execution?
#Guess a number
nMyNumber = 37
nYourNumber = int(input('Input your integer number :'))
if nMyNumber = nYourNumber:
print('Correct well done!')
else:
print('Sorry try again!'
a. Input your integer number :37
Sorry try again!
b. There is not output generated.
c. Input your integer number :37
Correct well done!
d. Syntax error
Question 10
What is the output from this program, given the input presented?
#input
nTemp=int(input('Please input your temperature reading : '))
#process
if (nTemp >= 37):
#output
print('Please go for a COVID TEST NOW!')
a. Please input your temperature reading : 38
#output Please go for a COVID TEST NOW!
b. Please input your temperature reading : 38
#output
c. Please input your temperature reading : 38
d. Please input your temperature reading : 38
Please go for a COVID TEST NOW!
Question 11
What is the output from the execution? The age is 65.
nCost=0
nAge=int(input('Please enter your age : '))
if (nAge < 15):
nCost=0
elif (nAge < 21):
nCost=10
elif (nAge < 65):
nCost=35
else:
nCost=0
print('The cost is : ', nCost)
a. Please enter your age : 65
The cost is : 35
b. Please enter your age : 65
The cost is : 10
c. Please enter your age : 65
The cost is : 20
d. Please enter your age : 65
The cost is : 0
Question 12
For the user input, what would be the output of the program?
#input
nTemp=int(input('Please input your temperature reading : '))
#process
if (nTemp >= 37):
#output
print('Please go for a COVID TEST NOW!')
else:
print('all OK, have a HAPPY day!')
a. Please input your temperature reading : 37
all OK, have a HAPPY day!
b. syntax error
c. Please input your temperature reading : 37
all OK, have a HAPPY day
d. Please input your temperature reading : 37
Please go for a COVID TEST NOW!
Question 13
What is the output from this code?
#input
nTemp=34
#process
if (nTemp >= 37.9):
#output
print('Please go for a COVID TEST NOW!')
a. Please go for a COVID TEST NOW # Output
b. No output.
c. Please go for a COVID TEST NOW!
d. syntax error
Question 14
The IF … ELSE statement determines which code block is executed depending on the value of a
_________.
a. iteration.
b. logical expression.
c. loop.
d. constant.
Question 15
The logical expression that is evaluated to true and preceded by the not logical operator results in a
____ value.
a. true
b. greater than
c. false
d. syntax error
Assessment 3
Question 1
What is the output from the following code?
for icount in range(10, 1, 2):
print(icount)
print('in loop')
#print('hello out loop \n')
a. 1012
b. there is not output
c. syntax error
d. 101113
Question 2
What is the output from the following execution?
istart=3
iend=10
for icount in range(istart,iend,5):
print(icount)
a. 3105
b. syntax error
c. 31318
d. 38
Question 3
What is the output from the execution of the following code?
for icount in range(1,10,3):
print(icount)
#print('in loop')
#print('hello out loop \n')
a. syntax error
b. 147
c. 1103
d. 11114
Question 4
The _____ statement can be used as a placeholder for code that you may want to write later, and
acts as a reminder of where the program can be expanded later.
a. extended
b. pass
c. break
d. continue
Question 5
What is the output from the following code?
for icount in range(2,4,6):
print(icount)
print('in loop')
#print('hello out loop \n')
a. 2in loop4in loop6in loop
b. 2in loop
c. 2612
d. 246
Question 6
If the logical expression of a WHILE structure is false, ________________
a. the body of the WHILE loop will not be executed.
b. the body of the WHILE loop will continue executing.
c. the body of the WHILE loop will be executed once.
d. a syntax error occurs.
Question 7
The ____ statement is used to indicate an empty block of statements.
a. halt
b. pass
c. break
d. continue
Question 8
Describe the function of the following code:
nstart=int(input('enter the start number : '))
nend=int(input('enter the end number : '))
for icount in range (nstart, nend, 1):
if (icount%2 ==0):
print(icount)
a. The code contains a syntax error.
b. The code is used to print all odd numbers between a start and end number.
c. The code is used to print all even numbers between a start and end number.
d. The code is used to print all numbers equal to 2 between the start and end number.
Question 9
When the number of iterations is known before the iterations start, a ____ looping structure is
recommended.
a. for
b. if
c. else
d. while
Question 10
The range (x, y) returns a list of items that are consecutive integers from _______.
a. x (included) to y (included)
b. x (excluded) to y (excluded)
c. x (excluded) to y (included)
d. x (included) to y (excluded).
Question 11
What is the output from the code execution?
for icount in (2,3,4,5):
print(icount)
a. 2345
b. 25914
c. no output generated
d. syntax error
Question 12
Describe the function of the following code:
nstart=int(input('enter the start number : '))
nend=int(input('enter the end number : '))
for icount in range (nstart, nend, 1):
if (icount%2 !=0):
print(icount)
a. The code prints all even numbers between the start and end number.
b. The code has a syntax error.
c. The code prints all numbers not equal to 0 between the start and end numbers.
d. The code prints all odd numbers between the start and end number.
Question 13
Describe the function of the following code:
nTotal=0
#student number has 8 digits!
for icount in range (1,9,1):
ndigit=int(input('enter the next digit in your student number : '))
nTotal = nTotal + ndigit
print('the total is : ', nTotal)
a. The code displays the digits in your student number.
b. The code adds the digits in your student number.
c. The code contains a syntax error.
d. The code concatenates the digits in your student number.
Question 14
What is the output from the execution of the following code?
for icount in range(1, 10, 3)
print(icount)
#print('in loop')
#print('hello out loop \n')
a. 1103
b. syntax error
c. 147
d. no output
Question 15
The _____ function returns a list of items that are consecutive integers from 0 (included) and x
(excluded).
a. range(x-2)
b. range (x)
c. range (x+1)
d. range (x-1)
Assessment 4
Question 1
What is the output after the following code is executed?
sString='this is my FIRST string'
print(sString.title())
a. This Is My FIRST String
b. This is my first string
c. This Is My First String
d. syntax error
Question 2
What is the output from the execution of the following code?
s='Today is Wednesday!'
#processing and output
print ('Original : ', s)
print('The length is : ', len(s))
a. Original : Today is Wednesday!
The length is : 19
b. Original : Today is Wednesday!
The length is : 17
c. syntax error
d. Original : Today is Wednesday!
The length is : 16
Question 3
An example of a string value is _____
a. 9
b. my
c. literal
d. "my wonderful world"
Question 4
What is the output after the execution of the following code?
sString='my name is john smith'
print(sString.title())
a. My Name Is John Smith
b. syntax error
c. My name is John Smith
d. My name is john smith
Question 5
An example of an immutable sequence in Python is __________
a. integer
b. float
c. list
d. string
Question 6
A _______ is mutable; you can append elements, remove existing elements, or rearrange elements.
a. string
b. keyword
c. tuple
d. list
Question 7
To initialize a one-dimensional array nAssign to hold 4 zero values, the following code is used:
________________________
a. nAssign=[0 for i in range(3)]
b. nAssign=[0 for i in range(5)]
c. nAssign==[0 for i in range(4)]
d. nAssign=[0 for i in range(4)]
Question 8
list1 is [2, 33, 222, 14, 25], What is list1[-1]?
a. 25
b. Out of bounds
c. 2
d. -1
Question 9
What is the output after the execution of the following code?
#input
sWord1="salt"
sWord2='pepper'
#processing
myTotal = sWord1+ ' and '+sWord2
#output
print('The output is : ', myTotal.upper())
a. syntax error
b. The output is : Salt And Pepper
c. The output is : SALT and PEPPER
d. The output is : SALT AND PEPPER
Question 10
What is the output from the execution of the following code?
nName=' Jessica Jones '
print(nName.lstrip())
a. Syntax Error
b. Jones
c. Jessica Jones
d. JessicaJones
Question 11
The code is required to produce the output:
Please input a first string : This is the Exam for INF1511 2022
What letter are we counting : e
The count is : 2
Which code can be used?
a. s=input('Please input a first string : ')
l=input('What letter are we counting : ')
t=s.count(l.lower(), 0, length) + s.count(l.upper(), 0, length)
print('The count is : %d' %(t))
b. s=input('Please input a first string : ')
l=input('What letter are we counting : ')
t=s.count(l.lower, 0, len(s)) + s.count(l.upper, 0, len(s))
print('The count is : %d' %(t))
c. s=input('Please input a first string : ')
l=input('What letter are we counting : ')
t=s.count(l, 0, len(s))
print('The count is : %d' %(t))
d. s=input('Please input a first string : ')
l=input('What letter are we counting : ')
t=s.count(l.lower(), 0, len(s)) + s.count(l.upper(), 0, len(s))
print('The count is : %d' %(t))
Question 12
What is the output generated by the execution of the following code?
s='Today is Wednesday!'
#processing and output
print ('Original : ', s)
print('After toggling the case:', s.swapcase())
a. Original : Today is Wednesday!After toggling the case: tODAY IS wEDNESDAY!
b. Original : Today is Wednesday!After toggling the case: Wednesday IS tODAY!
c. Original : Today is Wednesday!After toggling the case: TODAY is WEDNESDAY!
d. Syntax error
Question 13
What is the output from the execution of the following code?
sRainbow=['Red', 'Orange','Yellow', 'Green', 'Blue', 'Indigo', 'Violet']
print(sRainbow[0])
print(sRainbow[-1])
a. Red, Violet
b. Syntax error
c. RedViolet
d. Red Orange Yellow Green Blue Indigo Violet
Question 14
A ____________ is a collection of values on which operations can be performed
a. sequence
b. method
c. set
d. function
Question 15
Given that the output is: The combination is vCOVIDiCOVIDrCOVIDuCOVIDs
What are the values of the two variables?
#add the variables s and t here_______________
print('The combination is ',s.join(t))
a. syntax error
b. t='COVID'
s='virus'
c. s='COVID'
t='virus'
d. s='covid'
t='VIRUS'
Assessment 5
Quesstion 1
What code is generated when the following code is executed?
def myPet(pType,pName):
print('I have a %s named %s.' %(pType.lower(), pName.title()))
petType = str(input("What type of pet do you have? "))
petName = str(input("What is the name of your pet? "))
myPet(petType, petName)
a. What type of pet do you have? CAT
What is the name of your pet? FRED
I have a CAT named FRED.
b. What type of pet do you have? CAT
What is the name of your pet? FRED
I have a cat named Fred.
c. What type of pet do you have? CAT
What is the name of your pet? FRED
I have a Cat named Fred.
d. What type of pet do you have? CAT
What is the name of your pet? FRED
I Have A Cat Named Fred.
Question 2
Global variables can be used in functions. What is the final value of the global variable x after the
execution of the following code:
def myXFunction():
global x
print('The value of x in function is : ', x)
x=x*5
print('The value of x in function is : ', x)
return
x=100
myXFunction()
print('The value of x out of function is : ', x)
a. 500
b. 505
c. 5
d. 100
Question 3
The following code is executed. Which output is generated?
def square(nNum):
return (nNum*nNum)
#input
nStart=int(input('Enter a start number : '))
nEnd=int(input('Enter an end number: '))
#process
mySquare=map(square, range(nStart,nEnd))
#output
print(list(mySquare))
a. Enter a start number : 8
Enter an end number: 10
[81, 100]
b. Enter a start number : 8
Enter an end number: 10
[64, 81]
c. Enter a start number : 8
Enter an end number: 10
[64, 81, 100]
d. Enter a start number : 8
Enter an end number: 10
[64, 81, 100, 121]
Question 4
A function that is defined inside a class is called a ______________
a. module
b. pseudo-function
c. method
d. class
Question 5
What output is generated when the following code is executed?
def myPet(pType,pName):
print('I have a %s named %s.' %(pType.upper(), pName.upper()))
petType = str(input("What type of pet do you have? "))
petName = str(input("What is the name of your pet? "))
myPet(petType, petName)
a. syntax error
b. What type of pet do you have? dog
What is the name of your pet? jack
I have a DOG named JACK.
c. What type of pet do you have? dog
What is the name of your pet? jack
I have a dog named jack.
d. What type of pet do you have? dog
What is the name of your pet? jack
I have a dog named Jack.
Question 6
The functions that are defined within a class are known as _____
a. classes
b. selfies
c. methods
d. instances
Question 7
In this code, calendar is used as a ______
from calendar import *
year=int(input('In which year will you graduate? '))
prcal(year)
a. global
b. module
c. modify
d. generate
Question 8
What output is generated, given the following code?
def sum(one,two=22):
return (one+two)
#input
myNum=int(input("please enter a number:"))
nTotal=sum(myNum)
print(nTotal)
nTotal=sum(myNum, myNum)
print(nTotal)
a. please enter a number : 100
100
200
b. please enter a number : 100
122
322
c. please enter a number : 100
122
200
d. please enter a number : 100
122
222
Question 9
Recursion is supported by the _________ data structure
a. array
b. matrix
c. stack
d. linked list
Question 10
The following uses a method and a function. Which output is generated?
def myVal(x):
return (x%2 !=0)
#input
nStart=int(input('Enter a start number : '))
nEnd=int(input('Enter an end number: '))
#processing
myVals=filter(myVal, range(nStart,nEnd))
#output
print(list(myVals))
a. Enter a start number : 34
Enter an end number: 43
[35, 37, 39, 41]
b. Enter a start number : 34
Enter an end number: 43
[34, 35, 37, 39, 41]
c. Enter a start number : 34
Enter an end number: 43
[35, 36, 37, 38, 39, 40, 41]
d. Enter a start number : 34
Enter an end number: 43
[35, 37, 39, 41, 43]
Question 11
Where is the syntax error in this code?
def myMonth(xMonth):
months = ['Jan','Feb','March','April','May','June','July','Aug','Sep','Oct','Nov','Dec']
if 1 <= xMonth <= 12:
sPrint = 'The month is ' + months[xMonth-1]
sMonth = months[xMonth-1]
else:
sPrint = 'Value is out of the range'
return (sPrint)
nMonth = int(input("What is the current month? "))
print(myMonth(nMonth))
a. Line 3
b. Line 6
c. Line 1
d. No syntax error
Question 12
Which option is the definition of a function to calculate the average of 3 numbers?
a. it cannot be defined
b. def myAverage(a,b,c)
return (a+b+c/2.0)
c. def myAverage(a,b,c)
return (a+b+c/3.0)
d. def myAverage(a,b,c)
return ((a+b+c)/3.0)
Question 13
What output is generated at the execution of the following code?
def myXFunction():
#global x
print('The value of x in function is : ', x)
x=x*5
print('The value of x in function is : ', x)
return
x=100
myXFunction()
print('The value of x out of function is : ', x)
a. 5
b. 500
c. syntax error
d. 100
Question 14
Which of the following is a defined mathematical function in Python in the math module?
a. add
b. sqrt
c. divide
d. rhombus
Question 15
The function that returns the data type of a variable is _____
a. objType()
b. datatype()
c. type()
d. data()
Assessment 6
Question 1
What is the output from the execution of the following code?
class triangle:
#setting default values
def __init__(self, x=10, y=10):
self.__base=x
self.__height=y
def calc(self):
area=0.5*self.__base*self.__height
return (area)
#create an instance
myBase=int(input('Please enter the base length : '))
myHeight=int(input('Please enter the height : '))
myTri=triangle(myBase, myHeight)
#print(myTri.base)
#print(myTri.height)
myTri.calc()
a. Syntax error
b. Please enter the base length : 10
Please enter the height : 10
Out[2]:100.0
c. Please enter the base length : 10
Please enter the height : 10
Out[2]:50
d. Please enter the base length : 10
Please enter the height : 10
Out[2]:50.0
Question 2
The procedure of _____ allows different methods with the same name in different classes to perform
different tasks.
a. polymorphism
b. metamorphism
c. heteromorphism
d. monomorphism
Question 3
In the definition of the class Triangle, there are ____ data members.
#define the class object
class Triangle:
base=9
height=4
area=0.5*base*height
print(Triangle.base)
print(Triangle.height)
print(Triangle.area)
a. 3
b. 6
c. none
d. 2
Question 4
Provide a valid instantiation of the class:
class Triangle:
def __init__(self, x, y):
self.base=x
self.height=y
def calc(self):
area=0.5*self.base*self.height
return (area)
myBase=int(input('Please enter the base length : '))
myHeight=int(input('Please enter the height : '))
#create an instance_____________________
a. myTri=Triangle(self.myBase, self.myHeight)
b. myTri=Triangle(myBase, myHeight)
c. myTri=Triangle(x, y)
d. myTri=Triangle(Base, Height)
Question 5
A special method that is automatically invoked after the creation of a new instance of a class is _____
a. __init__
b. class
c. __str__
d. def
Question 6
In the class Triangle, there are ___ member functions.
#define the class object
class Triangle:
base=9
height=4
area=0.5*base*height
print(Triangle.base)
print(Triangle.height)
print(Triangle.area)
a. none
b. 6
c. 2
d. 3
Question 7
A Python class consists of the following:
a. objects and member functions
b. variables and data members
c. data members and member functions
d. instances and data members
Question 8
How many instances of the class have been created?
class Triangle:
#an attribute of the class
base=9
height=4
def calcArea(self):
area=0.5*Triangle.base*Triangle.height
return (area)
myTri=Triangle()
a. one
b. two
c. none
d. syntax error
Question 9
To call the class member function, which line of code is required?
class Triangle:
#an attribute of the class
base=9
height=4
def calcArea(self):
area=0.5*Triangle.base*Triangle.height
return (area)
myTri=Triangle()
#print(myTri.base)
#print(myTri.height)
_________________________
a. Triangle.calcArea()
b. calcArea()
c. myTri.calcArea()
d. myTri.calcArea
Question 10
A class that implements only the _get_ methods for an object is called a _______
a. getter class
b. non-data descriptor class
c. fetch class
d. method class
Question 11
There are ___ member functions defined in this class.
class Bird():
#this is the class body
def __init__(self, name, age):
self.name=name
self.age=age
def birdsit(self):
print(self.name + ' is a bird that is sitting')
def birdfly(self):
print(self.name + ' is a bird that is flying')
def birdage(self):
print(str(self.age) + ' is a bird age')
a. 0
b. 4
c. 2
d. 3
Question 12
What is the output from the execution of the following code?
class Bird():
#this is the class body
def __init__(self, name, age, breed):
self.name=name
self.age=age
self.breed=breed
def birdsit(self):
print(self.name + ' is a bird that is sitting')
def birdfly(self):
print(self.name + ' is a bird that is flying')
def birdage(self):
print(str(self.age) + ' is a bird age')
def birddata(self):
print(str(self.name) + ' is a '+str(self.breed))
#modify this to use user input.
myBird=Bird('Pink',4,'flamingo')
myBird.birddata()
a. Pink is a flamingo
b. Pink is a flamingo!
c. Pink is a Flamingo
d. syntax error
Question 13
The line of code required to initialise the data members for this code is ____
class Triangle:
def ______
self.base=9
self.height=4
def calcArea(self):
area=0.5*self.base*self.height
return (area)
a. __initialized__(self):
b. __init__(self):
c. __init__():
d. init(self):
Question 14
What is the output from the execution of the following code?
class triangle:
#setting default values
def __init__(self, x=10, y=10):
self.__base=x
self.__height=y
def calc(self):
area=0.5*self.base*self.height
return (area)
#create an instance
myBase=int(input('Please enter the base length : '))
myHeight=int(input('Please enter the height : '))
myTri=triangle(myBase, myHeight)
print(myTri.base)
print(myTri.height)
myTri.calc()
a. error message
b. Please enter the base length : 12
Please enter the height : 12
Out[3]:72.0
c. Please enter the base length : 12
Please enter the height : 12
12
12
Out[3]:72.0
d. Please enter the base length : 12
Please enter the height : 12
12
12
Out[3]:144.0
Question 15
Which of the following is NOT a built-in class attribute?
a. __init__
b. __initialise__
c. __doc__
d. __bases__
Assessment 7
Qusetion 1
The ________ statement is used to check that the values in variables are correct, e.g. a numerical
value is entered and not a string.
a. class
b. init
c. assert
d. def
Question 2
How many except statements can a try-except block have?
a. at least one
b. only one
c. zero
d. more than one
Question 3
What comment is required to describe the function of this code?
#THE PURPOSE OF THIS CODE IS: ______________________
myFile='testfile.txt'
f = open(myFile, 'r')
lines = f.read()
f.close()
newFile='anotherfile.txt'
g = open(newFile, 'w' )
g.write(lines)
g.close()
#comment?
print('The file '+ newFile + ' contains : ')
g = open(newFile, 'r' )
lines = g.read()
print (lines)
g.close()
a. divide the content of one file into two files
b. compare two files
c. delete the content of a file
d. copy the content of one file to another file
Question 4
In the text given, what is name?
myFile='testfile.txt'
f = open(myFile, 'r')
print ('The name of the file is : ', f.name)
a. name is an attribute of the file
b. name is an attribute of the text class
c. name is the mode of r
d. name is the description of the file mode
Question 5
The try/except structure is used in this code as a measure of ______
myFile=input('Enter the name of the file : ')
import sys
try:
f = open(myFile, 'r')
lines = f.read()
except IOError:
print ('The file ' + myFile + ' does not exist')
sys.exit(1)
f.close()
print('The content of the file ' + myFile + ' is :')
print (lines)
a. input output count
b. file handling
c. error handling
d. file reading
Question 6
Given that the file xxxx.txt does not exist, what will the output be?
import sys
myFile=input('What is the name of the file : ')
try:
f = open(myFile, 'r')
#read the entire file
lines = f.read()
except IOError:
print ('The file does not exist ', myFile)
sys.exit(1)
f.close()
print (lines)
a. syntax error
b. The file does not exist xxxx.txt
c. The file does not exist myFile
d. The file does not exist
Question 7
What is the output from the execution of the following code?
myFile='testfile.txt'
f = open(myFile, 'r')
#print ('Is the file '+ myFile + ' closed? ', f.closed)
#print ('The name of the file is : ', f.name)
#print ('What is the opening mode of file ' + myFile + ' : ', f.mode)
#print ('The file number descriptor is : ', f.fileno())
f.close()
print ('Is the file '+ myFile + ' closed? ', f.closed)
a. Is the file testfile.txt closed? YES
b. syntax error
c. Is the file testfile.txt closed? True
d. Is the file testfile.txt closed? FALSE
Question 8
Which type of try block is used to handle exceptions?
a. try/finalised
b. try/end
c. try/except
d. try/retry
Question 9
There are three types of files in Python, namely: ______________ files.
a. text, binary and pickled
b. encrypted, binary and pickled
c. text, binary and compressed
d. encrypted, binary and compressed
Question 10
Given the following file opening statement, in which mode is the file opened?
f = open(myFile, 'a' )
a. a read
b. alert
c. append
d. adjust
Question 11
What is the output from the execution of the following code?
myFile='testfile.txt'
f = open(myFile, 'r')
print ('What is the opening mode of file ' + myFile + ' : ', f.mode)
a. What is the opening mode of file testfile.txt : reading
b. What is the opening mode of file testfile.txt : read
c. What is the opening mode of file testfile.txt : r
d. What is the opening mode of file testfile.txt : ready
Question 12
This code can be used to _____
f = open(myFile)
while True:
line = f.readline()
if len(line) == 0:
break
print (line,)
f.close()
a. write text to a file
b. read text from a file
c. copy text to a file
d. append text to a file
Question 13
What code is required after the for statement?
nLines=int(input('How many lines do you want to enter? '))
myLine= ''
#open the file
myFile='testfile.txt'
f = open(myFile, 'w')
#write or read
for __________________
myLine=input('\n Enter a line : ')
f.write("\n%s" %myLine)
print('\n Writing line ',nLine)
#close the file
f.close()
a. nLine in range(0, nLines):
b. nLine in range(0, nLines-1):
c. nLine in range(1, nLines):
d. nLine in range(0, nLines)
Question 14
When an undesired situation is encountered during program execution ____ occurs.
a. a try
b. a file open
c. a file close
d. an exception
Question 15
What is the function of the following code?
#comment
nCount=int(input('How may lines? '))
#comment
myFile='testfile.txt'
f = open(myFile, 'a' )
for i in range(0, nCount):
myLine=input('Enter the line : ')
f.write("\n%s" %myLine)
f.close()
a. to modify lines in a file
b. to delete lines in a file
c. to append lines to a file
d. to select lines in a file
Assessment 8
Question 1
The application includes radiobuttons. The code to determine whether the towel radiobutton has been
selected is ___
a. if self.ui.towel.isChecked()==True:
b. if self.ui.towel ==isChecked():
c. if self.ui.towel.isChecked()=Selected:
d. if self.ui.towel.isChecked()=True:
Question 2
The purpose of the following code is to
______.s=self.ui.edtLine.text()self.ui.edtLine.setText(s.upper())
a. to identify the capital letters in a string
b. to replace the string in a text edit with the same string all in capital letters.
c. to count the number of capital letters in a string
d. convert the string to all capital letters.
Question 3
To ensure that the focus returns to the text edit edtLine, the following code is recommended.
a. self.ui.edtLine.setFocus
b. self.ui.edtLine.Focus()
c. self.ui.edtLine.setFocus()
d. self.ui.edtLine.getFocus()
Question 4
To add the text from an edit line to a list widget, the following code is recommended:
_________________________
a. self.ui.lstList.addItem(self.ui.edtLine.text())
b. self.ui.lstList.addAnItem(self.ui.edtLine.text())
c. lf.ui.lstList.addItem(self.ui.Text())
d. self.ui.lstList.add(self.ui.edtLine.text())
Question 5
Which of the following widgets is NOT an example of a Model Bases Item View?
a. Column View (QColumnView)
b. List Widget (QListWidget)
c. Tree View (QTreeViewGeneral User Interaction)
d. Table View (QTableView)
Question 6
The following code is recommended to sort the items in a List widget in alphabetical order:
______________________
a. self.ui.lstList.AllItemsSorted()
b. self.ui.lstList.sortItems()
c. self.ui.lstList.sortAlphabetical()
d. self.ui.lstList.AlphabeticalSort()
Question 7
A dialog application contains at least a _____
a. menu bar
b. button
c. status bar
d. toolbar
Question 8
To verify that the edit line is empty (i.e. no text has been entered into a edit line), the following code is
recommended: ____________________
a. if length(self.ui.edtLine.text())==0:
b. if numchars(self.ui.edtLine.text())==0:
c. if len(self.ui.edtLine.gettext())==0:
d. if len(self.ui.edtLine.text())==0:
Question 9
The abbreviation GUI stands for _____
a. Graphical User Interface
b. Graphical Usage Interaction
c. Graphical User Interchange
d. General User Interface
Question 10
The following code is recommended to identify the item currently selected in a list widget: _____
a. self.ui.lstList.theRow()
b. self.ui.lstList.currentrow()
c. self.ui.lstList.currentRow()
d. self.ui.lstList.therowselected()
Question 11
The statement: self.setGeometry(250, 300, 200, 150) does the following:
a. A window 200 pixels wide and 150 pixels high will be positioned at x and y co-ordinates 250 and
300 respectively.
b. A window 250 pixels wide and 300 pixels high will be positioned at x and y co-ordinates 200 and
150 respectively.
c. A window 250 pixels wide and 300 pixels high will be positioned at x and y co-ordinates 150 and
200 respectively.
d. A window 300 pixels wide and 250 pixels high will be positioned at x and y co-ordinates 200 and
150 respectively.
Question 12
Which one of the following widgets is NOT an input widget in Qt Designer?
a. spin edit
b. label
c. combo box
d. text edit
Question 13
The following code is recommended to count the number of items displayed in a list widget:
____________________
a. self.ui.lstList.countitems()
b. self.ui.lstList.count()
c. self.ui.lstList.numbercount()
d. self.ui.lstList.numberitems()
Question 14
The code self.ui.lstList.takeItem(self.ui.lstList.currentRow()) returns the number ____ if no item on the
list is selected.
a. 0
b. an error message is shown.
c. 100
d. -1
Question 15
The purpose of the following code is to ______self.ui.lstList.addItem(self.ui.edtLine.text())
a. to copy the selected item in a list to a edit text
b. the code has no purpose as there is a syntax error
c. add the text in an edit text to a list widget
d. to compare the length of the strings in the text edit and the list widget
SELF-ASSESSMENT
Question 1
Which of the following is an invalid statement, and will generate a syntax error message?
a. a,b,c=100,200,300
b. a b c = 100 200 300
c. abc=1,000,000
d. a_b_c=1,200,300
Question 2
Python is an interpreted language, thus Python can be _____
a. not executed by the computer with compiling
b. executed by the computer without compiling
c. executed by the computer with compiling
d. not executed by the computer without compiling
Question 3
Which of the following is NOT TRUE of keywords in Python programming?
a. keywords in Python cannot be used as variable names.
b. keywords in Python are used to store keys.
c. keywords in Python include words such as finally and class.
d. keywords in Python are identifiers reserved for special use.
Question 4
Python uses several data types. Which one of the following a NOT a fundamental data type?
a. float
b. tuple
c. integer
d. array
Question 5
Which variable stores a Boolean value?
a. aVar=False
b. aVar=1245
c. aVar=('red','yello','blue')
d. aVar=12.45
Question 6
To ensure that Python can be executed from any folder on a computer, the path variable in the
______ must be updated with the path of the Python installation.
a. environmental variables
b. environmental keywords
c. environmental comments
d. environmental literals
Question 7
Python has _____ keywords.
a. 10
b. 20
c. 40
d. 30
Question 8
A literal value in a Python program _______________.
a. never requires quotes.
b. is used to store values.
c. can only be used once in the code.
d. occurs directly in a program.
Question 9
The following is a literal that can be found in a Python program:
a. an if statement
b. a loop statement
c. a variable name
d. a number
Question 10
The following is NOT a literal:
a. ‘Two Point Zero’
b. TwoPointZero
c. 2.0
d. “2.0”
Question 11
To ensure that Python can be executed from any folder on a computer, the ____ variable (an
environmental variable) must be updated with the path of the Python installation.
a. destination
b. folder
c. path
d. source
Question 12
In programming, the ______ are used for the storage of data in a program.
a. variables
b. integers
c. keywords
d. comments
Question 13
A Python comment starts with a ___________ symbol.
a. @
b. &amp;
c. #
d. *
Question 14
Which of the following is an invalid variable?
a. 1st_string
b. foooolish
c. my_string_1
d. _passonthis
Question 15
The format code that is used in Python to display ASCII code is ______
a. %a
b. %s
c. %i
d. %c
Question 16
The print() function prints a new line. Which one of the following print() commands includes
characters that will supress the printing of a new line?
a. print (‘Good luck’, end == ‘ ’ )
b. print (‘Good luck’, end = ‘ ’ )
c. print (‘Good luck’, nl/// )
d. print (‘Good luck’, end )
Question 17
Which of the following CANNOT be used as a variable in Python?
a. in
b. on
c. __init__
d. it
Question 18
The following is NOT a keyword in Python.
a. export
b. except
c. import
d. global
Question 19
Which of the following options is a valid Python comment?
a. @ this code should be used if required
b. # this code should be used if required
c. * this code should be used if required
d. &amp; this code should be used if required
Question 20
Is Python code case sensitive when dealing with identifiers?
a. yes, always
b. no, not ever
c. sometimes, it is machine dependent
d. sometimes, it is compiler dependent
Question 21
The following is a keyword in Python programming: ____
a. only
b. within
c. class
d. without
Question 22
Which of the following is NOT a data type used in Python programming?
a. string
b. float
c. literal
d. integer
Question 23
What is the maximum possible length of an identifier used in Python programming?
a. machine dependent
b. unlimited
c. 63 characters
d. 31 characters
Question 24
The data types does NOT determine: ____
a. The possible values for values of that data type.
b. The meaning of the values of the data type.
c. The possible sizes for values of that data type.
d. The operations that can be performed with such data type values.
Question 25
The logical expression connected with the or logical operator returns ____ if any of the logical
expressions evaluates to true.
a. equal to
b. syntax error
c. true
d. false
Question 26
Comparison operators can be used within the logical expression of the IF … ELSE statement. The !=
operator reads as ____
a. mostly equal
b. definitely equal to
c. not equal to
d. similar
Question 27
Which of the following operators is NOT a comparison operator?
a. ==
b. =
c. !=
d. &lt;
Question 28
The logical expressions connected with an and logical operator returns _____ if all logical expressions
evaluate to true.
a. true
b. not equal to
c. false
d. a syntax error
Question 29
The logical expression that is evaluated to true and preceded by the not logical operator results in a
____ value.
a. greater than
b. true
c. syntax error
d. false
Question 30
Comparison operators can be used within the logical expression of the IF … ELSE statement. The ==
operator reads as ____
a. not equal to
b. equal to
c. similar
d. not greater than
Question 31
If the logical expression of the IF … ELSE statement is evaluated to true then _____
a. the IF code block is executed.
b. the ELSE code block is executed.
c. all code blocks are executed.
d. no code blocks are executed.
Question 32
If multiple logical expressions need to be evaluated, then a ____ statement is recommended.
a. IF … IF … ELSE
b. IF … ELSEIF … ELSE
c. IF … ELIF … ELSE
d. IF … ELSE … IFEL
Question 33
The IF … ELSE statement determines which code block is executed depending on the value of a
_________.
a. iteration.
b. loop.
c. logical expression.
d. constant.
Question 34
Comparison operators can be used within the logical expression of the IF … ELSE statement. The <
operator reads as ____
a. greater than
b. less than or equal to
c. less than
d. greater than or equal to
Question 35
If the logical expression of a WHILE structure is false, ________________
a. the body of the WHILE loop will not be executed.
b. the body of the WHILE loop will be executed once.
c. a syntax error occurs.
d. the body of the WHILE loop will continue executing.
Question 36
The _____ function returns a list of items that are consecutive integers from 0 (included) and x
(excluded).
a. range (x)
b. range (x+1)
c. range(x-2)
d. range (x-1)
Question 37
To indent code, _______ can be used to indent code.
a. hashtags
b. only spaces
c. commas
d. tabs or spaces
Question 38
The ____ statement is used to indicate an empty block of statements.
a. halt
b. continue
c. break
d. pass
Question 39
Loops are used to execute a collection of code statements only while the logical expression is ______
a. true
b. pending
c. looping
d. false
Question 40
When the number of iterations is not known or when the control structure is not a count (e.g. a
BOOLEAN) value, then the use of a __________ structure is recommended.
a. TRY … EXCEPT
b. IF … ELSE
c. FOR
d. WHILE
Question 41
One way to terminate a loop is to ensure that _________________.
a. logical expression evaluates to false.
b. logical expression is incremented.
c. logical expression evaluates to true.
d. logical expression is initiated.
Question 42
Python uses ____ to express the block structure of a Python code.
a. looping
b. decisions
c. pickling
d. indentation
Question 43
The ______ statement stops execution of the current iteration by skipping the rest of the loop and
continuing to execute the loop with the next iterative value.
a. go
b. halt
c. continue
d. break
Question 44
A FOR structure is used to program a programming _____
a. decision
b. sequence
c. repetition
d. inheritance
Question 45
The choice() function is used to ____. It may be used with lists, tuples and strings.
a. pick and return the maximum item
b. pick and return the optimal string value
c. pick and return a random item from a sequence
d. pick and return the median value from a sequence
Question 46
list1 is [2, 33, 222, 14, 25], What is list1[-1]?
a. -1
b. 25
c. 2
d. Out of bounds
Question 47
A ____________ is a collection of values on which operations can be performed
a. function
b. sequence
c. method
d. set
Question 48
A _______ is mutable; you can append elements, remove existing elements, or rearrange elements.
a. tuple
b. string
c. list
d. keyword
Question 49
A ____________ is a part of the code that is called by name, e.g. min (), max () and len (), which
does some computation on the attributes of an object and returns a value.
a. method
b. set
c. function
d. sequence
Question 50
An example of an immutable sequence in Python is __________
a. list
b. integer
c. float
d. string
Question 51
An example of a string value is _____
a. my
b. 9
c. literal
d. "my wonderful world"
Question 52
A string ‘ready’ is entered into a program. To generate the output string ’adery’, the string function
____ is used
a. is_random()
b. swapcase()
c. sorted()
d. lstrip()
Question 53
Suppose t = (1, 2, 4, 3), which of the following will produce a syntax error?
a. t[3]=45
b. print(len(t))
c. print(t[3])
d. print(max(t))
Question 54
A ______________ is a section of the code called by name that returns the object (or part of it) to
which it is associated, e.g. str (), sorted () and capitalise ().
a. sequence
b. set
c. method
d. function
Question 55
A ______________ is a section of the code called by name that returns the object (or part of it) to
which it is associated, e.g. str (), sorted () and capitalise ().
a. set
b. sequence
c. function
d. method
Question 56
A _____ is a function that creates an iterator.
a. generator
b. module
c. argument
d. yield
Question 57
The function that returns the data type of a variable is _____
a. data()
b. objType()
c. type()
d. datatype()
Question 58
Which of the following is a defined mathematical function in Python in the math module?
a. add
b. divide
c. rhombus
d. sqrt
Question 59
A function is a group of statements that can be invoked ______ .
a. any number of times
b. never
c. only twice
d. only once
Question 60
The functions that are defined within a class are known as _____
a. selfies
b. classes
c. methods
d. instances
Question 61
The variables in the function that receive the arguments are called _____.
a. globals
b. modules
c. parameters
d. returns
Question 62
The _______ statement passes the result from a function to the caller of the function.
a. else
b. def
c. return
d. if
Question 63
Recursion is supported by the _________ data structure
a. linked list
b. matrix
c. array
d. stack
Question 64
When calling a function, the data sent to the function is called ____________.
a. arguments
b. variables
c. definitions
d. modules
Question 65
A Python class consists of the following:
a. instances and data members
b. data members and member functions
c. variables and data members
d. objects and member functions
Question 66
Which function overloads the + operator?
a. __total__()
b. __sum__()
c. __plus__()
d. __add__()
Question 3
The Python programming language provides an option for re-useable code in the form of ____
a. orientations
b. classes
c. objects
d. instances
Question 67
The procedure of _____ allows different methods with the same name in different classes to perform
different tasks.
a. metamorphism
b. polymorphism
c. heteromorphism
d. monomorphism
Question 68
A class that implements the _set_ method for an object is called a _______
a. data descriptor class
b. method class
c. assign class
d. setter class
Question 69
Correct
Which of the following is NOT a built-in class attribute?
a. __doc__
b. __bases__
c. __initialise__
d. __init__
Question 70
The ___ block is used to ensure that the code in the block will always execute, irrespective of whether
an exception occurs or not.
a. try/finally
b. try/if/test
c. try/except
d. try/test
Question 71
A special method that is automatically invoked after the creation of a new instance of a class is _____
a. def
b. class
c. __init__
d. __str__
Question 72
Which of the following options is not a type of inheritance used in Python programming?
a. multi-level
b. single
c. multiple
d. hierarchical
Question 73
The________ method produces the string representation of a class instance.
a. __init__
b. __doc__
c. __str__
d. __txt__
Question 74
How many except statements can a try-except block have?
a. more than one
b. only one
c. zero
d. at least one
Question 75
There are three types of files in Python, namely: ______________ files.
a. text, binary and pickled
b. encrypted, binary and compressed
c. encrypted, binary and pickled
d. text, binary and compressed
Question 76
Which file access mode option opens a file for reading, and appends contents to the end of the file?
a. r+
b. a
c. a+
d. A
Question 77
There are three required steps when working with files. Which of the following options is NOT one of
these three required steps?
a. Deleting the file.
b. Performing an action of the content of the file.
c. Closing the file.
d. Opening a file.
Question 78
Which type of try block is used to handle exceptions?
a. try/finalised
b. try/except
c. try/end
d. try/retry
Question 79
To open a file c:\scores.txt for reading, we use ______
a. f = open (“c:\scores.txt”, “r”)
b. f = open (file = “c:\\scores.txt”, “r”)
c. f = open (“c:\\scores.txt”, “r”)
d. f = open (file = “c:\scores.txt”, “r”)
Question 80
The technique of storing relevant data and then retrieving the data from storage is known as _____
a. containing
b. processing
c. sequencing
d. file handling
Question 81
The use of ____is a procedure for freeing up the memory that is used by the variables or instances
that are no longer required.
a. waste recycling
b. memory leak collection
c. link deletion
d. garbage collection
Question 82
The ________ statement is used to check that the values in variables are correct, e.g. a numerical
value is entered and not a string.
a. def
b. class
c. assert
d. init
Question 83
When an undesired situation is encountered during program execution ____ occurs.
a. a file close
b. an exception
c. a file open
d. a try
Question 84
Scrollbars are user to _____.
a. zoom in on an image.
b. display buttons.
c. represent an integer value.
d. view documents that are larger than the view area.
Question 85
A window is defined as a ________
a. widget that has no parent widget.
b. widget that has no properties and values.
c. widget that has no tool bar.
d. widget that has multiple properties but no values.
Question 86
The widgets in the item views category are _____
a. not visible when the program is executing.
b. used to display many data values.
c. used to initiate an action.
d. used to arrange other widgets.
Question 87
Which one of the following statements is NOT correct?
a. PyQt is not dependent on the Qt libraries to run.
b. PyQt supports Unix, Mac OS, Linux and Windows.
c. PyQT API is a large collection of classes and methods.
d. PyQt is a GUI widgets toolkit.
Question 88
The ___ widget is used to display text or images.
a. line edit
b. push button
c. list
d. label
Question 89
Which one of the following statements is TRUE about RadioButtons?
a. Multiple buttons can be selected at the same time.
b. Only one RadioButton can be selected from a group at a time.
c. The class QRadioButton has a method isSelected()
d. Pressing the CTRL key and clicking on another button will allow the selection of both buttons.
Question 90
Which one of the following widgets is NOT a buttons widget in Qt Designer?
a. tool button
b. tool box
c. check box
d. dialog button box
Question 91
To display text which cannot be changed use a ______ widget.
a. text
b. pixmap
c. phonon
d. label
Question 92
Which of the following widgets is NOT an example of a Model Bases Item View?
a. Table View (QTableView)
b. Column View (QColumnView)
c. List Widget (QListWidget)
d. Tree View (QTreeViewGeneral User Interaction)
Question 93
PyQt is used to ______
a. develop command line code in Python.
b. write loop statements in Python.
c. develop graphical user interfaces for Python programs.
d. write if statements in Python.
Question 94
The ____ widget is used to enter a single line of data.
a. list
b. push button
c. label
d. line edit
Question 95
Which one of the following methods is NOT provided by the QCheckBox Class?
a. setChecked()
b. setState()
c. setText()
d. setIcon()
Question 96
To display an image that is too large to fit on the screen, use a ________ widget.
a. webview
b. scrollbar
c. pixmap
d. label
Question 97
Which one of the following widgets is NOT a display widget in Qt Designer?
a. Calendar Widget
b. Text Browser
c. Double Spin Edit
d. Label
Question 98
The object inspector will provide a list of all objects on the created form. The list of objects are
presented in _____ format.
a. pickled
b. sequential
c. linear
d.hierarchical
Question 99
Container widgets are used to _______
a. arrange widgets.
b. group widgets.
c. hide things when the application runs.
d. display a list of widgets.
Question 100
You need to display a list of options to a user, from which the user should be able to select more than
one option. You will use widgets from the ______________ class.
a. QCheckBox
b. QListWidgetItem
c. QRadioButton
d. QInputDialog
Question 101
A dialogue application must contain at least one ______
a. menu
b. button
c. toolbar
d. status bar
Question 102
Which one of the following widgets is NOT an input widget in Qt Designer?
a. label
b. text edit
c. combo box
d. spin edit
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )