Font size
WorksheetsPython Programming
Total questions: 75
Worksheet time: 37mins
What will be the output?
name = "Dave"
print (name)
Dave
name
"Dave"
(name)
What is a input?
To plug in something
A function that allows us to ask the user to enter some data
Data displayed on a screen
A routine
A variable must have been assigned (given) a value before that value is referenced (used).
True
False
The correct way to convert user input is:
birth_year = number(input())
birth_year = int(input())
birth_year = (input(int))
birth_year = int(input)
To display the following on screen Hello World! the following command should be used:
print(Hello World!)
print("Hello World" + !)
print("Hello World!")
print"(Hello World!)"
You assign a value to a variable with which symbol
@
==
=
*
The code you use to receive and input from the keyboard
enter()
add()
receive()
input()
Program statements are executed in sequence, one after the other...
True
False
if you receive a NameError when you run your program it means....
A variable has been assigned before it has been referred to
An incorrect name has been chosen
A variable has been referred to before it has been assigned
A language key word has been used
If the coding steps are in the incorrect order, the computer can still execute the program.
True
False
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
What is the output of the following piece of code when executed in Python shell?
>>> a=("Check")*3
>>> a
(‘Check’,’Check’,’Check’)
* Operator not valid for tuples
(‘CheckCheckCheck’)
Syntax error
Which are arithmetic operators?
+
-
>
<
Which of the following cannot be a variable?
_init_
in
it
on
Which one of these is floor division?
//
/
%
None of the above
Python is a general purpose programming language created by
Dennis M. Ritchie
Guido Van Rossum
James Gosling
Bjarne Stroustrup
Expand IDLE
Internal Development Learning Environment
Integrated Development Learning Enforcement
Interactive Development Learning Environment
Integrated Development Learning Environment
Example of valid identifiers
12Name
name$
total-mark
total_marks
A Relational operator is also called as ___________
Arithmetic operator
Logical operator
Assignment operator
Comparative operator
"and, or and not" are ___________________
Arithmetic operator
Logical operators
Assignment operator
Comparative operator
__________are special words that are used by Python interpreter to recognize the
structure of program.
Tokens
Identifiers
Keywords
Operators
Choose the INVALID identifiers from the following
NUmbEr1
1NUMBer
A_B
A&B
________ are data items that have a fixed value
Tokens
Literals
Keyword
Operators
Examples of String Literals
"ABC1273"
nfjdlsj@@$
12638
'7e920938'
Choose the keyword from the following
IF
Else
iF
else
‘If’ is a decision making statement
TRUE
FALSE
What is the word (command) used to display numbers and text on the screen?
Input
Output
Command
What symbol is used in python to assign values to a variable?
:
*
=
==
Which of these would work as a piece of code?
if string="Dove"
if string=="Dove"
IF string="Dove":
if string=="Dove":
Python is -------language
compiled
interpreted
both compiled and interpreted
none of the above
What extension must you add to the end of a file when saving?
.c
.java
.py
.pyc
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
The equivalent of the above for loop using the while syntax would be
The above program prints
Numbers 1 to 10 in reverse order
Numbers 1 to 11 in reverse order
Numbers 1 to 10
Numbers 1 to 11
The result of this program:
Friday = False
if Friday:
print("Jeans day!")
else:
print("Uniform day")
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
True
False
condition1
condition2
What is the output?
True
NIL
True
NIL
True
NIL
NIL
Result of the program above is
('1', '2', '3', '4', '5')
(1, 2, 3, 4, 5)
12345
"12345"
What is the output of the code:
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
print d1 > d2
True
False
Not applicable
Predict the output of the following code:
x=3
If x>2 or x<5 and x==6:
Print(“ok”)
else:
print(“no output”)
ok
okok
no output
none of above
Which one of the following if statements will not execute successfully?
1) if (1, 2);
print(‘foo’)
2) if (1, 2):
print(‘foo’)
3) if (1):
print( ‘foo’ )
4) if (1);
print( ‘foo’ )
1,4
2
2,4
4
Find the output of the following program segments:
for i in range(20,30,2):
print(i)
20 22 24 26 28
20
22
24
26
28
20 22 24 26 28 30
20
22
24
26
28
30
Which one of the following is incorrect?
The variables used inside function are called local variables.
The local variables of a particular function can be used inside other functions, but these cannot be used in global space.
The variables used outside function are called global variables
In order to change the value of global variable inside function, keyword global is used.
Suppose a function called add() is defined in a module called adder.py. Which of the following code snippets correctly show how to import and use the add() function? Select all that apply.
from adder import add
result = adder.add(2, 3)
from adder import add
result = add(2, 3)
import add from adder
result = add(2, 3)
import adder
result = adder.add(2, 3)
What is the output of the given below program?
print("Know Program".split())
‘Know’, ‘Program’
(‘Know’, ‘Program’)
[‘Know’, ‘Program’]
{‘Know’, ‘Program’}
Find the output of the given Python program?
print(list("abcd".split('')))
[‘a’, ‘’, ‘b’, ‘’, ‘c’, ‘*’, ‘d’]
[‘a’, ‘b’, ‘c’, ‘d’]
[‘abcd’]
[‘abc*d’]
What will be the output of the following Python code?
a={1:"A",2:"B",3:"C"}
a.items()
items()
dict_items([(1,2,3)])
dict_items([(‘A’), (‘B’), (‘C’)])
dict_items([(1, ‘A’), (2, ‘B’), (3, ‘C’)])
Which of the following is correctly evaluated for this function?
pow(x,y,z)
(x**y) / z
(x / y) * z
(x**y) % z
(x / y) / z
Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?
Infile = open(''d:\\java.txt'', ''r'')
Infile = open(file=''d:\\\java.txt'', ''r'')
Infile = open(''d:\java.txt'',''r'')
Infile = open.file(''d:\\java.txt'',''r'')
