0% found this document useful (0 votes)
12 views10 pages

Preboard 11

The document contains a series of questions and programming tasks related to computer science concepts, including data transfer protocols, cyber crimes, Python programming, SQL assertions, and file handling. It covers topics such as function definitions, error handling, data structures, and database operations. The questions are designed to assess knowledge and skills in programming and database management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

Preboard 11

The document contains a series of questions and programming tasks related to computer science concepts, including data transfer protocols, cyber crimes, Python programming, SQL assertions, and file handling. It covers topics such as function definitions, error handling, data structures, and database operations. The questions are designed to assess knowledge and skills in programming and database management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

1.Name the protocol that is used to transfer data over the internet.

2.After practicals, Atharv left the computer laboratory but forgot to sign off
from his email account. Later, his classmate Revaan started using the
same computer. He is now logged in as Atharv. He sends inflammatory
email messages to few of his classmates using Atharv’s email account.
Revaan’s activity is an example of which of the following cyber crime?
a. Hacking b. Identity theft c. Cyber bullying d.
Plagiarism

3. Assertion (A):- If the arguments in function call statement matchthe


number and order of arguments as defined in the function definition,
such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).

4. Assertation (A) – Protocol is a set of rules and guidelines for data


communication over the internet
Reasoning (R) – This determines the data communication among various
devices connected on a network

5. Evaluate the following expressions:


a) 16 // 3 + 3 ** 3 + 15 / 4 - 9
b) x>y or y<z and not x!=z If x, y, z=25, 16, 9

6. Write a function Interchange (num) in Python, which accepts a list num of


integers, and interchange the adjacent elements of the list and print the
modified list as shown below: (Number of elements in the list is assumed as
even)
Original List:
num = [5,7,9,11,13,15]
After Rearrangement num = [7,5,11,9,15,13]

7. Write a function in Python that displays the words, starting with uppercase
letter in a file ‘legend.txt’.
Example: If the “legend.txt” contents are as follows:
Diego Maradona, Argentinian soccer legend and celebrated Hand of
Godscorer dies at 60.
The output of the function should be:
Diego Maradona, ArgentinianHand God

8. Write a function countdigits() in Python, which should read each character


of a text file “marks.txt”, count the number of digits and display the file
content and the number of digits.
Example: If the “marks.txt” contents are as follows:
Harikaran:40,Atheeswaran:35,Dahrshini:30,Jahnavi:48
The output of the function should be:
Harikaran:40,Atheeswaran:35,Dahrshini:30,Jahnavi:48
('Total number of digits in the file:', 8)

9.Find and write the output of the following Python code:


def Shuffle(str1):
str2=""
for i in range(0,len(str1)-1):
if(str1[i].islower()):
str2=str2+str1[i].upper()
elif str1[i].isupper():
str2=str2+str1[i].lower()elif
str1[i].isdigit():
str2=str2+'d'
else:
str2=str2+(str1[1-i])
print(str2)
Shuffle('Pre-Board Exam@2023')

10. A file sports.dat contains information in following format [event,


participant].
Write a program that would read the contents from file and copy only those
records from sports.dat where the event name is “Athletics” in new file
named Athletics.dat

11. Name the switching technique used for voice communication.

12. SSL is the abbreviation of _________


13.
Find and write the output of the following Python code:
def Mycode(Msg,ch):
s=""
for cnt in range(len(Msg)):
if Msg[cnt]>='P' and Msg[cnt]<='S':
s=s+Msg[cnt].lower()
else:
if Msg[cnt]=='N' or Msg[cnt]=='n' or Msg[cnt]==' ':
s=s+ch
else:
if(cnt%2==0):
s=s+Msg[cnt].upper()
else:
s=s+Msg[cnt-1]
print(s)
Mycode("Input Raw","@")

14. Write a user defined function in python SHIFT(lst) that would accept a list as
argument .The function should shift the negative numbers of the list to right
and the positive numbers to left without using a another list.
For example if list initially contains
[3, -5, 1, 3, 7, 0, -15, 3, -7, -8]
Then after shifting list should contain
[3, 1, 3, 7, 0, 3, -8, -7, -15, -5]

15. Binary file gift.dat has structure:

{" Gift_ID ":value, " Name ":value, " Remarks ":value, " Price ":value}
Write a function BUMPER() in Python to read each record of a binary file
GIFTS.DAT, find and display details of those gifts, which has remarks as
"ON DISCOUNT".
ii. Write a function TRANSFER( ) in python, that would copy all
those records which are having price greater than 500 to
G_COPY.DAT .

16. Identify the output of the following code snippet:


text = "PYTHONPROGRAM"
text=text.replace('PY','#')
print(text)

17. True or False:


The finally block in Python is executed only if no exception occurs in the
try block

18. Assertion (A): In the case of positional arguments, the function call and
function definition statements match in terms of the number
and order of arguments.
Reasoning (R): During a function call, positional arguments should precede
keyword arguments in the argument list.

19. Assertion (A): A SELECT command in SQL can have both WHERE and
HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check
conditions, therefore, these can be used interchangeably.

20. Write a Python program to input an integer and display all its prime factors in
descending order, using a stack. For example, if the input number is 2100, the
output should be: 7 5 5 3 2 2 (because prime factorization of 2100 is
7x5x5x3x2x2)
Hint: Smallest factor, other than 1, of any integer is guaranteed to be prime.

21. When is NameError exception raised in Python?


II. Give an example code to handle NameError? The code should
display the message "Some name is not defined" in case of
NameError exception, and the message "Some error occurred" in
case of any other exception.

22. csv file "Happiness.csv" contains the data of a survey. Each record of
the file contains the following data:
● Name of a country
● Population of the country
● Sample Size (Number of persons who participated in the survey in
that country)
● Happy (Number of persons who accepted that they were Happy)
For example, a sample record of the file may be:
Signiland, 5673000, 5000, 3426
Write the following Python functions to perform the specified operations
on this file:
(I) Read all the data from the file and display all those records for
which the population is more than 5000000.
(II) Count the number of records in the file.

23. urya is a manager working in a recruitment agency. He needs to


manage the records of various candidates. For this he wants the
following information of each candidate to be stored:
Candidate_ID – integer
Candidate_Name – string
Designation – string
Experience – float
You, as a programmer of the company, have been assigned to do this
job for Surya. Suggest:
(I) What type of file (text file, csv file, or binary file) will you use
to store this data? Give one valid reason to support your
answer.
(II) Write a function to input the data of a candidate and append
it in the file that you suggested in part (I) of this question.
(III) Write a function to read the data from the file that you
suggested in part (I) of this question and display the data of
all those candidates whose experience is more than 10.

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


int('65.43')
a) ImportError
b) ValueError
c) TypeError
d) NameError

25. Can one block of except statements handle multiple exception?


A. yes, like except TypeError, SyntaxError [,…]
B. yes, like except [TypeError, SyntaxError]
C. No
D. None of the above

26. How many except statements can a try-except block have?


A. 0
B. 1
C. more than one
D. more than zero

27. Which block lets you test a block of code for errors?
A. try
B. except
C. finally
D. None of the above

28. . What will be output for the folllowing code?


try:
print(x)
except:
print(""An exception occurred"")
A. x
B. An exception occurred
C. Error
D. None of the above

29. Assertion(A): If the arguments in a function call match the number and order of
argumets as defined in the function definition,such arguments are called the
positional
arguments.
Reasoning(R): During a function call,the argument list first contains default
arguments
followed by positional arguments.
30. Assertion(A): The random module is a built-in module to generate the pseudo-
random
variables.
Reason(R): The randrange() function is used to generate a random number between the
specified range in its parameter.
31. Assertion (A): Global variable is declared outside the all the functions.
Reasoning (R): It is accessible through out all the functions.
32. Assertion (A): The math.pow(2,4)gives the output: 16.0
Reason (R): The math.pow() method receives two float arguments, raise the first to
the
second and return the result.
33. Assertion (A): Built-in function are predefined in the language that are used
directly.
Reason (R): print() and input() are built-in functions
34. Assertion (A):- In Python, statement return [expression] exits a function.
Reasoning (R):- Return statement passes back an expression to the caller.
A return statement with no arguments is the same as return None.
35. Assertion (A): When passing a mutable sequence as an argument, function
modifies
the original copy of the sequence.
Reasoning (R): Function can alter mutable sequences passes to it.

36. Assertion(A):An identifier may be combination of letters and numbers.


Reason(R):No special symbols are permitted in an identifier name

37. .Assertion(A):After adding element in a list, its memory location remains same
Reason(R):List is a mutable data type

38. Which of the following function header is Correct:


A. def fun(x=1,y)
B. def fun(x=1,y,z=2)
C. def fun(x=1,y=1,z=2)
D. def fun(x=1,y=1,z=2,w)

39. Give the output of the following program


def check(a):
for i in range(len(a)):
a[i]=a[i]+5
return a
b=[1,2,3,4]
c=check(b)
print(c)
a) [6, 8, 8, 9] b) [6,7,8,9] c) [7, 7, 8, 9] d) [6,7,9,9]

40. Find the output of the following program:


def ChangeIt(Text,C):
T=""
for K in range(len(Text)):
if Text[K]>='F' and Text[K]<='L':
T=T+Text[K].lower();
elif Text[K]=='E' or Text[K]=='e':
T=T+C;
elif K%2==0:
T=T+Text[K].upper()
else:
T=T+T[K-1]
print(T)
OldText="pOwERALone"
ChangeIt(OldText,"%")

41. What possible output(s) are expected to be displayed on screen at the time of
execution of the following code? Also specify the maximum and minimum value that
can be assigned to variable X.
import random
L=[10,7,21]
X=random.randint(1,2)
for i in range(X):
Y=random.randint(1,X)
print(L[Y],"$",end=" ")
(i)10 $ 7 $ (ii) 21 $ 7 $ (iii) 21 $ 10 $ (iv) 7 $

42. Statement1: Local Variables are accessible only within a function or block in
which it
is declared.
Statement2: Global variables are accessible in the whole program

43. Which of the following statements are true?


a. When you open a file for reading, if the file does not exist, an error
occurs
b. When you open a file for writing, if the file does not exist, a new file is
created
c. When you open a file for writing, if the file exists, the existing file is
overwritten with the new file
d. All of the mentioned

44. Which of the following python statement will bring the read pointer to 10th
character from the
end of a file containing 100 characters, opened for reading in binary mode.
a) File.seek(10,0) b) File.seek(-10,2) c) File.seek(-10,1) d) File.seek(10,2)

45. Vedansh is a Python programmer working in a school. For the Annual Sports
Event, he has
created a csv file named Result.csv, to store the results of students in different
sports events. The
structure of Result.csv is : [St_Id, St_Name, Game_Name, Result]
Where
St_Id is Student ID (integer)
ST_name is Student Name (string)
Game_Name is name of game in which student is participating(string)
Result is result of the game whose value can be either 'Won', 'Lost' or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to write the following
user defined
functions:
Accept() – to accept a record from the user and add it to the file Result.csv. The
column headings
should also be added on top of the csv file.
wonCount() – to count the number of students who have won any event.
As a Python expert, help him complete the task.

46. Kiran is a Python programmer working in a shop. For the employee’s tax
collection, he has
created a csv file named protax.csv, to store the details of professional tax paid
by the employees.
The structure of protax.csv is : [empid, ename, designation, taxpaid]
Where,
empid is employee id (integer)
ename is employee name (string)
designation is employee designation(string)
taxpaid is the amount of professional tax paid by the employee(string)
For efficiently maintaining data of the tax, Kiran wants to write the following
user defined
functions:
Collection() – to accept a record from the employee and add it to the file
protax.csv.
Totaltax() – to calculate and return the total tax collected from all the
employees.
As a Python expert, help him complete the task

47. Assertion(A): The resultset refers to a logical set of records that are fetched
from the
database executing an SQL Query.
Reason (R): Resultset stored in a cursor object can be extracted by using fetch(…)
functions.

48. Assertion(A): In SQL, aggregate function avg()calculates the average value on a


set of
values and produce a single result.
Reason (R): The aggregate functions are used to perform some fundamental arithmetic
tasks such as min(), max(), sum() etc

49. Assertion(A): Primary key is a set of one or more attributes that identify
tuples in a
relation.
Reason (R): The primary key constraint is a combination of the NOT NULL and UNIQUE
constraints

50. Assertion(A): Foreign key is a non-key attribute whose value is derived from
primary
key of another table.
Reason (R): Each foreign key refers a candidate key in a relation
51. Assertion(A): The SELECT statement in SQL is used to retrieve data from one or
more
tables.
Reason(R): The SELECT statement can be used to retrieve all columns or a subset of
columns from a table.

52. Assertion(A): The WHERE clause in SQL is used to filter data based on a
specified
condition.
Reason(R): The WHERE clause is always required when using the SELECT statement
in SQL

53. Assertion (A): The ORDER BY clause in SQL is used to sort the result set in
ascending
or descending order.
Reason(R): The ORDER BY clause can only be used with the SELECT statement in
SQL

54. Assertion (A): The IN operator in SQL is used to match a value with a list of
values.
Reason(R): The IN operator can only be used with the where clause in SQL

55. Assertion (A): The between operator in SQL is used to match a value with in a
range of
values.
Reason(R): The between operator can only be used with numerical values in SQL.

56. Assertion (A): The LIKE operator in SQL is used to match a value with a
pattern.
Reason(R): The % and _ wildcard characters can be used with the LIKE operator in
SQL

56. Write a python connectivity program to delete the record from a table named
employee
using parameterised query and also count the number of deleted record. If the
details are
not existing,then print “Record Not Found” message?

57. Shyam has created a table named ‘Student’ in MYSQL database, ‘SCHOOL’:
• rno(Roll number )- integer
• name(Name) - string
• Per(Percentage) – float
Note the following to establish connectivity between Python and MySQL:
•Username - root • Password - manager • Host – localhost
120 | K V S E K M , P A R T – A S T U D E N T S U P P O R T M A T E R I A L , X I I
C S
Shyam, now wants to increase the percentage of students by 2% ,who got less than 40
percentage. Help Shyam to write the program in Python

58. Assertion (A):- The default delimiter in CSV files is comma(,).


Reasoning (R):- The default delimiter of the CSV file can be overridden
withthe help of the ‘delimiter’ attribute

59. Assertion (A):- If the arguments in a function call statement match the
number and order of arguments as defined in the function definition, such
arguments arecalled positional arguments.
Reasoning (R):- During a function call, the argument list first contains
defaultargument(s) followed by positional argument(s).

60. Write a function countNow(STUDENT) in Python, that takes the dictionary,


STUDENT as an argument and displays the names (in uppercase) having 4
characters.
For example, Consider the following dictionary
STUDENT={1:"ARUN",2:"AVINASH",3:"PRIYA",4:"NIHA",5:"JEWEL"}
The output should be:
ARUN
NIHA

61. Ms. Shalu has just created a table named “Staff” containing Columns Sname,
Department and Salary.
After creating the table, she realized that she has forgotten to add a primary key
in the table. Help her in writing an SQL command to add a primary key - StaffId
of integer type to the table Staff.
Thereafter, write the command to insert the following record in the table:
StaffId - 111
Sname- Shalu
Department: Marketing
Salary: 45000

62. Kiran is working in a database named SCHOOL, in which he has created a table
named “STUDENT” containing columns UID, SName, Gender and Category.
After creating the table, he realized that the attribute, Category has to be
deleted
from the table and a new attribute Stream of data type string has to be added.
This attribute Stream cannot be left blank. Help him to write the commands to
complete both the tasks.

63. Write a Program in Python that defines and calls the following user defined
functions:
a) add() – To accept and add data of an employee to a CSV file
‘furdata.csv’. Each record consists of a list with field elements as fid,
fname and fprice to store furniture id, furniture name and furniture
price respectively.
b) search()- To display the records of the furniture whose price is more
than 10000.

64. Define the term Domain with respect to RDBMS. Give one example to support
your answer.
Sunil wants to write a program in Python to read a record from the table named
student and displays only those records who have marks between 80 and 95:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python and MYSQL:
∙ Username is root
∙ Password is tiger
The table exists in a MYSQL database named vidyalaya.

65. Write a program to insert the following record in the table Student:
RollNo – integer
Name – string
Class – integer
Marks – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is abcd
The table exists in a MYSQL database named XIICS.
The details (RollNo, Name, Class and Marks) are to be accepted from the user

66. The Python interpreter handles logical errors during code execution

67.

68.

You might also like