📅  最后修改于: 2023-12-03 15:28:39.119000             🧑  作者: Mango
This is a programming question that was asked in the GATE CS 2021 examination. The question aims to test the programming skills of the candidates.
The question asks the candidates to write a program that takes two integers as input, a and b. The program should output the number of integers in the range [a, b] (inclusive) that have the digit 0 in their decimal representation.
Here is the code snippet in Python:
a, b = map(int, input().split())
count = 0
for num in range(a, b+1):
if '0' in str(num):
count += 1
print(count)
input()
function and split them using the split()
function. map()
function and assign them to the variables a
and b
.count
to 0.range()
function.num
in the range, we check if it contains the digit 0 in its decimal representation.count
variable.count
.In conclusion, this programming question from the GATE CS 2021 examination tests the candidate's programming skills. The solution involves taking two integers as input and iterating over a range to count the number of integers with the digit 0 in their decimal representation.