[miniorange_social_sharing]
[TheChamp-Login]

/40

Final Exam for Python for Everyone (A to Z)

BEST OF LUCK!!!

1 / 40

1. The len() method to return the length of an array

2 / 40

2.

Function defined to achieve some task as per the programmer’s requirement is called a ___________

a. user defined function

b. library function

c. built in functions

d. All of the above.

3 / 40

3. You have to use the same number of spaces in the same block of code, otherwise Python will give you an error

4 / 40

4.

Which keyword is used to begin the definition of a function?

a. Define

b. DEF

c. def

d. Def

5 / 40

5. A loop block in python starts with a –

a) ; (semicolon)

b) , (comma)

c) : (colon)

d) # (hash)

6 / 40

6. Can we write if/else into one line in python?

a) Yes
b) No
c) if/else not used in python
d) None of the above

7 / 40

7. What does the following code print?

x = -10if x < 0:    print("The negative number ",  x, " is not valid here.")print("This is always printed")
a.This is always printedb.The negative number -10 is not valid hereThis is always printedc.The negative number -10 is not valid here

8 / 40

8. Comparison operators are not  used to compare two values

9 / 40

9. Python can be treated in a procedural way, an object-oriented way or a functional way.

10 / 40

10.

Write the output of the following code :

str = "Welcome"str[2] = 'a'print(str)

a. Weacome

b. Error

c. aWelcome

d. Welcomea

11 / 40

11. X wants to allow the program to repeatedly ask the user to enter their Choice if it does not equal the Answer. Which loop option should X use?

a) while Choice == Answer:

Choice = input()

b) while Choice != Answer:

Choice = input()

c) while Answer != Choice:

Choice = input()

d) while Answer =! Choice:

Choice = input()

 

12 / 40

12. Who developed Python Programming Language?

13 / 40

13. break in Python is used ______________

a) To restart a loop

b) Terminate a loop

c) To jump in between the loop

d) None of the above

14 / 40

14. Variables that are created outside of a function

15 / 40

15. What will be the output of the following Python code?

  1. d = {"john":40, "peter":45}
  2. d["john"]

a) 40
b) 45
c) “john”
d) “peter”

16 / 40

16. Python has a set of built-in methods that you can use on lists/arrays

17 / 40

17. Find the output of the following program segments:

for i in range(20,30,2):

print(i)

a) 20 22 24 26 28

b) 20

22

24

26

28

c) 20 22 24 26 28 30

d) 20

22

24

26

28

30

18 / 40

18. Comments starts with a #

19 / 40

19. if statements cannot be empty, but if you for some reason have an if statement with no content, put in the pass statement to avoid getting an error

20 / 40

20.

Following is an example of ___________________

sv = “csiplearninghub.com”

a. List

b. String

c. Dictionary

d. None of the above

21 / 40

21. Which term describes a loop that continues repeating without a terminating (ending) condition?

a) Infinite Loop

b) Conditional Loop

c) Unlimited Loop

d) Sequence Loop

22 / 40

22. Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned

23 / 40

23.

What will be the output of below Python code?

str1="poWer"str1.upper()print(str1)

A. POWER
B. Power
C. power
D. poWer

24 / 40

24. To insert characters that are illegal in a string, use an escape character

25 / 40

25. Strings in python are surrounded by either single quotation marks, or double quotation marks

26 / 40

26.

Which function overloads the >> operator?

  1. more()
  2. gt()
  3. ge()
  4. None of the above

27 / 40

27. You can also have multiple else statements on the same line:

28 / 40

28. Python has syntax that allows developers to write programs with fewer lines than some other programming languages.

29 / 40

29. Python is a  high-level programming language.

30 / 40

30. You can return a range of characters by using the slice syntax

31 / 40

31. You can use the append() method to add an element to an array

32 / 40

32. The else keyword catches anything which isn’t caught by the preceding conditions.

33 / 40

33.

What will be the output of below Python code?

str1="Information"print(str1[2:8])

A. format
B. formatio
C. orma
D. ormat

34 / 40

34. You can also use the remove() method to remove an element from the array

35 / 40

35. print() function is often used to output variables.

36 / 40

36. An example of an illegal character is a double quote inside a string that is surrounded by double quotes

37 / 40

37.

The function can be called in the program by writing function name followed by ____

a. [ ]

b. { }

c. ( )

d. None of the above

38 / 40

38. A variable name must start with a letter or the underscore character

39 / 40

39. python has two primitive loop commands:

  • while loops
  • for loops

40 / 40

40.

Which of the following statement will execute in last?

def s(n1): #Statement 1      print(n1) #Statement 2n2=4 #Statement 3s(n2) #Statement 4

a. Statement 1

b. Statement 2

c. Statement 3

d. Statement 4

Exit



[hurrytimer id=”2250″]
[wooct_product]

Wrong shortcode initialized


You must log in to see your results.



Wrong shortcode initialized


There are no questions atteched yet.





[ays_quiz_leaderboard id=”Your_Quiz_ID” from=”Y-m-d H:i:sa” to=”Y-m-d H:i:s”]

Category:


Wrong shortcode initialized


[WATU 1]

You must log in to see your results.