CBSE Class 11 Computer Science Question 105 of 106

Python Fundamentals — Question 14

Back to all questions
14
Question

Question 14

Write a program to input a single digit(n) and print a 3 digit number created as <n(n + 1)(n + 2)> e.g., if you input 7, then it should print 789. Assume that the input digit is in range 1-7.

Solution
d = int(input("Enter a digit in range 1-7: "))
n = d * 10 + d + 1
n = n * 10 + d + 2
print("3 digit number =", n)
Output
Enter a digit in range 1-7: 7
3 digit number = 789
Answer