Practice Paper - 6 With Ans
Practice Paper - 6 With Ans
Q1 f) Write a python program to accept age (integer) and gender (M or F) from user and 2
print ‘Allowed to Marry’ if the age is 21 and gender M or age 18 and gender F.
Otherwise ‘Not allowed’.
Ans age = int(input('Enter age:'))
gender = input('Enter gender as M or F:')
if age>=21 and gender=='M' or age>=18 and gender=='F':
print('Allowed to Marry')
else:
print('Not allowed')
g) Predict the output of the following python program: 2
num,sum=10,0
for i in range(1,num+2,2):
if i % 3 == 0:
continue
sum = sum + i
print(sum)
Ans 1 6 13 24
h) Predict the output of the following python program: 2
marks = [10,20]
for x in marks:
x = x + 10
print(x)
print(marks)
Ans 20
30
[10, 20]
i) Write a python program to accept a number from a user and print ‘Prime Number’ if 4
the input number is prime or else print ‘Not Prime’ if the number is not a prime
number.
[Or]
Write a program to accept two numbers from an user and compute the HCF(GCD) of
the two numbers.
Ans num = int(input())
for i in range(2,num//2+1):
if num % i == 0:
print('Not Prime')
break
else:
print('Prime Number')
[or]
divisor = int(input('Enter divisor:'))
dividend = int(input('Enter dividend:'))
while divisor > 0:
remd = dividend % divisor
dividend = divisor
divisor = remd
print(dividend)
Q.2 a) Name the exception that will be raised for the following python code: 1
num = input()
res=0
res= res + num
print(res)
Ans TypeError will be raised
b) What will be the output of the following python code: 2
(i) name = [2,4,6,8,10]
print(name[-1:1:-2])
c) Write a python program to count the frequency of elements of a list of numbers and 3
store the result in a dictionary.
Eg:
num = [1,2,1,3,4,2,3,4,5,6,1,2,1,3,3,4,5]
the result should be:
{1: 4, 2:3, 3:4, 4:3, 5:2, 6:1}
[Or]
Write a python program to shift each element of a list to the right and the last
element to become the first element.
Eg:
2 3 4 5 6
Should become
6 2 3 4 5
Ans num = [1,2,1,3,4,2,3,4,5,6,1,2,1,3,3,4,5]
d = {x:num.count(x) for x in num}
print(d)
[or]
lst = [2,4,6,8,10]
temp = lst[len(lst)-1]
for i in range(len(lst)-1,-1,-1):
lst[i]=lst[i-1]
lst[0]=temp
print(lst)
d) Write a python program tom implement the insertion sort algorithm for a list of 4
integers.
[Or]
Write a python program tom implement the bubble sort algorithm for a list of
integers.
Ans PYTHONPYTHON
f) Write a python program to print the words in a string which starts with the alphabet 3
‘T’ or ‘t’.
Eg: For the string – ‘The tiger kept his kill in tree’ we shall get output as
The
Tiger
Tree
[Or]
Write a python program to count the number of alphabets, numbers and special
characters in a given string.
Eg: For the string ‘Happiest year 2019 is @ ending’ the output will be
20 4 6
Ans st = 'The tiger kept his kill in tree'
lst = st.split()
for x in lst:
if x.startswith('T') or x.startswith('t'):
print(x)
[Or]
s = 'Happiest year 2019 is @ ending'
c1,c2,c3=0,0,0
for x in s:
if x.isalpha():
c1+=1
elif x.isdigit():
c2+=1
else:
c3+=1
print(c1,c2,c3)
g) What are modules in python? 1
Ans Module is a python file containing a set of functions you want to include in your
application.
h) Do as directed: 2
i) What are the possible numbers generated from the python code below:
import random as r
num = r.randrange(1,5,2)
print(num)
ii) What will be the output of the following python code
import math
print(math.ceil(-3.5))
Ans i) Either 1 or 3
ii) -3
Q.3 a) Which of the following can be termed as Cyber Bullying: 1
i) Posting Rumors online
ii) Posting hate speech
iii) Posting sexual remarks
iv) All the above
Ans All the above
b) Mention two ways by which you can protect your online identity 2
Ans i) Properly manage your password
ii) Use Two-Factor Authentication
iii) Always keep your system updated
iv) Verify email validity before clicking on link
v) Do not divulge sensitive information
vi) Be careful while using public wi-fi
c) i) Name the popular micro blogging social networking website 2
ii) _________ is an American business and employment-oriented service that
operates via websites and mobile apps.
Ans i) Twitter
ii) Linkdin
d) What is a Trojan? 2
Ans A malware that misleads users as a genuine software and performs malicious
activities when activated.
e) _________ is the fraudulent attempt to obtain sensitive information such as 1
usernames, passwords and credit card details by disguising oneself as a trustworthy
entity in an electronic communication.
Ans Phishing
f) What is Eavesdropping? 2
Ans Eavesdropping is the act of secretly or stealthily listening to the private conversation
or communications of others without their consent.[1] The practice is widely
regarded as unethical, and in many jurisdictions is illegal.