- 3
Read 7 numbers and print their squares and cubes
please tell asap
10 Antworten
+ 1
why cant you start yourself? If you try and post your attempted code, ill help you.
+ 1
i=0
while i<7:
x=int(input("enter number 1"))
square=x**2
cube=x**3
print("squares and cubes are:".square,cube)
i=i+1
0
print("/n".join([f"{int(el)**2}, {int(el)**3}" for el in input("Numbers: ").split()]))
0
Show your attempt first
0
i was not able to stary
0
start
0
plz tell
0
now help
what is wrong
0
well, youre looping your input, requiring you to place every individual number on 7 different lines. Lets just split the numbers from 1 input by whitespace.
n = [int(i) for i in input().split()]
if len(n)==7:
for x in n:
square=x**2
cube=x**3
print("squares and cubes are:",square,cube)
sample input
1 2 3 4 5 6 7
0
gotcha
thnx