logo

Data Type And String in Python Report

This section contains Multiple-choice questions. There are 25 questions and each question carries 4 marks.

9 Pages2149 Words24 Views
   

Added on  2022-09-11

Data Type And String in Python Report

This section contains Multiple-choice questions. There are 25 questions and each question carries 4 marks.

   Added on 2022-09-11

ShareRelated Documents
Section A (100 marks)
This section contains Multiple-choice questions. There are 25 questions and each question
carries 4 marks. Please provide the answer ONLY in the space provided below every
question.
Answers provided elsewhere will NOT be marked.
1. What is the name of data type for character in Python?
A. Chr
B. Char
C. Character
D. Python do not have any data type for characters they are treated as string.
Question 1 Answer D. Python do not have any data type for characters they are treated as
string.
2. What does the following code do?
def a (b, c, d): pass
A. Defines a list and initialise it
B. Defines a function, which does nothing
C. Defines a function, which passes its parameters through
D. defines an empty class
Question 2 Answer B. Defines a function, which does nothing
Q3. What will be printed if we execute the following statement?
nums = set ([1,1,2,3,3,3,4])
print(len(nums))
A. 1
B. 2
C. 4
D. 5
Question 3 Answer C. 4
Q4. What is the output of the following program?
temp = ['Geeks', 'for', 'Geeks']
arr = [i [0]. upper () for i in temp]
print(arr)
A. [‘G’, ‘F’, ‘G’]
B. [‘GEEKS’]
C. [‘GEEKS’, ‘FOR’, ‘GEEKS’]
D. Compilation error
Question 4 Answer A. [‘G’, ‘F’, ‘G’]
Q5. What is the output of the code?
if (7 < 0) and (0 < -7):
print("abhi")
elif (7 > 0) or False:
Data Type And String in Python Report_1
print("love")
else:
print("geeksforgeeks")
A. geeksforgeeks
B. love
C. abhi
D. Error
Question 5 Answer B. love
6. What is the output of the following?
True = False
while True:
print (True)
break
A. False.
B. True.
C. Error.
D. None of these
Question 6 Answer C. Error
7. What is the output of the following?
i = 1
while True:
if i % 3 == 0:
break
print(i)
i + = 1
A. 1 2 3
B. 1 2
C. Syntax Error
D. None of these
Question 7 Answer B. 1 2
8. A ----------------is a variable that is created inside a function.
A. Global variable
B. Local variable
C. Hidden variable
D. None of the above; you cannot create a variable inside a function
Question 8 Answer B. Local variable
9. This statement causes a function to end and sends a value back to the part of the
program that called the function.
A. End
B. Send
Data Type And String in Python Report_2
C. Exit
D. Return
Question 9 Answer D. Return
10. A file that data is read from is known as a(n)--------------.
A. Input file
B. Output file
C. Sequential access file
D. Binary file
Question 10
Answer
A. Input file
11. The contents of this type of file can be viewed in an editor such as Notepad.
A. Text file
B. Binary
C. English file
D. Human-readable file
Question 11
Answer
A. Text file
12. You write this statement to responds to exceptions.
A. Run/handle
B. Try/except
C. Try/handle
D. Attempt/ except
Question 12
Answer
B. Try/except
13. This list method adds an item to the end of an existing list.
A. Add
B. Add to
C. Increase
D. Append
Question 13
Answer
D. Append
14. Which built-in function can be used to read input that has been typed on the
keyboard?
A. input ()
B. get_input()
C. read_input()
D. keyboard ()
Question 14
Answer
A. input()
15. A (n) __________ is a special variable that receives a piece of data when a function is
called.
Data Type And String in Python Report_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Python Program Structure Analysis
|6
|1191
|28

C Programming Language Assignment
|44
|2042
|197

TCSS142 Computer Science and Systems
|8
|2141
|359

Python 3 Programming Assignments
|26
|6985
|50

LO1 Define basic Algorithms to Carry Out an Operation
|24
|6156
|124

Walk through the exercises in the attached pdf
|36
|5753
|28