Probelm Solving Using Python End Sem
Probelm Solving Using Python End Sem
NAVRACHAMA
LukeUNIVERSITY
School: School of Engincering&Technology (SET)
P'rogram/s: B. Tech (C'SE)
Year:I Semester:
xamination: nd-Sennester Examinalion
Examination Ye:ar: May, 2024
Course Code: (S193 Course Name: Problem Solving using Python
Date: 17-Mav-2024 Total Marks: 40
Time: l1:00 am to01:00 pm Total Pages: 4
Instructions:
’Use of anon-programmable and non-gaphic scientific or general calculator isnot permitled.
’*COs=Cowse Outcome mapping. # BTL=Bloom's Taxonony Level mapping
’ Wriie each question on neN page.
’ Atemplall the questions and sub-questions sequentially in the ascending order.as given in the
question paper:
> Rough workis bedone at the last page of themain answer-book
1.3: Which of'the following operations are not pemitted ona string?
Page: l of4
(Selectone or more options as applicalble)Given: strl s str2
"'second
(A) strl|0)
(B)srl strl|0].upp)
(Osulower)
(D) sr2.capitalize)
14:\Which of the following expressions (may be one
are not valid)
or more than onc)
(A) 25-7*8/2
(B)--17
(C) S not- 7
(D) 6&-8
1.5: sl=}
sl[], sl[2] - (11, 12)
Which one of the following statements is
not exactly true?
(A) sl is a set
(B) 11 is the second value of s1,
because index in Python starts witlh 0
(C) 12 is the second value of sl
(D) Left-side of '= in the 2nd statement
is not tuple while the right-side
is a tuple.
1.6: d={0: 10, 1:21}
for x, v in d.keys(), d.values():
print (x, V, end =*")
Which one of the following statements is true?
(A) There will be an error in this
program.
(B) 0 110 21 willbe printed
(C) type(d) will display <class 'set'>
(D) 010121 will be printed
1.7: Which one of the following statements is not
valid for a list.
(A) A list can be an element of a list.
(B) A list can be an element of a tuple.
(C)A list can be a value in a dictionary.
(D) Alist can be an clement of a set.
Page: 2 of 4
written: Line-1: The Error/s;
Output/s Line-2: Correction/s; and Line-3:
The ,3
Find error/s, if any in the
ollowing expressions / prograins, correct
error/s, and writc the output. (Atempt any our), Condition: No valuc he
should be/get deletcd.
2.1: setI 1,2, |3, 4, 5), (6, 7), "atb- c"}. Condition: len(set) should
not change
2.2: ('a', 'b','c) +(|) +(2.3)
2.3: ('a'. b', c]+[||+(2, 3)
2.4: ||: 'one', 2: lwo', 3: 'thrce', 4: four', 1: One', 3:*Thrce"}
2.5:"123"+(6.7)" +|"8,9")
Q.3 08 CO
31: Which data structures in Python does not support indexing? Write
1, 3
the characteristics of such a data structure. Characteristics should
include (a) lypes of clements supported, (b) any restrictions on its
elements. (c) at least 3 operations (functions) permissible on the data
structur, and (d) what opcrations (functions) are not permitted"?
3.2: (a) Write at least 3 opcrations (functions) other than min(), max().
function
sum), etc supported by a tuple. Briefly explain what each
does. (b) Write at least 2 operations /functions which are not supported
by a tuple. Give possible reasons for these operations not being
supported by a tuple.
08 CO 3
Q.4 Write a program for any two of thefollowing: 2, 3
Output should
4.1: Input is a positive integer to be accepted from auser.
be (a)Count of number of digits in the given number, and (b) Sum of
digits in the given number. Do not use str), len() functions. Example:
17
Input: 37 142; Output: Count of digits=5, Sum of digits =
Output should
4.2: Input is a positive integer to be accepted from a user.
integer in the reverse order of the given number. Do not use str).
be an
len() functions. Example: Input: 37142; Output: 24173
4.3: Find the sum of the following series:
S=|-2+3-4 +5-6+ ... up to nterms, n > 5(to be
acccpted from auser)
08 CO 3. 4
Q.5 Writea programfor any oneof the following parts:
3, 4
5.1:Acccpt afloat (decimal) number consisting of digits 1l to 9 fromn a
user (do not include 0 in the decimal part). Outputs: (a) Whole part and
Decimal Part; (b) Count thc number of decinal digits and sum of
Page: 3of 4
decimal digits. Exanple: Input: 5794.21368; Outputs: (a) Whole part
5794, Decimal part 21638; (b)Count of decimal digits - 5; sum of
deciinal digits 20
Hint-1: Take int() and subtract to get Decimal Part (decl ); add
0.00000001. Wint-2: Multiply by 10 to get dccimal part's digits. Hint-3:
Loop condition: deel < l and decl>0.09