Problem 1
Calculate the cube of all numbers from 1 to a given number
Write a program to rint the cube of all numbers from 1 to a given number
Given:
input_number = 6
Expected output:
Current Number is : 1 and the cube is 1
Current Number is : 2 and the cube is 8
Current Number is : 3 and the cube is 27
Current Number is : 4 and the cube is 64
Current Number is : 5 and the cube is 125
Current Number is : 6 and the cube is 216
Problem  2 Display numbers from 10 to 1 using for loop
Expected output:
10
9
8
7
6
5
4
3
2
1
HINTS: 1
List item
*Iterate numbers from 1 to n
using for loop and range()
function
 In each iteration of a loop, calculate the cube of a current number (
i
) by multiplying itself three times (c = i * i* i)
Each and every batch can solve this problem and share your code with your friends
Regards
Utkarsh Kesharwani
2 Likes
i = int(input("Enter the limit of the range: "))
for num in range(1, i+1):
cube = num ** 3
print(â€śCube ofâ€ť, num, â€śisâ€ť, cube)
1 Like
Q 2
for i in range(10, 0):
print(i)
1 Like
Problem 1:
i=1
while i<=6:
print(â€śCurrent number is:â€ť,i,â€śand the cube is:â€ť, i * i * i )
i=i+1
Problem 2:
i=10
while i<=1:
print(i)
i=i+1
NOTE: It does not reflect space after while loop .
1 Like
Problem 1:
num=int(input(â€śinput_number:â€ť))
for i in range(1,num+1):
print(â€śCurrent Number is:â€ť,i,â€śand the cube isâ€ť,i**3)
Problem 2:
for i in range(10,0):
print(i)

for i in range(1,7):
print(â€śCurrent Number is:â€ť, i , â€śandâ€ť, â€śthe cube isâ€ť , i**3)

for num in range(10,0):
print(num)
Problem 1
=>while loop
i=1
while i<=6:
print(i,â€ś^â€ť,3,â€ś=â€ť,i**3)
i=i+1
Problem2
for i in range (10,0)
print(i)
for problem 1:
i=1
while i<=6:
cube=i**3
print(â€śCurrent number is:â€ť,i,â€śand the cube isâ€ť,cube)
i+=1
For problem 2:
for i in range(10, 0):
print(i)
for i in range(7):
print(â€śCurrent Number is:â€ť,i,â€śand the cube is:â€ť,i**3)
num=6
while num<=6
print(num,â€ś^ 3=â€ť,num**3)
num=num+1
Komal
num=1
while num<=6:
print(num,â€ś^â€ť,3.â€ś=â€ť,num**3)
Problem 1:
num=int(input(â€śinput_number:â€ť))
for i in range(1,num+1):
print(â€śCurrent Number is:â€ť,i,â€śand the cube isâ€ť,i**3)
Problem 2:
for i in range(10,0)
print(i)
Komal
Problem 2
for i in range(10,0):
print(i)
problem no.1
num=1
while num<=6:
print(num,â€ś^â€ť,3,â€ś=â€ť,num**3)
num=num+1
Problem 1 Cube of Number
n=int(input("enter the number range "))
for i in range(1,n):
print(â€śCurrent number is :â€ť, i ,â€śand the cube isâ€ť,i**3)
Problem2 Display numbers from 10 to 1 using for loop
for i in range(10,0) :
print(i)
problem 2
for num in range (10,0):
print(num)
#Write a program to find the cube of all numbers from 1 to a given number
num=int(input(â€śEnter the numberâ€ť))
for i in range(1,num+1):
print(â€śCurrent Number is :â€ť ,i, "and the cube is ",i**3)
#Display numbers from 10 to 1 using for loop
num=10
while num<=1:
print(num)
num+=1
1 Like
i=1
while i<=6:
print(â€śCurrent number is:â€ť,i,â€śand the cube is:â€ť, i * i * i )
i=i+1
Problem 2:
i=10
while i<=1:
print(i)
i=i+1
1 Like
welcome to community @almasafrudheen