The square of a number | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

The square of a number

How to write the code of it in python? The numberĀ nĀ is writtenĀ kĀ times. The resulting number is multiplied by itself. What is the result? Input The first number contains nonnegative integerĀ nĀ (nĀ ā‰¤Ā 777). The second line contains positive integerĀ kĀ (kĀ ā‰¤Ā 777). Output Print the resulting number. Input example #1 1 2 Output example #1 121 Input example #2 12 3 Output example #2 14692348944

3rd Nov 2017, 8:22 AM
Maria
Maria - avatar
5 Respostas
+ 8
a=int(input("Enter number:")) b=int(input("Enter repeats:")) print((int(str(a)*b)**2))
3rd Nov 2017, 8:42 AM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar
+ 14
Homework? If you need help for making it just google how to do it.
3rd Nov 2017, 8:31 AM
qwerty
qwerty - avatar
+ 10
@Pegasus Don't give the answer. Just give the hints.
3rd Nov 2017, 2:31 PM
qwerty
qwerty - avatar
+ 3
@110000, I didn't find the answer there
3rd Nov 2017, 8:35 AM
Maria
Maria - avatar
+ 2
There are two ways to do this. I am sure you would find it hard to follow up with the string method. I will post an easy trick soon.
3rd Nov 2017, 9:32 AM
Itz_Arnab
Itz_Arnab - avatar