WorksheetsInformatics Practices Mid-Term Exam
Total questions: 35
Worksheet time: 3600secs
Dictionaries are set of _________elements.
sorted
ordered
unordered
random
Dictionaries are also called____________.
mappings
hashes
associative arrays
all of these
Auxiliary memory refers to:
Primary memory
Secondary memory
Ternary memory
All of these
Which of the following is correct with respect of the following Python code? d = {"X":3,"Y":7}
a dictionary d is created
X and Y are the keys of dictionary d
3 and 7 are the values of dictionary d
All of these
Which of the following is the correct extension of the Python file?
.py
.python
Both (a) and (b)
None of these
Which one of the following brackets do we use to create a LIST in Python?
( )
[ ]
{ }
" "
Is Python case-sensitive when dealing with identifiers?
no
yes
machine dependent
none of the mentioned
Which of the following is not a decision-making statement?
if statement
if-elif statement
for statement
if -else statement
What will be the output of the following code? d = {'spring': 'autum', "autumn": "fall", "fall":"spring"} print (d["autumn"])
autumn
fall
spring
Error
Which one of the following is the correct way of initializing a variable, x with value 5 in Python?
int x
int x = 5
x = 5
all of these
Which one of the following will give an error?
a=b=c=1
a,b,c=1
a,b,c=1,1,1
None of these
What will be the output of the following code? D1 = {"cat":17, "dog":6, "elephant":23, "bear":20} print (25 in D1)
True
False
Error
None
What is the output when we execute list(“hello”)?
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘hello’]
[‘llo’]
[‘olleh’]
To decrease the value of X by 4 using an augmented operator, the correct expression will be :
X-=4
X*=4
X=X**4
None of the mentioned
Correct syntax of writing simple ‘ if Statement’ is ................
if condition statements
if (condition) statements
if condition : statements
if condition-- statements
Which one of the following is correct to create an empty dictionary?
myDic = ( )
myDic = [ ]
myDic = { }
None of these
Assertion (A): Solving an expression involves NOT, AND, OR with no parenthesis then Reasoning (R): NOT will be evaluated first; AND will be evaluated second; OR will be evaluated last.
Both A and R are true and R is the correct explanation for A
Both A and R are true and R is not the correct explanation for A
A is True but R is False
A is False but R is True
Assertion (A): We are trying to change an element in a tuple, we get an error Reasoning (R): Because tuple is an immutable data type, here we cannot change any element.
Both A and R are true and R is the correct explanation for A
Both A and R are true and R is not the correct explanation for A
A is True but R is False
A is False but R is True
What is for loop in python? Write syntax and example.
Why can’t Lists be used as keys of dictionaries?
Why is a dictionary termed as an unordered collection of objects?
What is list in python? How we can create a list in Python?
Write difference between = and == OR Write the Differences between RAM and ROM.
What is an operating system? Give a few examples.
What is the value of this expression? 2**2**1
Which of the following will result in an error for a given valid empty dictionary D?
What is the output of the following codes? i. print(float(49//5)) ii. print(49//5) iii. print(49%5)
What is the output of the following codes? i. x = 15 print(x > 14 and x < 16) ii. a={(1,2):1,(2,3):2} print(a[1,2]) iii. a={'a':1,'b':2,'c':3} print(a['a','b'])
What is the difference between Interpreter and a Compiler? (any three) OR What is the difference between Software and Hardware? (any three)
What do you understand by Python programming language? Who developed Python programming language? OR Explain the evolution of computing devices.
Find out the Errors and rewrite the corrected code also underline the corrected part. #Write a Python program to check whether a number is negative, positive or zero. num = = int(input('Enter the number :')) if (num = 0): print('It is zero.') elif (num < 0): print('It is positive.') else print('It is negative.') OR #Write a Python program to check whether a year is leap year or not. year = int(input("Enter Year: ")) if (year % 4 == 0 or year % 100 != 0): print(year, "is a Leap Year") elif (year % 100 = 0): print(year, "is not a Leap Year") elif (year * 400 ==0): print(year, "is a Leap Year") else: input(year, "is not a Leap Year")
Find out the Errors and rewrite the corrected code also underline the corrected part. #Write a program to create a dictionary containing names of competition winner students as keys and number of their wins as values. n = int(input("How many students?")) CompWinners = { } for a in range(n): value == input("Name of the student :") key = int (input("Number of competitions won :")) CompWinners [key] == value print("The Dictionary now is :") print(CompWinners) OR #program that inputs a list, replicates it twice, and then prints the sorted list in ascending and descending orders. val = EVAL(input("Enter a list :")) print("Original list :", val) val = val * 2 print("Replicated list :", val) val.SORT() print("Sorted in ascending order :", val) val.SORT(reverse = False) print("Sorted in descending order :", val)
Write examples of the following ways to create a Python dictionary using dict( ) function. i. Creating an empty dictionary by dict( ) function. ii. Specify key:value pairs as keyword arguments to dict( ) function. iii. Specify comma-separated key:value pairs. iv. Specify keys separately and corresponding values separately. v. Specify key:value pairs separately in the form of sequences.
What do you understand by the “nested if “ statement? Write syntax for different formats of “nested if “statements. OR Write the output of the following Python statements. i. for x in range(5): print(x) ii. for y in range(2,5): print(y)
Write the output return by the following slices for the given below list. List = [’a’,’b’,’c’,10, 20, 30, 40, 50, 60, 70, 80, 90] i. print(List[::]) ii. print(List[::2]) iii. print(List[3:9:2]) iv. print(List[::-1]) v. print(List[1:1:-2]) OR Write the difference for the following:- i. between append() and extend() ii. between sort() and sorted()
