0 votes
1 view
in Python by (120 points)

How to print the numbers given below without using any conditional statements? The set of numbers: var=01120221011202210112.

1 Answer

0 votes
by (115k points)

Here is the easiest way to print the number 01120221011202210112 without using conditional statements:



s = a+b+a+b+a+b


Explanation: If you observe, 10112022 pattern is repeating through the variable, So, initialize a as '1011' and b as '2022'. Concat a+b three times. After that sub-string the result string from 2nd character until the last 3rd character. 

If you are interested to learn Python, I would recommend this Python Training course Intellipaat which has experienced instructors, the best curriculum, and projects.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !