Python Coding Question
Chapter 01: Command
Terminal
Q. 1: Command for
printing the version of python in terminal __________
(a) pypl version
(b) python
-version
(c) python
--version
(d) version
Ans: (c) python --version
Q. 2: Command for running
a python file__________
(a) python filename.py
(b) python->filename.py
(c) start filename.py
(d) run filename.py
Ans: (a) python filename.py
Q. 3: Valid command
for running a python file__________
(a) python
(b) pypl
(c) py
(d) run
Ans: (a) python, (c) py
Q. 4: what is the command
for closing a terminal?
(a) exit
(b) quiet
(c) exit()
(d) quiet()
Ans: (c) exit()
Python Coding Question
Chapter 02: Comment
Q. 1: Which sign do
use in python for commenting?
(a) -
(b) <>
(c) !
(d) #
Ans: (d) #
Q. 2: For multiple
comment python use the signs _____
(a) """ """
(b) < ! ---
>
(c) ###
(d) <<>>
Ans: (a) """ """
Q. 3: Which one is the
valid comment in python language?
(a) <this is a comment>
(b) #this is a comment
(c) """ this is a comment """
(d) <!this is a
comment--->
Ans: (b) #this is a comment (c) """ this is a comment """
Python Coding Question
Chapter 03:
Print function
Q. 1: What is the
number of parameters of the ‘print’
function in python?
(a) 6 (b)5 (c)
3 (d)2
Ans: (b) 5
Q. 2: Optional
parameter of python ‘print’
function is ______
(a) 4 (b)5 (c)
3 (d)6
Ans: (a) 4
Q. 3: What is the output
of this print function?
print(“Hello”, “python”, sep=”, ”, end=”.”)
(a)Hellopython (b)Hello, python
(c)Hello, python.
(d)Hello python.
Ans: (c) Hello, python.
Q. 4: What will be the output of the print function?
x=(”A”, ”B”, ”C”, ”D”)
print(x)
(a) Tuple (b)Set (c) Dictionary (d)List
Ans: (a) Tuple
Q. 5: What is the default
value of the ‘file’
parameter in the python ‘print’
function?
(a) sys.in (b) sys.print (c) sys.out (d) sys.stdout
Ans: (d) sys.stdout
Q. 6: ‘flush’ is a ______
(a) python list
function parameter
(b) python print
function parameter
(c) java print
function parameter
(d) python range
parameter
Ans: (b) python print function parameter
Q. 7: Which one is
valid for the print function
in python?
(a) print(“Hello”, end=”.”)
(b) print(“Hello”, “python”, flush=True, end=”.”)
(c) print(“Hello”, “python”)
(d) a , b, c
Ans: (d) a, b, c
Q. 8: What is the default
for the end parameter
in the print function?
(a) \t
(b) A space ( ‘ ‘
)
(c) \n
(d) None of the above
Ans: (c) \n
Q. 9: What is the default
for the sep parameter
in the print function?
(a) true
(b) A space ( ‘ ‘ )
(c) false
(d) 1
Ans: (b) A space ( ‘ ‘ )
Python Coding Question
Chapter 04: Variables
Q. 1: Which program
will run without any error?
(a)
x = 8
y = python
z = "abrar"
print(x)
print(y)
(b)
x = 9
y = "python"
print(x)
print(y)
(c)
x = 5a
y = "python"
print(x)
print{y)
(d)
x = 10
y = "python--"
print(x}
print(y)
Ans: (b)
Q. 2: What will be the
output of the below program?
a = 90
b = "python y"
print (a+b, end=".")
(a) 90python y.
(b) unsupported
operand
(c) syntax error
(d) 90 python y.
Ans: (b) unsupported operand
Q. 3: Find the output
of the following program.
hello="find me"
hi="I am
here"
print (hi+" "+hello,sep="--",end="...")
(a) find me -- I am
here…
(b) find me I am here.
(c) syntax error
(d) I am here find me…
Ans: (d) I am here find me…
Q. 4: Output of the
following python program _____
a=10
b=10
c=10
print (a+b+c/10, " :10", sep=",")
(a) 3, :10
(b) 3.0, :10
(c) 21.0, :10
(d) 21, :10
Ans: (c) 21.0, :10
Q. 5: Is the python
program valid?
import sys
a=10
sys.stdout(a)
(a) No
(b) Yes
(c) Valid for
different python engine
(d) Unknown
Ans: (a) No