0% found this document useful (0 votes)
55 views6 pages

ComputerScience xi worksheet

Download as docx, pdf, or txt
0% found this document useful (0 votes)
55 views6 pages

ComputerScience xi worksheet

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

ADHYAPANA SCHOOL CBSE, MADURAI

1) Define the following:


pharming,identity theft,DOS attack, Phishing and cyber crime
2) Assertion (A):- If the arguments in function call statement match the 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).

3) Assertion (A): Positional arguments in Python functions must be passed in the exact order in which
they are defined in the function signature.
Reasoning (R): Python functions automatically assign default values to positional arguments
4) Assertion (A): The strip() method removes all occurrences of a specific character from a string.
Reasoning (R): The strip() method removes characters only from the beginning and end of the
string.

5) Assertion(A): List is an immutable data type


Reasoning(R): When an attempt is made to update the value of an immutable
variable, the old variable is destroyed and a new variable is created by the same
name in memory.

6) Assertion(A): Python Standard Library consists of various modules.


Reasoning(R): A function in a module is used to simplify the code and avoids
repetition. 1 S

7) What will be the output of the following statement: print(3-2**2**3+99/11)


244 b. 244.0 c. -244.0 d. Error
8) Consider the statements given below and then choose the correct output from the
given options: pride="#G20 Presidency" print(pride[-2:2:-2]) 1 [3] Options: a. ndsr b.
ceieP0 c. ceieP d. yndsr 9 Which of the followi

9) Which of the following statement(s) would give an error during execution of the
following code?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4

10) Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES
as an argument and displays the names (in uppercase)of the places whose names are
longer than 5 characters. For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"} The output should
be: LONDON NEW YORK

11) 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)

12) 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’)

13) Write the Python statement for each of the following tasks using BUILT-IN
functions/methods only: (i) To insert an element 200 at the third position, in the list
L1.
14) (ii) To check whether a string named, message ends with a full stop / period or
not. 1+1= 2 [8] OR A list named studentAge stores age of students of a class. Write
the Python command to import the required module and (using built-in function) to
display the most common age value from the given list.
Given is a Python string declaration:
myexam="@@CBSE Examination 2022@@"
Write the output of: print(myexam[::-2])
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())

15) 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=' ')
s
16) Predict the output of the Python code given below:
tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

17) Write a function INDEX_LIST(L), where L is the list of elements passed


as argument to the function. The function returns another list named ‘indexList’ that stores the
indices of all Non-Zero Elements of L.
For example:
If L contains [12,4,0,11,0,56] The indexList will have - [0,1,3,5]

18) Write a function in Python, Push(SItem) where , SItem is a dictionary


containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who have price greater than 75.
Also display the count of elements pushed .
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}

The list should contain


Notebook
Pen
The output should be: The count of elements in the stack is 2
19) State True or False
“Variable declaration is implicit in Python.”
20) Which of the following is an invalid datatype in Python?
(a) Set (b) None (c)Integer (d)Real
21) Given the following dictionaries
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}

22) Which statement will merge the contents of both dictionaries?


a. dict_exam.update(dict_result)
b. dict_exam + dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)

23) Consider the given expression:


not True and False or True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL

24) Select the correct output of the code:


a = "Year 2022 at All the best"
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)
(a) Year . 0. at All the best
(b) Year 0. at All the best
(c) Year . 022. at All the best
(d) Year . 0. at all the best

25) Convert (31F)16 ,(432)10 to i) octal and ii) binary


26) Convert (76)8 ,(44.75)10 to i) Hex and ii) binary

27) 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
a) S="Thank you" # Stateme-15
b) 42

c) 0
d) 3.14
e) -0.99
f) 2.718
g) "Hello, World!"
h) 'Python123'
i) "2024-12-07"
j) True
k) False
l) [1, 2, 3, 4]
m) ["apple", "banana", "cherry"]
n) [True, False, True]
o) (5, 10, 15)
p) ("red", "green", "blue")
q) (42, "age", True)
r) {"name": "Alice", "age": 25}
s) {"brand": "Ford", "model": "Mustang", "year": 1964}
t) {"Python": 3.9, "Java": 17, "C++": 14}
u) {1, 2, 3}
v) {"cat", "dog", "rabbit"}
w) {True, False}
x) None
y) 3 + 4j
z) -2 - 7j

28) How is a mutable object different from an immutable object in Python?

29) Give two examples of each of the following: (III) unary and binary operators with eXample
30) compare: > with >> and < with << operators (II) Relational operators AND III Bitwise
31) EVALUATE result = (5 + 3 * 2) ** 2 / (8 - 4) + 6
i. value = 4 * (7 + 2) // 3 + (5 - 1) ** 2

32) 25. If L1=[1,2,3,2,1,2,4,2, . . . ], and L2=[10,20,30, . . .], then


33) (Answer using builtin functions only)
Write a statement to count the occurrences of 4 in L1.
Write a statement to insert all the elements of L2 at the end of L1. (OR)
Write a code to sort the elements of list L1 in ascending order.
Write a statement to reverse the elements of list L2.
a. L1 = [1, 2, 3, 2, 1, 2, 4, 2, ...]
b. L2 = [10, 20, 30, ...]

To sort the elements of L1 in ascending order, use the sort() method:

To reverse the elements of L2, use the reverse() method:

34) Sure! Here’s another set of questions with built-in functions related to lists:
35) Given the following lists:

L1 = [12, 45, 67, 89, 23, 45, 90, 45]


L2 = [1, 3, 5, 7, 9]
Write a statement to find the index of the first occurrence of 45 in L1.
Write a statement to remove the last element from L2.
36) L1 = [3, 1, 4, 1, 5, 9]
37) L2 = [6, 7, 8, 9]
Write a statement to count the occurrences of 4 in L1.
Write a statement to insert all the elements of L2 at the end of L1.

38) Write a statement to find the maximum value in L1.


39) Write a statement to create a new list with elements of L1 and L2 concatenated together.
find all the possible the output
import random
a="Wisdom"
b=random.randint(1,6)
for i in range(0,b,2):
a. print(a[i],end='#')

import random
x = random.randint(1, 10)
for i in range(0, x, 3):
print(i, end='$')
import random
letters = "HELLO"
z = random.randint(1, 5)
for i in range(0, z, 2):
print(letters[i], end='-')

import random
word = "Dreams"
n = random.randint(2, 7)
for i in range(1, n, 2):
print(word[i], end='%')

41) write a python program to to swap the first and last elements of a given tuple.
42) # Identify the syntax error in the following code:
for i in range(5):
print("Value:", i) # Output each value
43) # Identify and fix the indentation error:
x = 10
if x > 5:
print("x is greater than 5")
else:
print("x is 5 or less")
44) # Correct the code to resolve the syntax error:
def greet()
print("Hello, World!")
45) # Fix both the syntax and indentation errors in the code:
n = 4
while n > 0
print("Countdown:", n)
n -= 1
print("Blast off!")
46) # Identify and correct 1the syntax error:
numbers = [1, 2, 3, 4]1
for num in numbers
print(num)

47) What are some effective methods to prevent identity theft?


48) Write a Python function that finds and displays all the words longer than 5 characters from a list.
49) Write a Python function that finds and displays longest word in a string
50) Write a Python function that finds and displays longest word in a list
51) Write a Python function that create a dictionary with 5 elements in which each element contain
question as Key and option with answer as Values
52) If the BooksInfo is already empty, the function should display "No books available".
53) Write a user-defined function insert_even(N) which accepts a list of integers in a parameter
`N` and pushes all even integers in to list named `EvenNumbers` and display only the
numbers that are end with 4.
1∗ 3 2∗ 5 3∗ 7
54) Write a python program to find the sum of series S=
3!
+ 5!
+ 7 ! +…
55) Write a python program to find the sum of series S=1*2*3+2*3*4+3*4+5+…

56) 32. (a) Write the truth table for the given Boolean expression F=A’B’+A.C
57) Truth table for and,or and not gate and also nand and xor gate
58) Write the truth table for x+x’+y+y’ and also draw the circuit diagram also

59) (b)draw the c ircuit for abc+cd+(a+c)d

60) Predict the output of the following code:


d = {"apple": 15, "banana": 7, "cherry": 9}
str1 = ""
for key in d:
str1 = str1 + str(d[key]) + "@" + “\n”
str2 = str1[:-1]
print(str2)
61) for i in range(1, 6, 2):
print(i * '*')
62) *
***
*****

63) Output Prediction: String Manipulation


string = "PYTHON"
for i in range(0, len(string), 2):
print(string[i], end='@')
Output Prediction: List Operations
64) lst = [10, 20, 30, 40, 50]
for i in lst[::-2]:
print(i)

65) lst[::-2] reverses the list and selects every second element.
66) Reversed list is [50,40,30,20,10][50, 40, 30, 20, 10][50,40,30,20,10], so selected elements are
[50,30,10][50, 30, 10][50,30,10].
67) Output Prediction: Random Module
68) import random
for i in range(3):
print(random.randint(1, 10))

69) Output Prediction: Function with Recursion


def fun(n):
if n == 0:
return 1
else:
return n * (n - 1)
print(fun(4))

line=[4,9,12,6,20]
for I in line:
for j in range(1,I%5):
print(j,’#’,end=””)
print()
70) Write a python program to create a list of integers entered by the user. Find and display the
largest and smallest numbers in the list. Calculate and display the sum of all prime elements
in the list
71) What ethical principles should be adhered to for safe and responsible internet browsing?
72) If t1 = (3,4,5,6,7,9) and t2 = ( 8,2 ),perform the following task
Print the elements first and last
Print the tuple t1 elements in reverse after sorting
Merge the tuples and print it without using extend function
i.

You might also like