English

Arts (English Medium) Class 12 - CBSE Important Questions

Advertisements
[object Object]
[object Object]
Subjects
Popular subjects
Topics

Please select a subject first

Advertisements
Advertisements
< prev  1781 to 1800 of 4067  next > 

Which of the following operators will return either True or False?

Appears in 1 question paper
Chapter: [1] Exception Handling in Python
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.”

Appears in 1 question paper
Chapter: [1] Exception Handling in Python
Concept: Handling Exceptions in Python

An exception may be raised even if the program is syntactically correct.

Appears in 1 question paper
Chapter: [1] Exception Handling in Python
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))
Appears in 1 question paper
Chapter: [1] Exception Handling in Python
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?

Appears in 1 question paper
Chapter: [2] File Handling in Python
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?

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Reading from a Text File in Python

The correct syntax of seek() is ______

Appears in 1 question paper
Chapter: [2] File Handling in Python
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.

Appears in 1 question paper
Chapter: [2] File Handling in Python
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

Appears in 1 question paper
Chapter: [2] File Handling in Python
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

Appears in 1 question paper
Chapter: [2] File Handling in Python
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()
  1. Which module should be imported into the program? (Statement 1)
  2. Write the correct statement required to open a temporary file named temp.dat. (Statement 2)
  3. 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?
Appears in 1 question paper
Chapter: [2] File Handling in Python
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?

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Setting Offsets in a File in python

Write the definition of a Python function named LongLines() which reads the contents of a text file named 'LINES.TXT' and displays those lines from the file which have at least 10 words in it. For example, if the content of 'LINES.TXT' is as follows: 

Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some wood.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big gray wolf. 

Then the function should display output as:

He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily.

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Reading from a Text File in Python

Write a function count_Dwords() in Python to count the words ending with a digit in a text file "Details.txt".

Example:
If the file content is as follows:
On seat2 V1P1 will sit and
On seat1 VVIP2 will be sitting
The output will be:
The number of words ending with a digit is 4

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Reading from a Text File in Python

Write one difference between CSV and text files.

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Types of Files in Python

Which of the following functions changes the position of file pointer and returns its new position?

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Setting Offsets in a File in python

Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the tuple will have (4, 3, 2, 4, 4, 3)

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Reading from a Text File in Python

Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with the word ‘You’.

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Reading from a Text File in Python

Write a function, vowelCount() in Python that counts and displays the number of vowels in the text file named Poem.txt.

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: Reading from a Text File in Python

Consider a file, SPORT.DAT, containing records of the following structure:

[SportName, TeamName, No_Players]

Write a function, copyData(), that reads contents from the file SPORT.DAT and copies the records with Sport name as “Basket Ball” to the file named BASKET.DAT. The function should return the total number of records copied to the file BASKET.DAT.

Appears in 1 question paper
Chapter: [2] File Handling in Python
Concept: The Pickle Module in Python
< prev  1781 to 1800 of 4067  next > 
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×