Advertisements
Advertisements
The SELECT statement when combined with the ______ clause returns records without repetition.
Concept: SQL for Data Query
Write two points of difference between Circuit Switching and Packet Switching.
Concept: Switching Techniques
Expand the following in the context of Internet Protocol:
POP3
Concept: Introduction to Protocols
Which of the following is an invalid datatype in Python?
Concept: Introduction of Exception Handling in Python
Which of the following statement(s) would give an error after executing the following code?
S="Welcome to class XII" # Statement 1
print(S) #Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5Concept: Built-in Exceptions in Python
Rao has written a code to input a number and check whether it is prime or not. His code is having errors. Rewrite the correct code and underline the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)Concept: Built-in Exceptions in Python
Predict the output of the Python code given below:
def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')Concept: Handling Exceptions in Python
Atharva is a Python programmer working on a program to find and return the maximum value from the list. The code written below has syntactical errors. Rewrite the correct code and underline the corrections made.
def max_num (L):
max=L(O)
for a in L:
if a > max
max=a
return maxConcept: Syntax Errors in Python
Which of the following operators will return either True or False?
Concept: Introduction of Exception Handling in Python
“In a Python program, if a break statement is given in a nested loop, it terminates the execution of all loops in one go.”
Concept: Handling Exceptions in Python
An exception may be raised even if the program is syntactically correct.
Concept: Exceptions in Python
The code given below accepts a number as an argument and returns the reverse number. Observe the following code carefully and rewrite it after removing all syntax and logical errors. Underline all the corrections made.
define revNumber (num) :
rev = 0
rem = 0
While num > 0:
rem ==num %10
rev = rev*10 + rem
num = num//10
return rev
print (revNumber (1234))Concept: Syntax Errors in Python
Given the following dictionaries.
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge the contents of both dictionaries?
Concept: The Pickle Module in Python
Which of the following mode in the file opening statement results or generates an error if the file does not exist?
Concept: Reading from a Text File in Python
The correct syntax of seek() is ______
Concept: Setting Offsets in a File in python
Assertion (A): CSV (Comma Separated Values) is a file format for data storage that looks like a text file.
Reason (R): The information is organized with one record on each line and each field is separated by a comma.
Concept: Types of Files in Python
Write a method COUNTLINES() in Python to read lines from the text file ‘TESTFILE.TXT’ and display the lines which do not start with any vowel.
Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The COUNTLINES() function should display the output as:
The number of lines not starting with any vowel - 1
Concept: Reading from a Text File in Python
Write a function ETCount() in Python, which should read each character of a text file “TESTFILE.TXT” and then count and display the count of occurrence of alphabets E and T individually (including small cases e and t too).
Example:
If the file content is as follows:
Today is a pleasant day.
It might rain today.
It is mentioned on weather sites
The ETCount() function should display the output as:
E or e : 6
T or t : 9
Concept: Reading from a Text File in Python
Aman is a Python programmer. He has written a code and created a binary file record.dat with employeeid, ename, and salary. The file contains 10 records.
He now has to update a record based on the employee id entered by the user and update the salary. The updated record is then to be written in the file temp.dat. The records which are not to be updated also have to be written to the file temp.dat. If the employee id is not found, an appropriate message should be displayed.
As a Python expert, help him to complete the following code based on the requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb")
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary :: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has
been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()
- Which module should be imported into the program? (Statement 1)
- Write the correct statement required to open a temporary file named temp.dat. (Statement 2)
- Which statement should Aman fill in Statement 3 to read the data from the binary file, record.dat, and in Statement 4 to write the updated data in the file, temp.dat?
Concept: The Pickle Module in Python
The syntax of seek() is:
file_object.seek(offset[,reference_point])
What is the default value of reference_point?
Concept: Setting Offsets in a File in python
