(2 - 1) CSE1021 - Module 2 Worksheet (1)
(2 - 1) CSE1021 - Module 2 Worksheet (1)
Q.No.6. Choose the correct output for the following Python command: print(0 and 70)
a) 70
b) 0
c) True
d) None
Answer:
Q.No.7. Choose the correct output for the following Expression:
2+(5-4) * 2**10 // 5
a) 206
b) 204
c) -206
d) -204
Answer:
Q.No.8. When passing two arguments V1 and V2 to the function add(int, int) which one of
the following is not correct.
a) def add(V1,V2)
b) def add(V1,V2=7)
c) def add(*V1,V2)
d) def add(V1=5,V2=7)
Answer:
Answer:
Answer:
Fill in the Blanks
Q.No.1. Fill in the blank of the code the program should accept an integer list and it must
print the sum of the biggest and the smallest integer in the list.print( +
)
Hint: numList=list(map(int,input().split()))
Answer:
Q.No.2. ._______________ is the function used to print the ASCII Value of the given
character ch
Hint : Input : g
Output : 103
Answer:
Q.No.3. The program must accept the string S as the input and _____________ should print
the reverse of the given string
Hint : Input : Baseball
Output : llabaseB
Answer:
Q.No.4. The program must accept the price p as the input and it should print the output with
formatting upto 3 decimal places. _______________ statement is used to print the specified
output
Hint : Input : 33.8988
Output : 33.898
Answer:
Q.No.5. Mr. Prakash every day distributed pen (Pen) to the N number of students. The pens
distributed to the students equally and the remaining will be returned to Mr. Prakash.
________________ is used to find the number of pens returned to Mr. Prakash.
Hint : Sample Input1 : 100 Sample Input2 : 123
20 40
Sample Output1 : 0 Sample Output2 : 3
Answer:
Module 2 – Worksheet 2
Answer:
Answer:
Q.No.4. Converting the decimal Number into Binary
def convertBinary(number):
decimal = int(input())
convertBinary(decimal)
convertBinary(number//2)
if number > 1:
print(number % 2,end = '')
print()
Hint : Sample Input1 : 5
Sample Output1 : 101
Answer:
Programming Questions
Q.No 1 : If the name N of the athlete and the number of medals M won by the athlete in a
games tournament are passed as the input the program must print the message as N Won
M Medals
Hint : Input
Hema
7
Output
Hema Won 5 Medals
Answer:
Q.No 2 : Lakshmi went to saravana hyper market to buy house hold items. 10% discount
was provided by the saravana hyper market when the bill amount BA exceeds 2000. The
amount BA was passed as the input to the program. The Final Payable Amount PA should
printed as output
Hint : Sample Input1 Sample Input2
1900 3000
Sample Output1 Sample Output2
1900 2700
Answer:
Q.No 3 : The Length and Breadth of a rectangle are passed as the input. The program must
calculate the perimeter of the rectangle and print the perimeter as the output. Both the values
are positive integers.
Hint : Sample Input1
20
10
Sample Output1
60
Answer:
Q.No 4: Get three numbers A1, B1,C1 and Calculate the following equation B 2 + 4AC and
print the same.
Q.No 5 :Two Students have birthdays, they have A and B number of chocolates. The
chocolates have to be distributed among N students in such a way that each student receives
the same number of chocolates and no chocolates are remaining after distribution. If the
chocolates can be distributed as per the given conditions among the N students then print
the number of chocolates each student will receive. The program must print invalid if it cannot
be distributed.
Hint : Sample Input1 Sample Input2
50 40 50 40
30 20
Sample Output1 Sample Output2
3 invalid
Answer:
Module 2 – Worksheet 3
Q.No 1 : The input of the program was the bottom left coordinates of the square. The side
length of the square also passed as the input. The program should print the top right
coordinates of the square.
botlex = input()
botley = input()
sqlen = input()
toprix = botlex - sqlen
topriy = botley - sqlen
print(toprix)
print(topriy)
Hint: Sample Input1 Sample Input2
0 -10
0 -2
5 7
Sample Output1 Sample Output2
5 -3
5 5
Answer:
Q.No 2 : The integer value Hrs and Mins was passed as the input to the program. The
program must print the total number of seconds in the given hrs and Mins.
Hrs = input()
Mins = input()
Seconds = hrs * 60 / 60 + Mins * 60 * 60
Print(seconds)
Hint: Sample Input1
3
20
Sample Output1
12000
Explanation: 3 Hrs = 10800 + 20 * 60 = 1200 = 12000
Answer:
Q.No 3 : The list of integer was passed as the input to the program. The list should be
appended with the following values as constant (15,25,35) in the end. Then the program
must print all the integers with appended values.
FullList = Fulllist(map(int,input().spllit()))
FullList.Append(element, 15)
FullList.Append(element,25)
FullList.Append(element,35)
Printf(Fulllist)
Answer:
Q.No 4 : The integer N1 was passed as the input to the program. The program must print
average of the following (unit digit, tenth digit and hundred digits of N1) as the output
N1 = input()
Sum =0
Sum = N1/100 + (N1%10) %10 + (N1%100) %10
Avg = Sum/3.0
Print(Avg)
Hint: Sample Input1
4535
Sample Output1
4.333
Answer:
Q.No 5 : The integer N1, M1 was passed as the input to the program. The program must
give the output as the addition of the LSB in the binary representation of N1 and M1.
Note : LSB – Least Significant Bit
N1 = input()
M1 = input()
Print(N1/2 + M1/2)
Q.No.6.
for i in range(0,21):
if i % 2!=0:
print(i)
What will be the output of the above program
Answer:
Q.No.7. Identify the error?
def print_message()
message = "Hello, Debugging!"
print(message)
print_message()
Answer:
def display_number():
print(num)
display_number()
Answer: