0% found this document useful (0 votes)
152 views

UNIT-1 Introduction To Python Programming

This document contains a quiz on introductory Python programming concepts. It includes 50 multiple choice questions testing topics like variables, data types, operators, functions, strings and formatting, covering the basics of the Python language. The questions assess foundational knowledge of Python syntax, semantics and programming principles.

Uploaded by

harish
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views

UNIT-1 Introduction To Python Programming

This document contains a quiz on introductory Python programming concepts. It includes 50 multiple choice questions testing topics like variables, data types, operators, functions, strings and formatting, covering the basics of the Python language. The questions assess foundational knowledge of Python syntax, semantics and programming principles.

Uploaded by

harish
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

UNIT-1

Introduction to Python Programming

1. Is Python case sensitive when dealing with identifiers?

a) yes b) no c) machine dependent d) none of the mentioned

Answer: a

2. What is the maximum possible length of an identifier?

a) 31 characters b) 63 characters c) 79 characters d) none of the mentioned

Answer: d

3. Which of the following is invalid?

a) _a = 1 b) __a = 1 c) __str__ = 1 d) none of the mentioned

Answer: d

4. Which of the following is an invalid variable?

a) my_string_1 b) 1st_string c) foo d) _

Answer: b

5. Why are local variable names beginning with an underscore discouraged?

a) they are used to indicate a private variables of a class

b) they confuse the interpreter

c) they are used to indicate global variables

d) they slow down execution

Answer: a

6. Which of the following is not a keyword?

a) eval b) assert c) nonlocal d) pass

Answer: a

7. All keywords in Python are in

a) lower case b) UPPER CASE c) Capitalized d) None of the mentioned

Answer: d

8. Which of the following is true for variable names in Python?


a) unlimited length

b) all private members must have leading and trailing underscores

c) underscore and ampersand are the only two special characters allowed

d) none of the mentioned

Answer: a

9. Which of the following is an invalid statement?

a) abc = 1,000,000

b) a b c = 1000 2000 3000

c) a,b,c = 1000, 2000, 3000

d) a_b_c = 1,000,000

Answer: b

10. Which of the following cannot be a variable?

a) __init__ b) in c) it d) on

Answer: b

11. Python is said to be easily

A. readable language B. writable language C. bug-able language D. script-able language

Answer: A

12.Extensible programming language that can be extended through classes and

programming interfaces is

A.Python B.Perl C.PHP D.Ada

Answer: A

13.Python was released publicly in

A.1941 B.1971 C.1981 D.1991

Answer: D

14. What is the order of precedence in python?

i) Parentheses ii) Exponential iii) Multiplicationiv) Division v) Addition vi) Subtraction


A. i,ii,iii,iv,v,vi B.ii,i,iii,iv,v,vi C. ii,i,iv,iii,v,vi D .i,ii,iii,iv,vi,v

Answer: A

15. Who developed Python Programming Language

a) William Stalling b) Grady Booch c) Guido Van Rossum d) Rajkamal

Answer: C

16. Is Python Programming___

a) Low level Language b) Middle Level Language c) High Level Language d) All the above

Answer: C

19. What does Python supports like

a) Object Oriented Language b) Procedural Oriented

c) Interpreted Language d) Scripting Language

Answer: D

20. Which of the following is correct?

a)Comments are for programmers for better understanding of the program.

b)Python Interpreter ignores comment.

c)You can write multi-line comments in Python using triple quotes, either ''' or """.

d)All of the above

Answer: A

21. Which of the following is correct?

a)Variable name can start with an underscore. b)Variable name can start with a digit.

c)Keywords cannot be used as a variable name.

d)Variable name can have symbols like: @, #, $ etc.

Answer:A

22. In the following code, n is a/an _______? n = '5'

a)integer b)string c)tuple d)operator

Answer:B

25.What is the output of the following code?


print(1, 2, 3, 4, sep='*')

a)1 2 3 4 b)1234 c)1*2*3*4 d)24

Answer:C

26.What is used to take input from the user in Python?

a)cin b)scanf() c)input ()d)<>

Answer:C

27.What is the output of the following code?

numbers = [2, 3, 4]

print(numbers)

a)2, 3, 4 b)2 3 4 c)[2, 3, 4] d)[2 3 4]

Answer: C

28. What is the output of the following code?

print(3 >= 3)

a)3 >= 3 b)True c)False d)None

Answer:B

29.The statement using and operator results true if _______

a)both operands are true b)both operands are false

c)either of the operands is true d)first operand is true

Answer:A

30. What is used to define a block of code (body of loop, function etc.) in Python?

a)Curly braces b)Parenthesis c)Indentation d)Quotation

Answer: C

31. Which of these in not a core datatype?

a) Lists b) Dictionary c) Tuples d) Class

Answer: d
32. Given a function that does not return any value, What value is thrown by default when
executed in shell.

a) int b) bool c) void d) None

Answer: d

33.Following set of commands are executed in shell, what will be the output?

>>>str="hello"

>>>str[:2]

>>>

a) he b) lo c) olleh d) hello

Answer: a

34.Which of the following will run without errors ?

a) round(45.8) b) round(6352.898,2,5) c) round() d) round(7463.123,2,1)

Answer: a

35.What is the return type of function id ?

a) int b) float c) bool d) dict

Answer: a

36.n python we do not specify types,it is directly interpreted by the compiler, so consider the
following operation to be performed.

>>>x = 13 ? 2

objective is to make sure x has a integer value, select all that apply (python 3.xx)

a) x = 13 // 2 b) x = int(13 / 2) c) x = 13 % 2 d) All of the mentioned

Answer: d

38.What error occurs when you execute?

apple = mango

a) SyntaxError b) NameError c) ValueError d) TypeError

Answer: b

39.Carefully observe the code and give the answer.

def example(a):
a = a + '2'

a = a*2

return a

>>>example("hello")

a) indentation Error

b) cannot perform mathematical operation on strings

c) hello2

d) hello2hello2

Answer: a

40.What dataype is the object below ?

L = [1, 23, ‘hello’, 1].

a) list

b) dictionary

c) array

d) tuple

Answer: a

41.In order to store values in terms of key and value we use what core datatype.

a) list

b) tuple

c) class

d) dictionary

Answer: d

42.Which of the following results in a SyntaxError ?

a) ‘”Once upon a time…”, she said.’

b) “He said, ‘Yes!'”

c) ‘3\’
d) ”’That’s okay”’

Answer: c

43.The following is displayed by a print function call:

tom

dick

harry

Select all of the function calls that result in this output

a) print(”’tom

\ndick

\nharry”’)

b) print(”’tomdickharry”’)

c) print(‘tom\ndick\nharry’)

d) print(‘tom

dick

harry’)

Answer: c

44.What is the average value of the code that is executed below ?

>>>grade1 = 80

>>>grade2 = 90

>>>average = (grade1 + grade2) / 2

a) 85

b) 85.1

c) 95

d) 95.1

Answer: b

45.Select all options that print


hello-how-are-you

a) print(‘hello’, ‘how’, ‘are’, ‘you’)

b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)

c) print(‘hello-‘ + ‘how-are-you’)

d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

Answer: c

46. What is the return value of trunc() ?

a) int

b) bool

c) float

d) None

Answer: a

47.What is the output of the following?

print("Hello {name1} and {name2}".format(name1='foo', name2='bin'))

a) Hello foo and bin

b) Hello {name1} and {name2}

c) Error

d) Hello and

Answer: a

48.What is the output of the following?

print("Hello {0!r} and {0!s}".format('foo', 'bin'))

a) Hello foo and foo

b) Hello ‘foo’ and foo

c) Hello foo and ‘bin’

d) Error

Answer: b

49.What is the output of the following?


print("Hello {0} and {1}".format(('foo', 'bin')))

a) Hello foo and bin

b) Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)

c) Error

d) None of the mentioned

Answer: c

50.What is the output of the following?

print('{:,}'.format(1112223334))

a) 1,112,223,334

b) 111,222,333,4

c) 1112223334

d) Error

Answer: a

You might also like