wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Full

Total questions: 55

Worksheet time: 34mins

Name
Class
Date
1.

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:

a)

Read String is : Hi there,

b)

Read String is : Python is simple.

c)

Syntax error

d)

Read String is : Hi there,

I am loving Python.

Python is simple.

2.

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:

a)

Read String is : Hi there

b)

Read String is : Hi there,

c)

Syntax error

d)

Hi there,

I am loving Python.

Python is simple.

3.

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):

a)

Stmt2 prints the contents of the file test.txt

b)

Stmt5 will print number of tokens(words) in the file separated by a space ' '

c)

Stmt6 should be uncommented to close the open file.

d)

Stmt3 results in an error

4.

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:

a)

{}

b)

{0: 'Banana', 1: 'Apple', 2: 'Grapes'}

c)

[0: 'Banana', 1: 'Apple', 2: 'Grapes']

d)

{'Banana':0, 'Apple':1, 'Grapes':2}

5.

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:

a)

[]

b)

['Banana', 'Apple', 'Grapes']

c)

{'Banana', 'Apple', 'Grapes'}

d)

Error

6.

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

a)

['Banana', 'Guava', 'Strawberry']

b)

['Mango', 'Banana', 'Guava', 'Strawberry']

c)

['Mango', 'Banana']

d)

['Mango', 'Banana', 'Guava']

e)

['Guava', 'Banana', 'Mango']

7.

Assume the following list definition:

a = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge']

a)

print(a[4::-2])

b)

a[:] is a

c)

max(a[2:4] + ['grault'])

d)

print(a[-5:-3])

8.

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)

a += 'de'

b)

a += ['d', 'e']

c)

a.append(['d', 'e'])

d)

a[len(a):] = ['d', 'e']

e)

a.extend(['d', 'e'])

9.

What gets printed?

names = ['Amir', 'Barry', 'Chales', 'Dao']

print(names[-1][-1])

a)

A

b)

r

c)

Amir

d)

Dao

e)

o

10.

What gets printed from the above piece of code?

a)

11

b)

12

c)

21

d)

22

e)

33

11.

names1 = ['Amir', 'Barry', 'Chales', 'Dao']

loc = names1.index("Edward")

print(loc)

a)

-1

b)

0

c)

4

d)

Edward

e)

An exception is thrown

12.

Which of the following are true of Python lists?

a)

These represent the same list:['a', 'b', 'c'] ['c', 'a', 'b']

b)

A given object may appear in a list more than once

c)

All elements in a list must be of the same type

d)

A list may contain any type of object except another list

e)

There is no conceptual limit to the size of a list

13.

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)  

14.

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)  

15.

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)

a[2:2] = []

b)

del a[2]

c)

a[2] = []

d)

a[2:3] = []

e)

a.remove(3)

16.

Who is the father of Computer?

a)

Allen Turing

b)

Charles Babbage

c)

Simur Cray

d)

Augusta Adaming

17.

Which of the following is also known as brain of computer?

a)

Control unit

b)

Central Processing unit

c)

Arithmetic and language unit

d)

Monitor

18.

ASCII stands for

a)

American Stable Code for International Interchange

b)

American Standard Case for Institutional Interchange

c)

American Standard Code for Information Interchange

d)

American Standard Code for Interchange Information

19.

Microprocessors as switching devices are for which generation computers

a)

First Generation

b)

Second Generation

c)

Third Generation

d)

Fourth Generation

20.

Which of the following is a part of the Central Processing Unit?

a)

Printer

b)

Key board

c)

Mouse

d)

Arithmetic & Logic unit

21.

Which device is required for the Internet connection?

a)

Repeater

b)

Modem

c)

CD Drive

d)

NIC Card

22.

Which of the following is incorrect variable name in Python?

a)

variable_1

b)

variable1

c)

1variable

d)

_variable

23.

Which functions are used to accept input from the user.

a)

input()

b)

raw_input()

c)

rawinput()

d)

string()

24.

What is the data type of print(type(10))

a)

float

b)

integer

c)

int

d)

String

25.

What is the output of the following code

x = 6 y = 2

print(x ** y) print(x // y)

a)

66 0

b)

36 0

c)

66 3

d)

36 3

26.

Which of the following statement is False?

a)

They can contain both letters and numbers.

b)

Variable names can be arbitrarily long.

c)

Variable name can begin with underscore.

d)

Variable name can begin with number.

27.

Which of the following is not used as loop in Python?

a)

for loop

b)

while loop

c)

do-while loop

d)

None of the above

28.

What is NIC used for?

a)

To remotely access PC

b)

To connect computer to a network

c)

It is used in junipers routers for gateway card

d)

None

29.

. In a type of computer network, what does MAN stands for?

a)

Metropolis area network

b)

Mini area network

c)

Metropolitan area network

d)

Micro area network

30.

Which of the following is the type of the computer network?

a)

Metropolitan area network (MAN)

b)

Local area network (LAN)

c)

Wide area network (WAN)

d)

All of the above

31.

The _______ provides pictorial representation of given problem.

a)

Algorithm

b)

Flowchart

c)

Pseudocode

d)

All of these

32.

_______ is a procedure or step by step process for solving a problem.

a)

Algorithm

b)

Flowchart

c)

Pseudocode

d)

All of these

33.

The ______ symbol is used at the beginning of a flow chart.

a)

Circle

b)

Rectangle

c)

Diamond

d)

None of these

34.

What will be the output of above Python code?

str1="6/4"

print("str1")

a)

1

b)

6/4

c)

1.5

d)

str1

35.

What will following Python code return?

str1="Stack of books"

print(len(str1))

a)

13

b)

14

c)

15

d)

16

36.

Which one of the following is correct way of declaring and initializing a variable, x with value 5?

int x

a)

Int x=5

b)

int x=5

c)

x=5

d)

declare x=5

37.

All keyword in python are in

a)

Lowercase

b)

Uppercase

c)

Both uppercase & Lowercase

d)

None of the above

38.

How many keywords are there in python 3.7?

a)

32

b)

33

c)

30

d)

31

39.

In Python3, which functions are used to accept input from the user

a)

input()

b)

raw_input()

c)

rawinput()

d)

string()

40.

Who developed the Python language?

a)

Zim Den

b)

Guido van Rossum

c)

Niene Stom

d)

Wick van Rossum

41.

Config() in Python Tkinter are used to ____________

a)

destroy the widget

b)

place the widget

c)

configure the widget

d)

change property of the widget

42.

___________ method is used to draw a line in canvas tkinter

a)

canvas.create_line()

b)

line()

c)

create_line(canvas)

d)

create line()

43.

Creating line belongs to _________ category.

a)

GUI

b)

CGI

c)

Canvas

d)

scripting

44.

Essential thing to create a window screen using tkinter python is _________

a)

create a button

b)

To define a geometry

c)

create a file

d)

call tk() function

45.

The purpose of bg in Tkinter widget is to ____________

a)

To change the background of widget

b)

To change the direction of widget

c)

To change the size of widget

d)

To change the color of widget

46.

The keyword used to import the Tkinter in program is ________

a)

call

b)

from

c)

import

d)

use

47.

GUI stand for ___________

a)

Graph user interaction

b)

Global user interaction

c)

Graphical user interface


d)

Graphical user interaction

48.

How does the grid() function put the widget on the screen ?

a)

According to x,y coordinate

b)

According to left,right,up,down

c)

According to horizontal,vertical

d)

According to row and column wise

49.

The method(s) to import a tkinter in python program is/are ____________.

a)

import tkinter

b)

import tkinter as t

c)

from tkinter import *

d)

All the above

50.

The method to install tkinter in system is _________

a)

pip install python

b)

tkinter install

c)

tkinter pip install

d)

pip install tkinter

51.

It is possible to draw a circle directly in Tkinter canvas ?

a)

Yes

b)

No

c)

No(but possible by oval)

52.

The Minimum number of argument to be passed in a function to create a rectangle using canvas tkinter is (a)  

53.

Screen inside another screen is possible by creating __________

a)

Another window

b)

buttons

c)

labels

d)

frames

54.

The correct way to use the config() function in tkinter is _____________

a)

object.property

b)

config(property)

c)

object.config(property)

d)

config(object,property)

55.

The use of the mainloop() in Python Tkinter is __________

a)

To create a window screen

b)

To Destroy the window screen

c)

To exit window screen

d)

To Hold the window Screen