Created
April 16, 2015 15:43
-
-
Save gilrg18/31fb03afe3a64c54ede5 to your computer and use it in GitHub Desktop.
Quiz09
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
#Distance between two points Gilberto Rogel García | |
#Gilberto Rogel García | |
import math | |
def distancia(x1,y1,x2,y2): | |
a=x2-x1 | |
b=y2-y1 | |
dis=math.sqrt((a*a)+(b*b)) | |
return (dis) | |
x1=int(input("x1:")) | |
y1=int(input("y1:")) | |
x2=int(input("x2:")) | |
y2=int(input("y2:")) | |
d=distancia(x1,y1,x2,y2) | |
print ("The distance between your points is:",d) |
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
#Triangle Gilberto Rogel García | |
def triangles(size): | |
for x in range(1,size+1): | |
for y in range(1,x+1): | |
print("t", end="") | |
print() | |
for x in range(size-1,0,-1): | |
for y in range(1,x+1): | |
print("t",end="") | |
print() | |
print("This program makes a triangle using your number as the middle length") | |
size=int(input("Give me a number:")) | |
while (size<0): | |
print("Can't do it with negative numbers") | |
size=int(input("Give me a positive number:")) | |
t=triangles(size) |
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
#Superpower Gilberto Rogel García | |
def superpower (a,b): | |
x=a | |
y=1 | |
while (y<b): | |
a=a*x | |
y=y+1 | |
return (a) | |
a=int(input("Give me a number:")) | |
b=int(input("Give me another number:")) | |
print (superpower(a,b)) |
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
#Fibonacci Gilberto Rogel García | |
def fib(n): | |
if(n==1 or n==0): | |
return (n) | |
return(fib(n-2)+fib(n-1)) | |
n=int(input("Give me a non negative number:")) | |
while (n<0): | |
print("NON NEGATIVE please") | |
n=int(input("Give me another number:")) | |
fi= fib(n) | |
print("El fibonacci de tu num es:",fi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment