0% found this document useful (0 votes)
9 views4 pages

Module 2 Worksheet 3

Uploaded by

alokg0488
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)
9 views4 pages

Module 2 Worksheet 3

Uploaded by

alokg0488
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

Module 2 – Worksheet 3

Debugging Code Questions

[Link] 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:

[Link] 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:

[Link] 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()))
[Link](element, 15)
[Link](element,25)
[Link](element,35)
Printf(Fulllist)

Hint: Sample Input1


14 17 19
Sample Output1
14 17 19 15 25 35

Answer:

[Link] 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:

[Link] 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)
Hint: Sample Input1
6 7
Sample Output1
1
Explanation: Binary Representation of 6 = 110
Binary Representation of 7 = 111
LSB of 6 + LSB 0f 7 => 0 + 1 => 1
Answer:

[Link].6.
for i in range(0,21):
if i % 2!=0:
print(i)
What will be the output of the above program
Answer: 1

[Link].7. Identify the error?


def print_message()
message = "Hello, Debugging!"
print(message)

print_message()
Answer:

[Link].8. Identify the error?

def display_number():
print(num)
display_number()

Answer:

You might also like