0% found this document useful (0 votes)
44 views8 pages

Practice Exam 7

#1. The document contains 30 practice exam questions about Python. #2. The questions cover Python syntax like comments, variables, data types, functions, conditionals, loops, strings and more. #3. Each question provides multiple choice answers to test the examinee's knowledge of Python programming concepts and standard library functions.

Uploaded by

unheardfacts16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views8 pages

Practice Exam 7

#1. The document contains 30 practice exam questions about Python. #2. The questions cover Python syntax like comments, variables, data types, functions, conditionals, loops, strings and more. #3. Each question provides multiple choice answers to test the examinee's knowledge of Python programming concepts and standard library functions.

Uploaded by

unheardfacts16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Practice Exam 7

1. How would you insert a comment in python?

A. #I am a comment
B. //I am a comment
C. // I am a comment in python //
D. comment(I am a comment in python)

2. Who is the creator of Python?

A. Anthony hopkins
B. Guido van Rossum
C. James Gosling
D. Yukihiro Matsumoto

3. Which of the following is a wrong way to declare a variable in python?

A. _ak = "forrest"
B. 123abc = "forrest"
C. _myvar= "forrest"
D. my_var= "forrest"

4. What kind of argument can you put into print() function?

A. Only numbers
B. Only strings
C. All kind of arguments
D. print() function doesn't support arguments

5. What is the output of below program?


print("hello world")
print("superman")
print()
print("wonderland")
A.
hello world
superman
wonderland
B. hello world superman wonderland
C.
hello world
superman
wonderland
D. none of the above
6. What will be the output of following code?
print("Lion king is a\ngreat movie")
A. Lion king is a great movie
B. Lion king is a\ngreat movie
C.
Lion king is a
great movie
D. Lion king is a great movie
7. What is the correct output for the code below?
print("red roses and violet roses")
print(" 'red' roses and 'violet' roses")
print("""red roses and violet roses""")
A.
red roses and violet roses
red roses and violet roses
red roses and violet roses
B.
red roses and violet roses
'red' roses and 'violet' roses
red roses and violet roses
C. red "roses" and "violet" roses

D. none of the above


8. What will be the output of mentioned below code ?
Dict = {'Name': 'Robert', 'age': 30, 3:[2,3,4,5,8]}
print(Dict)

A. Syntax Error
B. {'Name', 'age', 3}
C. {'Robert', 30, [2,3,4,5,8]}
D. {'Name': 'Robert', 'age': 30, 3: [2, 3, 4, 5, 8]}

9. What will be the output of mentioned below code ?


for num in range(1, 10, 3):
print(num, end = ",")

A. 1,4,7,
B. syntax error
C. 1,2,4,5,6,7,8,9,10
D. 1,10,3

10. Which of the following the correct output to the mentioned below code?
print("apple","mangoes","Bananas","Oranges","Watermelon")

A. "apple","mangoes","Bananas","Oranges","Watermelon"
B. apple mangoes Bananas oranges
C. apple mangoes Bananas Oranges Watermelon
D. None of the above

11. Python is treated as a:

A. Compiled language
B. Assembled language
C. Interpreted language
D. None of the above

12. What will be the output of mentioned below code ?


print("bottle", "cup", "bag", "wallet", end=" ")
print("Mobile", "calculator","book")
A. bottle, cup, bag, wallet, Mobile, calculator, book
B. bottle cup bag wallet Mobile calculator book
C.
bottle cup bag wallet
Mobile calculator book
D.
bottle, cup, bag, wallet
mobile, calculator, book
13. What will be the output of mentioned below code ?
print("bottle", "cup", "bag", "wallet", sep="-")

A. bottle-cup-bag-wallet-sep
B. bottle, cup, bag, wallet
C. bottle cup bag wallet
D. bottle-cup-bag-wallet

14. What will be the output of mentioned below code ?


print(13//(2*2))

A. 3
B. 3.5
C. 4
D. Syntax Error

15. Which one is the correct file extension used for python files ?

A. .ty
B. .pyt
C. .py
D. .pt

16. What is the output of the mentioned below code?


if 2==2.0:
print("same values")
else:
print("different values")

A. different values
B. Same values
C. syntax error
D. runtime error

17. What would be the output of the below code?


fruits = ["Robert","Karamagi", ""]
fruits.remove("Robert")
print(fruits)

A. Robert
B. ['Robert', '']
C. ["Robert","Karamagi"]
D. ["Robert"]

18. What would be the output of the following code?


print((10*2)/5)

A. 6
B. 2
C. 1
D. 4.0

19. What will be the output of mention below code?


a= "castle"
b= "army"
c,d=a,b
print(c,d, sep="::")

A. army::castle
B. army:castle:
C. castle::army
D. none of the above

20. What is the output of the mentioned below code?


i=1
while i < 10:
i+=3
print(i)
A.
4
7
10
B.
1
4
8
C.
2
6
10
D. Syntax Error
21. What would be the output of the following code?
temperature = 105
if temperature > 96 and temperature < 98:
print("body is ok")
elif temperature > 99 and temperature < 103:
print("fever detected")
elif temperature >103 and temperature < 106:
print("Emergency, Rush to the hospital")
else:
print("No data entered")

A. body is ok
B. fever is detected
C. Emergency, Rush to the hospital
D. No data is entered

22. What will be the output of mentioned below code ?


def myfun(num):
if num >= 4:
return num
elif num<4:
return 2
print(myfun(3))

A. 2
B. 3
C. Syntax Error
D. none of the above

23. What will be the output of mentioned below code ?


fruits = ("pineapple", "strawberry", "grapes", "orange", "kiwi", "cherry",
"mango")
print(fruits[-4:-1])

A. ('orange', 'kiwi', 'cherry')


B. ('grapes', 'mango')
C. ()
D. ("pineapple", "strawberry", "grapes", "orange", "kiwi", "cherry",
"mango")

24. What is the output of the following code?


aTuple = (200, 300, 400, 500, 600)
print(aTuple[-2])
print(aTuple[-4:-1])
A. 300
B.
500
(300, 400, 500)
C. None of the above
D. IndexError: tuple index out of range
25. What is the output of the following code ?
name = "robert"
print(name=="Robert")

A. TypeError
B. TRUE
C. FALSE
D. UnboundLocalError

26. What would be the output of mentioned below code ?


for num in range(1, 12, 2):
print(num, end = ",")

A. 1.2.3.4.5.6.7.8.9.10.11.12
B. 1 3 5 7 9 11
C. 1,3,5,7,9,11,
D. None of the above

27. What will the output be after running the following code?
def magicTrick(num) :
if (num % 2 == 0):
print('even')
else:
print("odd")
magicTrick(8)

A. even
B. odd
C. magicTrick
D. num

28. What will be the output of mentioned below code ?


continentOne = str("Antarctica")
continentTwo = "Antarctica"
print(continentOne == continentTwo)

A. FALSE
B. TRUE
C. error
D. undefined variable

29. Which of the following will convert the string "hello, life is beautiful" to
"Hello, Life Is Beautiful"
A. capitalize()
B. uppercase()
C. bigcase()
D. upper()

30. Strings are immutable.

A. True
B. False
C. Maybe
D. So

You might also like