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

t2 a Qp Python-i Sem-III 2022

This document is a test paper for B.E. Semester-III students at L.J. Institute of Engineering and Technology, covering the subject 'Fundamentals of Computer Science using Python - I'. It includes various programming questions related to Python code outputs, lambda functions, and string manipulations, along with practical programming tasks. The test is scheduled for January 2, 2023, with a total duration of 2.25 hours and a maximum score of 25 marks.

Uploaded by

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

t2 a Qp Python-i Sem-III 2022

This document is a test paper for B.E. Semester-III students at L.J. Institute of Engineering and Technology, covering the subject 'Fundamentals of Computer Science using Python - I'. It includes various programming questions related to Python code outputs, lambda functions, and string manipulations, along with practical programming tasks. The test is scheduled for January 2, 2023, with a total duration of 2.25 hours and a maximum score of 25 marks.

Uploaded by

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

Enrollment No:

L. J. UNIVERSITY Set: Z
L.J. INSTITUTE OF ENGINEERING AND TECHNOLOGY, AHMEDABAD
TEST 2
B.E. SEMESTER-III BRANCH: CE/IT/CSD/AIML/AIDS/RAI/CSE
SUBJECT- FUNDAMENTALS OF COMPUTER SCIENCE USING PYTHON - I
SUBJECT CODE: 017012391,017022391,017032391,017042391,017052391,017062391,017122391
DATE: 02-Jan-23 DURATION: 2.25 Hours
TIME: 03:30 PM To 05:45 PM MAX MARKS: 25 marks
Instructions
* All questions are compulsory.
* Figure to the right indicates marks
* Assume suitable additional data if necessary and mention them.

Q-1 A)

1) What will be the output of the following Python code? [0.5]


def function1(var1=7,var2=5):
var1=2
var3=var1*var2
return var3
var2=6
var1=3
print(function1(var1,var2))

a) 15 b) 25 c) 10 d) 18 e) Error as var2 is not defined while


calling the function f) 42 g) 12
2) What will be the output of the following Python code? [0.5]

def current_date(**kwargs):
for i in kwargs:
print(i)
current_date(date=2-1-2023)

a) 2-1-2023 b) i c) date=2-1-2023 d) date e) date:2-1-2023


f) kwargs g) None of Above
3) What will be the output of the following Python code? [0.5]
x = 'abcd'
for i in x:
i.isupper()
print (x)
a) ABCD b) 0 1 2 3 c) Error d) abcd
e) A f) Abcd g) none of mentioned
B
C
D
4) What will be the output of the following Python code? [0.5]
t=(1,2,4,3,6,8,4)
t[1:-1:-1]

a) (2,4,3,6,8) b) (2,1) c) (8,6,3,4,2,1) d) ()


e) (2,4,3,6,8,4) f) (4,8) g) Error
5) What will be the output of the following Python code? [0.5]

my_tuple = (1, 2, 3, 4)
my_tuple.append( (1,2,3) )
print (len(my_tuple))

a) 4 b) 7 c) 5 d) 1
e) 2 f) 3 g) Error
6) What will be the output of the following Python code? [0.5]
def writer():
title = 'Sir'
name = (lambda x: title + ' ' * 2x)
return name
who = writer()
print(who('Arthur'))

a) Sir Arthur Sir Arthur b) ArthurSir c) Arthur Sir d) SirArthurSirArthur


e) Arthur f) Sir Arthur Arthur g) Syntax Error
7) What will be the output of the following Python code? [0.5]
def fun(a=5,b=10,c):
print(a**2,b//a,c**1)
fun(20,c=30)

a) 400 1 5 b) 400 4 5 c) 25 2 5 d) 25 2 30 e) 25 4 30
f) Syntax Error g) 400 2 30
8) What will be the output of the following Python code? [0.5]

i = [10, 11, 12, 13]


for i[-2] in i:
print(i[-2] ,end=" ")

a) 10 11 11 13 b) 10 12 12 13 c) 12 d) 12 13
e) 10 11 12 13 f) Attribute error g) Syntax Error
Q-1 B)

1) Following Lambda function series can be used to find __________. [01]


from functools import *
Series = lambda n: reduce(lambda x, _: x + [x[-1] + x[-2]], range (n-2) , [0,1])
a) The geometric series b) Fibonacci Series
c) Sum of two consecutive numbers in a list d) sum of first two numbers in a list
e) sum of last two numbers in a list f) sum of odd numbers of a list
g) Syntax error
2) What will be the output of the following Python code? [01]

a = [5,5,6,7,7,7]
b = set(a)
def test(lst):
if lst in b:
return 1
else:
return 0
for i in filter(test, a):
print(i,end=" ")

a) 1 b) 5 6 7 c) 0 d) 5 5 6 7 7 7
e) 5 5 6 f) 5 6 7 7 7 g) Error
3) What will be the output of the following Python code? [01]

s1={3, 4}
s2={1, 2}
s3=set()
i=0
j=0
for i in s1:
for j in s2:
s3.update((i,j))
i+=1
j+=1
print(s3)

a) {1,2,3,4,5} b) {(4, 2), (5, 2)} c) {(3, 1), (4, 2)}


d) {(3, 1), (4, 1), (4, 2), (5, 2)} e) {(3, 1), (4, 1), (4, 2), (5, 3)}
f) {1,2,3,4} g) Error
4) What will be the output of the following Python code? [01]

def enc(st):
encoded=""
c=1
ld=st[0]
for i in range (1,len(st)):
if ld==st[i]:
c=c+1
else:
encoded=encoded+str(c)+ld
c=0
ld=st[i]
c=c+1
encoded=encoded+str(c)+ld
return encoded
st="AAABBACCAA"
print(enc(st))
a) 3A2B1A3C2A b) AAABBACCAA c) A3B2A1C3A2 d) 3A2B1A2C2A
e) A3B2A1C2A2 f) 10 g) Error
5) What will be the output of the following Python code? [01]
names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print(sum)

a) 12 b) 11 c) 32 d) 33 e) 22 f) 21 g) 20
6) What will be the output of the following python code? [01]
car=20
bike=10
cycle=30
def new_Pur():
global bike,cycle
car=30
bike=20
cycle=50
new_Pur()
print(car+10," ",bike+5," ",cycle+5)

a) 40 25 55 b) 30 15 35 c) 30 25 35 d) 20 25 55
e) 25 20 50 f) 30 25 55 g) Syntax Error
Q-2 1) Write a Python programme that accepts a string and calculate the number of uppercase [03]
letters, lowercase letters and number of digits.
For example,

Input: Hello Pyth@n is 100% easy

Output:

Uppercase letters : 2
Lowercase letters : 14
Digits : 3

2) Write a Python program using function to shift the decimal digits n places to the left, [03]
wrapping the extra digits around. If shift > the number of digits of n, then reverse the string.
Note:
Function will take two parameters:
1. The number
2. How much shift user want
Example:
Input: n=12345 shift=1
Output: Result=23451

Input: n=12345 shift=3


Output: Result=45123

Input: n=12345 shift=5


Output: Result=12345

Input: n=12345 shift=6


Output: Result=54321
Q-3 A digital image in a computer is represented by a pixels matrix. Each image processing [09]
operation in a computer may be observed as an operation on the image matrix. Suppose you
are given an N x N 2D matrix A (in the form of a list) representing an image. Write a
Python program to rotate this image by 90 degrees (clockwise) by rotating the matrix 90
degree clockwise. Write proper code to take input of N from the user and then to take
input of an N x N matrix from the user. Rotate the matrix by 90 degree clockwise and
then print the rotated matrix.

Note: You are not allowed to use an extra iterable like list, tuple, etc. to do this. You
need to make changes in the given list A itself. Your program should be able to handle
any N x N matrix from N = 1 to N = 20.

Examples:
ALL THE BEST

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy