Created
September 27, 2014 03:33
-
-
Save raphamorim/2cf813a9d7a900ef8892 to your computer and use it in GitHub Desktop.
First exercise from a sequence of challenges
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import numpy as np | |
print "1 = Faca um algoritmo que troque o valor de duas variaveis. Por exemplo, o algoritmo le n1 igual a 3 e n2 a 17, e mostra n1 igual a 17 e n2 a 3." | |
print "2 = Faca um algoritmo para calcular a media de duas notas digitadas pelo usuario." | |
print "3 = Faca um algoritmo que calcule a area de um quadrado, sendo que o comprimento do lado e informado pelo usuario. A area do quadrado e calculada elevando-se o lado ao quadrado." | |
exerc = int(raw_input("Defina qual o numero do exercicio: ")) | |
if exerc == 1: | |
n1 = 2 | |
n2 = 10 | |
n3 = None | |
n3 = n1 | |
n1 = n2 | |
n2 = n3 | |
# Te-hehehe | |
print "number A is", n1 | |
print "number B is", n2 | |
elif exerc == 2: | |
arr = [None, None] | |
arr[0] = int(raw_input("Digite um valor: ")) | |
arr[1] = int(raw_input("Digite um valor: ")) | |
print "A media dos numeros e ", np.mean(arr) | |
elif exerc == 3: | |
l = int(raw_input("Digite o comprimento do lado do quadrado: ")) | |
print "A area do quadrado e ", l**2 | |
else: | |
print "Nao existe este exercicio fera!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment