30 Day code challenge-python

Ganesh Uthiravasagam
1 min readMar 12, 2021

--

Day 5— Loops

Task

Given an integer, n, print its first 10 multiples. Each multiple n * i (where 1≤ i ≤ 10) should be printed on a new line in the form: n x i = result.

Sample input and output

Input Format

A single integer, n.

Output Format

Print 10 lines of output; each line i (where 1≤ i ≤ 10 ) contains the result of n x iin the form:
n x i = result.

Solution

Explanation

Line 1: Gets input from the user

Line 2: for loop is generated to multiply the value of the input from 1 to 10

Line 3: Finally, based on the output format the value is printed. Since we can only add strings, int values are type casted to string

Bonus Tip: We can also step through even and odd values of i eg: range(1, 11, 2) gives only the even values.

See you on day 6

--

--

No responses yet