Python Unit I MCQ.ppt

VEERANANVEERANAN 299 views 42 slides Aug 03, 2023
Slide 1
Slide 1 of 42
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42

About This Presentation

Python Programming


Slide Content

Python Programming
GOVERNMENT ARTS COLLEGE, MELUR
PG. Department of Computer Science
UNIT –I
MCQ & QPS
“Presentation & Delivery”
BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
VEERANAN VEERANAN
I M.Sc. Computer Science., Dip.in.Yoga.,
Roll No. P22PCS123

VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123
Python is a popular programming language. It was created by Guido van Rossum,
and released in 1991.
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.

1 PythonProgramming:AnIntroduction
1.1IDLE an Interpreter for Python
1.2 Python Strings
1.3 Relational Operators
1.4 Logical Operators
1.5 Bitwise Operators
1.6 Variables and Assignment Statements
1.7 Logical Operators
1.8 Bitwise Operators
1.9 Variables and Assignment Statements
1.10 Keywords
1.11 Script Mode
3 Control Structures
3.1 if Conditional Statement
3.2 Iteration (for and while
Statements).
2 Functions
2.1 Built-in Functions
2.2 Function Definition and Call
2.3 Importing User-defined Module
2.4 Assert Statement
2.5 Command Line Arguments

1 PythonProgramming:AnIntroduction
1.1IDLE an Interpreter for Python
1.2 Python Strings
1.3 Relational Operators
1.4 Logical Operators
1.5 Bitwise Operators
1.6 Variables and Assignment Statements
1.7 Logical Operators
1.8 Bitwise Operators
1.9 Variables and Assignment Statements
1.10 Keywords
1.11 Script Mode
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

1 PythonProgramming:AnIntroduction
1.1IDLE an Interpreter for Python
IDLE= Integrated Development and Learning Environment
i. Python Shell
ii. Python Editor
>>> 18 + 5
23
>>> 18 * 5
90
>>> 27 / 5
5.4
>>> 27 // 5
5
>>> 27.0 // 5
5.0
>>> 27 % 5
2
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

1 PythonProgramming:AnIntroduction
1.2 Python Strings
>>> ‘Hello World’
‘Hello World’
>>>print(‘Hello World’)
Hello World
>>>”””Hello
What’s
Happening”””
“Hello\nWhat’s\nHappening”
>>>print(“””Hello
What’s
Happening”””)
Hello
What’s
happening
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

1 PythonProgramming:AnIntroduction
1.3 Relational Operators
== (equal to)
< (lessthan)
> (greater than)
<= (less thanor equal to)
>= (greaterthan or equal to)
!= (not equal to)
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

1 PythonProgramming:AnIntroduction
1.4 Logical Operators
NOT
TrueFalse
FalseTrue
AND
TrueFalseFalse
FalseTrueFalse
OR
TrueTrueTrue
FalseTrueFalse
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

1 PythonProgramming:AnIntroduction
1.10 Keywords
Falseclass tryreturndefor if fromelseas elif
1.11 Script Mode
number1 = input()
number2 = input()
print(number1, number2)
number1 = input(‘Enter first number:’)
number2 = input(‘Enter Second number:’)
Print(‘Number are:’ number1, number2)
Enter first number: 3
Enter second number: 6
Number are: 3 6
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

2 Functions
2.1 Built-in Functions
2.2 Function Definition and Call
2.3 Importing User -defined Module
2.4 Assert Statement
2.5 Command Line Arguments
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

2 Functions
2.1 Built-in Functions
1. input Function
>>>name = input(‘Enter a name:’)
Enter a name: Navanee
>>>name
‘Navanee’
2. evalfunction
>>>eval(’15+10’)
25
3. Composition
>>>n1 = eval(input (‘Enter a Number:’))
Enter a Number: 234
>>> n1
234
4. type Function
>>>print(type(12), type(12.5), type(‘Hello’), type(int))
<class ‘int’> <class ‘float’> <class ‘str’> <class ‘type’>
5. round Function
>>>print(round(89.625,2), round(89.635), round(89.635,0)
89.6290 90.0 VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

2 Functions
2.2 Function Definition and Call
Syntax:
deffunction_name(comma_separated_list_of_parameters):
statements
if __name==‘__main__’:
main()
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

2 Functions
2.4 Assert Statement
defpercent (marks, maxMarks):
percentage = (marks / maxMarks) * 100
return percentage
defmain():
maxMarks= float(input(“Enter maximum marks:”))
assert maxMarks>=0 and maxMarks<=500
assert marks >=0 and marks <=maxMarks
percentage = percent(marks, maxMarks)
print(‘Percentage is:’, percentage)
if __name__==‘__main__:’
main()
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

3 Control Structures
3.1 if Conditional Statement
3.2 Iteration (for and while Statements).

BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
1.Whichoneofthefollowingisthe
correctextensionofthePythonFile?
A..py
B..python
C..p
D.None of these

BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
2.Whichoneofthefollowinghas
thehighestprecedenceinthe
expression?
A.Division
B.Subtraction
C.Power
D.Parentheses

BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
3.Whatarithmeticoperatorscannot
beusedwithstring?
A.+
B.*
C.-
D.All of the Mentioned

BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
4.Whatismethodinsidetheclassin
pythonlanguage?
A.Object
B.Function
C.Attribute
D.Argument

BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
5.Whichcharacterisusedinpython
tomakeasinglelinecomment?
A./
B.//
C.#
D.!

BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
6.Whichofthefollowingfunctions
isabuild-in-functioninpython
language?
A.val()
B.print()
C.printf()
D.None of these

SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
1.Whatwillbetheoutputofthe
followingPythoncode?
>>>print (r”\nhello”)
A.a new line and hello
B.\nhello
C.the letter r and then hello
D.error

SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
2.Whatistheanswertothis
expression,
22 % 3 is?
A.7
B.1
C.0
D.5

SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
3.Whatwillbetheoutputofthe
followingPythonStatement?
>>>print(‘new’ ‘line’)
A.Error
B.Output equivalent to print
‘new\nline’
C.newline
D.new line

SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
4.Whichisthecorrectoperatorfor
power(x)?
A.X^y
B.X**y
C.X^^y
D.None of the mentioned
y

SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
5.WhodevelopedthePython
language?
A.ZimDen
B.Guido van Rossum
C.NieneStom
D.Wick van Rossum

SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
6.Whichoneofthefollowinghas
thehighestprecedenceinthe
expression?
A.Exponential
B.Addition
C.Mutiplication
D.Parentheses

CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
1.Whatwillbetheoutputofthe
followingPythoncode?
A.None None
B.None 22
C.22 None
D.Error is generated
classfather:
def __init__(self, param):
self.o1=param
classchild(father):
def __init__(self, param):
self.o2=param
>>>obj =child(22)
>>>print "%d %d"%(obj.o1, obj.o2)

CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
2.Whatwillbethevalueofxinthe
followingPythonexpression,ifthe
resultofthatexpressionis2?
x>>2
A.8
B.4
C.2
D.1

CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
3.Whichofthefollowingrepresents
thebitwiseXORoperator?
A.&
B.^
C.|
D.!

CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
4.Which ofthefollowing
expressionscanbeusedtomultiply
agivennumber‘a’by4?
A.a<<2
B.a<<4
C.a>>2
D.a>>4

CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
5.Howmanytypesofseveritylevels
aretherefortheASSERTstatement?
A.1
B.2
C.3
D.4

CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
6.Howmanyexceptstatementscan
atry-exceptblockhave?
A.zero
B.one
C.more than one
D.more than zero

VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123
1.Which ofthefollowing
precedenceorderiscorrectin
Python?
A.Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
B.Multiplication, Division, Addition, Subtraction, Parentheses, Exponential
C.Division, Multiplication, Addition, Subtraction, Parentheses, Exponential
D.Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123
2.Whatdoweusetodefineablock
ofcodeinPythonlanguage?
A.Key
B.Brackets
C.Indentation
D.None of these

VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123
3.Whichofthefollowingstatements
iscorrectregardingtheobject-
orientedprogrammingconceptin
Python?
A.Classes are real-world entities while objects are not
real
B.Objects are real-world entities while classes are not
real
C.Both objects and classes are real-world entities
D.All of the above

VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123
4.Whatisthemethodinsidethe
classinpythonlanguage?
A.Object
B.Function
C.Attribute
D.Argument

VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123
5.Studythefollowingfunction:
round(4.576)
Whatwillbetheoutputofthis
function?
A.4
B.5
C.576
D.5

VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123
6.Studythefollowingfunction:
import math
abs(math.sqrt(36))
Whatwillbetheoutputofthis
function?
A.Error
B.-6
C.6
D.6.0

Python Programming: An Introduction
IDLE an Interpreter for Python
https://www.javatpoint.com/python-mcq
Python Strings
https://www.sanfoundry.com/python-mcqs-strings-1/
https://www.sanfoundry.com/python-mcqs-strings-2/
Python Strings –1
Python Strings –2
Python Strings –3
Python Strings –4
Python Strings –5
Python Strings –6
Python Strings
Python Strings –7
Python Strings –8
Python Strings –9
Python Strings –10
Python Strings –11
Python Strings –12
Python Strings –13
Reference
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

Relational Operators
https://study.com/academy/practice/quiz-
worksheet-relational-operators-in-
python.html
Logical Operators
https://www.sanfoundry.com/python-mcqs-
basic-operators/
Bitwise Operators
https://www.sanfoundry.com/python-
questions-answers-bitwise-1/
https://www.sanfoundry.com/python-
questions-answers-bitwise-2/
Variables and Assignment Statements
https://pynative.com/python-variables-and-
data-types-quiz/
https://www.sanfoundry.com/python-
questions-answers-variable-names/
Keywords
Script Mode
https://www.sanfoundry.com/python-
written-test-questions-answers/
https://www.sanfoundry.com/python-
scripting-questions-answers/
Reference
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

Reference
Functions
Python Function –1
Python Function –2
Python Function –3
Python Function –4
Built-in Functions
Python Built-in Functions –1
Python Built-in Functions –2
Python Built-in Functions –3
Function Definition and Call
Importing User-defined Module
https://www.sanfoundry.com/python-
questions-answers-modules/
Assert Statement
https://www.sanfoundry.com/vhdl-
questions-answers-assert-statement/
Command Line Arguments
https://www.sanfoundry.com/interview-
questions-c-command-line-arguments/
Control Structures
if Conditional Statement
https://www.sanfoundry.com/python-
questions-answers-exception-handling/
https://www.sanfoundry.com/python-
questions-answers-exception-handling-2/
Iteration (for and while Statements).
https://www.sanfoundry.com/python-
questions-answers-while-and-for-loops-1/
VEERANAN VEERANAN
I M.Sc. Computer Science
Roll No. P22PCS123

Thank You
&
Your Opportunity
“Presentation & Delivery”
BAVATHARANI K
I M.Sc. Computer Science
Roll No. P22PCS103
SANTHIYA C
I M.Sc. Computer Science
Roll No. P22PCS108
CHINNASAMY C
I M.Sc. Computer Science
Roll No. P22PCS112
VEERANAN VEERANAN
I M.Sc. Computer Science., Dip.in.Yoga.,
Roll No. P22PCS123
Tags