Font size
WorksheetsPython Full
Total questions: 55
Worksheet time: 34mins
Consider the file "d://test.txt" with the contents as given below:
Hi there,
I am loving Python.
Python is Simple
Choose the correct output from the above code snippet from the given options:
Read String is : Hi there,
Read String is : Python is simple.
Syntax error
Read String is : Hi there,
I am loving Python.
Python is simple.
Consider the file "d://test.txt" with the contents as given below:
Hi there,
I am loving Python.
Python is Simple
Choose the correct output from the above code snippet from the given options:
Read String is : Hi there
Read String is : Hi there,
Syntax error
Hi there,
I am loving Python.
Python is simple.
Consider a file test.txt in D Drive with the following contents:
I Love Python
Choose the output for the following Python code from the given options(Select all applicable):
Stmt2 prints the contents of the file test.txt
Stmt5 will print number of tokens(words) in the file separated by a space ' '
Stmt6 should be uncommented to close the open file.
Stmt3 results in an error
Consider a file read.txt in D Drive with the following contents:
Banana
Apple
Grapes
Choose the output for the following Python code from the given options:
{}
{0: 'Banana', 1: 'Apple', 2: 'Grapes'}
[0: 'Banana', 1: 'Apple', 2: 'Grapes']
{'Banana':0, 'Apple':1, 'Grapes':2}
Consider a file read.txt in D Drive with the following contents:
Banana
Apple
Grapes
Choose the output for the following Python code from the given options:
[]
['Banana', 'Apple', 'Grapes']
{'Banana', 'Apple', 'Grapes'}
Error
Consider a list, fruits=["Mango", "Banana", "Guava", "Strawberry"]. Match the following:
a. fruits[-4:]
b. fruits[-2:]
c. fruits[-4:-1]
d. fruits[1:4]
Select the correct answer for a, b, c & d
['Banana', 'Guava', 'Strawberry']
['Mango', 'Banana', 'Guava', 'Strawberry']
['Mango', 'Banana']
['Mango', 'Banana', 'Guava']
['Guava', 'Banana', 'Mango']
Assume the following list definition:
a = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge']
print(a[4::-2])
a[:] is a
max(a[2:4] + ['grault'])
print(a[-5:-3])
List a is defined as follows:
a = ['a', 'b', 'c']
Which of the following statements adds 'd' and 'e' to the end of a, so that it then equals ['a', 'b', 'c', 'd', 'e']:
a += 'de'
a += ['d', 'e']
a.append(['d', 'e'])
a[len(a):] = ['d', 'e']
a.extend(['d', 'e'])
What gets printed?
names = ['Amir', 'Barry', 'Chales', 'Dao']
print(names[-1][-1])
A
r
Amir
Dao
o
What gets printed from the above piece of code?
11
12
21
22
33
names1 = ['Amir', 'Barry', 'Chales', 'Dao']
loc = names1.index("Edward")
print(loc)
-1
0
4
Edward
An exception is thrown
Which of the following are true of Python lists?
These represent the same list:['a', 'b', 'c'] ['c', 'a', 'b']
A given object may appear in a list more than once
All elements in a list must be of the same type
A list may contain any type of object except another list
There is no conceptual limit to the size of a list
You have a list a defined as follows:
a = [1, 2, 7, 8]
Write a Python statement using slice assignment that will fill in the missing values so that a equals [1, 2, 3, 4, 5, 6, 7, 8].
(a)
Same nested list as the previous question:
x = [10, [3.141, 20, [30, 'baz', 2.718]], 'foo']
What expression returns the list ['baz', 2.718]?
(a)
List a is defined as follows:
a = [1, 2, 3, 4, 5]
Select all of the following statements that remove the middle element 3 from a so that it equals [1, 2, 4, 5]:
a[2:2] = []
del a[2]
a[2] = []
a[2:3] = []
a.remove(3)
Who is the father of Computer?
Allen Turing
Charles Babbage
Simur Cray
Augusta Adaming
Which of the following is also known as brain of computer?
Control unit
Central Processing unit
Arithmetic and language unit
Monitor
ASCII stands for
American Stable Code for International Interchange
American Standard Case for Institutional Interchange
American Standard Code for Information Interchange
American Standard Code for Interchange Information
Microprocessors as switching devices are for which generation computers
First Generation
Second Generation
Third Generation
Fourth Generation
Which of the following is a part of the Central Processing Unit?
Printer
Key board
Mouse
Arithmetic & Logic unit
Which device is required for the Internet connection?
Repeater
Modem
CD Drive
NIC Card
Which of the following is incorrect variable name in Python?
variable_1
variable1
1variable
_variable
Which functions are used to accept input from the user.
input()
raw_input()
rawinput()
string()
What is the data type of print(type(10))
float
integer
int
String
What is the output of the following code
x = 6 y = 2
print(x ** y) print(x // y)
66 0
36 0
66 3
36 3
Which of the following statement is False?
They can contain both letters and numbers.
Variable names can be arbitrarily long.
Variable name can begin with underscore.
Variable name can begin with number.
Which of the following is not used as loop in Python?
for loop
while loop
do-while loop
None of the above
What is NIC used for?
To remotely access PC
To connect computer to a network
It is used in junipers routers for gateway card
None
. In a type of computer network, what does MAN stands for?
Metropolis area network
Mini area network
Metropolitan area network
Micro area network
Which of the following is the type of the computer network?
Metropolitan area network (MAN)
Local area network (LAN)
Wide area network (WAN)
All of the above
The _______ provides pictorial representation of given problem.
Algorithm
Flowchart
Pseudocode
All of these
_______ is a procedure or step by step process for solving a problem.
Algorithm
Flowchart
Pseudocode
All of these
The ______ symbol is used at the beginning of a flow chart.
Circle
Rectangle
Diamond
None of these
What will be the output of above Python code?
str1="6/4"
print("str1")
1
6/4
1.5
str1
What will following Python code return?
str1="Stack of books"
print(len(str1))
13
14
15
16
Which one of the following is correct way of declaring and initializing a variable, x with value 5?
int x
Int x=5
int x=5
x=5
declare x=5
All keyword in python are in
Lowercase
Uppercase
Both uppercase & Lowercase
None of the above
How many keywords are there in python 3.7?
32
33
30
31
In Python3, which functions are used to accept input from the user
input()
raw_input()
rawinput()
string()
Who developed the Python language?
Zim Den
Guido van Rossum
Niene Stom
Wick van Rossum
Config() in Python Tkinter are used to ____________
destroy the widget
place the widget
configure the widget
change property of the widget
___________ method is used to draw a line in canvas tkinter
canvas.create_line()
line()
create_line(canvas)
create line()
Creating line belongs to _________ category.
GUI
CGI
Canvas
scripting
Essential thing to create a window screen using tkinter python is _________
create a button
To define a geometry
create a file
call tk() function
The purpose of bg in Tkinter widget is to ____________
To change the background of widget
To change the direction of widget
To change the size of widget
To change the color of widget
The keyword used to import the Tkinter in program is ________
call
from
import
use
GUI stand for ___________
Graph user interaction
Global user interaction
Graphical user interface
Graphical user interaction
How does the grid() function put the widget on the screen ?
According to x,y coordinate
According to left,right,up,down
According to horizontal,vertical
According to row and column wise
The method(s) to import a tkinter in python program is/are ____________.
import tkinter
import tkinter as t
from tkinter import *
All the above
The method to install tkinter in system is _________
pip install python
tkinter install
tkinter pip install
pip install tkinter
It is possible to draw a circle directly in Tkinter canvas ?
Yes
No
No(but possible by oval)
The Minimum number of argument to be passed in a function to create a rectangle using canvas tkinter is (a)
Screen inside another screen is possible by creating __________
Another window
buttons
labels
frames
The correct way to use the config() function in tkinter is _____________
object.property
config(property)
object.config(property)
config(object,property)
The use of the mainloop() in Python Tkinter is __________
To create a window screen
To Destroy the window screen
To exit window screen
To Hold the window Screen
