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
print ("hello world") |
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
num1 = int(input("Give me a number: ")) #Asks the user for a number | |
num2 = int(input ("Give me another number: ")) #Asks the user for another number | |
suma = num1+num2 #this is the variable for the sum of two numbers | |
resta= num1-num2 #this is the variable for the difference of two numbers | |
multi= num1*num2 #this ios the variable for the product of two numbers |
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
f=int(input("Give me the temperature in Farenheit that you want to convert to Celsius: ")) | |
c= 5*(f-32)/9 | |
print("The temperature in Celsius is: ", int(c)) ###i put the c in a parenthesis using an int so it gives the value without decimals | |
if c>=100: | |
print ("Water boils at this temperature") ###note that you have to ident this line in order for this to work |
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
print("We will calculate the sum of integers in the range you provide") | |
result= 0 | |
num1=int(input("Please give us the lower bound:")) | |
num2=int(input("Please give us the upper bound:")) | |
while num1>num2: | |
print ("User input error, please give us the numbers again") | |
num1=int(input("Please give us the lower bound:")) | |
num2=int(input("Please give us the upper bound:")) | |
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
#Gilberto Rogel García A01630171 | |
def fact(n): | |
n=n | |
a=1 | |
while (n>1): | |
a=a*n | |
n=n-1 | |
return (a) | |
x="y" |
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
#Gilberto Rogel García A01630171 | |
def triangles(size): | |
for r in range(1,size+1): | |
for c in range(1,r+1): | |
print("t", end="") | |
print() | |
for r in range(size-1,0,-1): | |
for c in range(1,r+1): | |
print("t",end="") | |
print() |
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
#Gilberto Rogel García a01630171 | |
def find_threes (list): | |
sum=0 | |
for x in range(0,len(list)): | |
if(list[x]%3==0): | |
#print(list[x]) | |
sum+=list[x] #sum=sum+list[x] | |
return (sum) | |
print("This program gives you the sum of all the numbers divisible by 3 in a list") |
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
#Gilberto Rogel García A01630171 | |
import statistics | |
def totalsum(list): | |
sum=0 | |
for x in range (0,len(list)): | |
sum+=list[x] | |
return (sum) | |
def average(list): | |
avrg=totalsum(list)/10 | |
return (avrg) |
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
#Gilberto Rogel García wsq14 estimating e | |
def calculate_e(precision): | |
x=precision | |
e=(1+1/x)**x | |
return (e) | |
precision=int(input("Give me the number of decimal points of accuracy that you want: ")) | |
print("The estimate e is: ",calculate_e(precision)) |
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
#Gilberto Rogel García wsq12 greates common divisor | |
def gcd(x,y): | |
if(x==y): | |
res=x | |
elif(x>y): | |
res=gcd((x-y),y) | |
else: | |
res=gcd(x,(y-x)) | |
return res | |
OlderNewer