0% found this document useful (0 votes)
4 views

25.07.2023 - 2 Programming for Problem Solving Using Python 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

25.07.2023 - 2 Programming for Problem Solving Using Python 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

GITA AUTONOMOUS COLLEGE, BHUBANESWAR

(Affiliated to BPUT Odisha)

2nd Semester B.Tech Regular / Back Examination 2023

Registration No.:

Subject : Programming For Problem Solving Using Python


Subject Code : 22BTTES205 / 21BTTES204
Branch: All
Time: 3 Hours
Full Marks: 60

Instructions:
Answer question No. 1 (Part I) any ten out of 12 bits, from (Part II) any five out of 7 bits
and any two from (Part III) out of 4 bits.
The figures in the right-hand side margin indicate marks

Part – I Marks
0 Short Answer Type Questions (Answer any ten out of twelve) (02 x 10) BL C PO &
1 O PSO
a) Find out errors if any, otherwise show the output: 2 1 2
x=str (input ("Enter the first no: "))
y=float (input ("Enter the second no:"))
z=complex (input (“Enter the third number”))
print(x+y)
print(y+z)
print(x+y+z)
b “Python is dynamically typed, interpreted, portable and rich in 2 1 2
) library language,” justify your answer with an example.
c) What will be the output of the following code snippet? 1 1 3
a = [0.95674, 23.89645, 30.890,” GITA”,” Python”]
a = tuple(a)
a[0:2] = (2,7,8)
print(a)
d Write a program to display all the keywords of python 3 2 1
) programming language.
e) What is nested tuple? How to input it from the keyboard. 2 2 2
f) Find out errors if any, otherwise show the output: 2 3 3
def f1(x):
global a
print("f1:",a)
def f2(y):
global b
print("f2:",b)
a=19
b=789
f1()
f2()
g) Write a statement in python to open a file named “data.txt” 3 4 1
which is present in the following location in your computer:
E drive ->New Folder->Python->GITA->First Year
in read mode
h 2 4 2
What is the difference between error and exception?
)
i) What is Encapsulation? Explain with examples. 4 5 1
j) Define Polymorphism? 2 5 2
k Find out errors if any, otherwise show the output: 2 2 3
) import random
l=('b','n','h')
u1=random.choice(l)
u2=random.choice(l)
if ((u1=="b' and u2=="n")or (u1=="n" and u2=="b")):
print("Bear is the strongest")
elif ((u1=="b" and u2=="h")or(u1=="h" and u2=="b')):
print("Hunter is the strongest")
elif ((u1=="n" and u2=="h") or (u1=="h" and u2=="n")):
print("Ninja is the strongest")
elif ((u1=='b' and u2=='b') or (u1=='n' and u2=='n')or (u1=='h'
and u2=='h')):
print("No one is strongest')
else:
print("Your option is wrong")
l) Define empty dictionary in Python and how to input it from 3 1 2
keyboard

Part – II Marks
0 Focussed – Short answer type Questions (Answer any five out (04 x 05) BL C PO &
2 of seven) O PSO
a) Write a Python program to check whether a number is 3 2 5
palindrome or not without using loop.
b Find out errors if any, otherwise show the output: 2 3 4
) def sum(a=12,b=90,c=34.5):
d=a+b+c
print("Sum is", d)
sum()
sum(18)
sum(13,34)
sum(14,56,78)
c) Write down various techniques to convert a list to tuple and 3 1 5
vice versa.
d Write a recursive program as fact() to find the factorial of given 2 3 4
) no.
Example: -
Input: ‘n’ value 5
Output: Factorial of 5 = 120
e) WAP to demonstrate constructor with default argument. 2 5 5
f) Write a Python class as revr(), that reverse a word and return 1 4 5
the reverse without using inbuilt function.
Example:
input value: “Bijupattanaik”
Return value of function: “kianattapujiB”
g) List all the types of operators supported by python language 1 1 5

Part – III Marks


Long Answer type Questions (Answer any two out of four) (10 x 2) BL C PO &
O PSO
0 a) Given the participant’s score sheet for your University Sports 2 1 4
3 Day, you are required to find the runner-up score. (Hint: -You are
given scores. Store them in a list and find the score of the runner-
up.)
b Fill in blanks (….) to complete the program, for to print the 1 2 3
) following in the output:
enter the number of rows:5
*
**
***
****
*****
def pyramid(….):
global m
i=n
if n>=1:
while m>=i:
print('*',end=….)
i=….
print()
n=….
pyramid(n)
else:
….
n=int(input("enter the number of rows:"))
m=n
pyramid(n)

0 a) Write a python program to append a new sentence i.e “I am a 2 4 5


4 student of GITA” in existing text file as ‘gita.txt’, without delete
the old data of the file.
b Write a program to display and count the words of a given string 3 3 4
) as well count the frequency of each word and their index
numbers.

0 a) Python program to remove spaces from string without using 1 3 5


5 inbuilt function.
b WAP to take a class as a polygon. Which will initialize the sides 2 5 4
) of triangle, rectangle, Rhombus. Take 3 classes as triangle,
rectangle, and rhombus to find the area using inheritance

0 a) Illustrate the concept of hard copy, deep copy, and shallow copy 3 2 4
6 in python.
b Write a python program to input your mobile number as string, 2 3 5
) and convert each digit in that string into word. Insert these words
sequentially into a list.
Hint: -
INPUT: ‘9867452390’
OUTPUT: L= [‘nine‘, ‘eight’,
‘six’,‘seven’,‘four’,’five’,’two’,’three’,’nine’,’zero’]

NB: BL – Blooms Level 1, 2, 3, CO – Course Outcome, PO – Program Outcome, PSO – Program Specific
Outcome

You might also like