Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

COMSATS Institute of Information Technology

Department of Computer Science


Introduction to ICT (CSC101)
QUIZ-2
Class: BSCS – 1B Marks: 05
-----------------------------------------------CLO-4------------------------------------------
Question
Given a three digit number, print its digits in reverse order and sum them.

digits = int(input("Enter a three digit number: "))


m = digits % 10
n = digits // 10
o = n % 10
p = n // 10
print(f"reverse_num is {m, o, p}")
sum = (m + o + p)
print(f"sum of the digits is {sum}")

Run:
Enter a three digit number: 567
reverse_num is (7, 6, 5)
sum of the digits is 18

You might also like