-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13.py
More file actions
32 lines (21 loc) · 723 Bytes
/
13.py
File metadata and controls
32 lines (21 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#Exercicio 13
#Faça um programa que peça dois números, base e expoente, calcule e mostre o primeiro número elevado ao segundo número. Não utilize a função de potência da linguagem.
#Exercício resolvido usando laço WHILE
print("base ^ expoente:")
base=int(input("Base: "))
expoente=int(input("Expoente: "))
potencia=1
count=1
while count <= expoente:
potencia *= base
count +=1
print(base,"^",expoente,"=",potencia)
#Exercício resolvido usando laço FOR
print("base ^ expoente:")
base=int(input("Base: "))
expoente=int(input("Expoente: "))
potencia=1
for count in range(expoente):
potencia *= base
count += 1
print(base,"^",expoente,"=",potencia)