def Richter(r): """ Assignment Python HW, pt. 1: Ritcher Andrew Noah Woodlee ENG 101-06 Due Date: 11-10-19 ******* """ E=[] T=[] j=0 print('Richter measurement \t Energy in Joules \t TNT') for i in r: E.append(10**((1.5*i)+4.8)) #Calculates energy in Joules T.append(E[j]*4.184*10**9) #Calculates tons of TNT print('%-20f \t %-20e \t %-20e' %(i,E[j],T[j])) j+=1 return E,T def RPSGame(): import random as ran w=['r','p','s'] cpu=ran.choice(w) Cwin=0 Uwin=0 Draw=0 #s=input('Please choose a wepon (r, p, or s) or q to quit. The game has begun; prepare to face your doom: ').lower() while Cwin<3 and Uwin<3: s=input('Please choose a wepon (r, p, or s) or q to quit. The game has begun; prepare to face your doom: ').lower() if s=='q': print("Goodbye") return elif (s=='s' and cpu=='r') or (s=='s' and cpu=='p') or (s=='p' and cpu=='s'): print("I win!") Cwin+=1 elif (s=='r' and cpu=='s') or (s=='p' and cpu=='s') or (s=='s' and cpu=='p'): print("You win.") Uwin+=1 elif s==cpu: print("Tie") Draw+=1 print("Wins:",Uwin) print("Draws: ",Draw) print("Losses: ",Cwin) def num_roman(num): """ Python Homework 1, pt. 3 Andrew Noah Woodlee ENG 101-06 Due date: 11-12-19 nun_roman(x) Input: num should be a scalar between 1-3999 Output: rn is a Roman numeral string """ rn='' if num=='': rn+='MMXIX' elif isinstance(num, list): print("num must be a scalar!") return elif num<1: print('Please enter a positive number!') return elif num>3999: print("num can not be greater than 3999!") return else: num==int(num) while num>=1000: num-=1000 rn+="M" if num>=900: num-=900 rn+="CM" if num>=500: num-=500 rn+="D" if num>=400: num-=400 rn+="CD" while num>=100: num-=100 rn+="C" if num>=90: num-=90 rn+="XC" if num>=50: num-=50 rn+="L" if num>=40: num-=40 rn+="XL" while x>=10: x-=10 rn+="X" if num>=9: num-=9 rn+="IX" if num>=5: num-=5 rn="V" if num>=4: num-=4 rn+="IV" while num>=1: num-=1 rn+="I" return rn def Epieces(x,y): """ Python HW1, pt. 4: Epieces Andrew Noah Woodlee ENG 101-06 Due Date: 11/12/19 Epieces(x,y) Input: x and y are arrays of equal length Output: The first output is an array of various calculations on the first array The second is the average of the output array The third output is the index number of the x input minimum """ import math as m import statistics as stats if len(x)!=len(y): print("Arrays must be equal in length.") n=len(x) a=[] for i in range(0,n): if y[i]=='A': a.append(m.degrees(m.atan(x[i]))) if y[i]=='B': a.append(m.sqrt(1+x[i]**2)) if y[i]=='C': a.append(m.factorial(m.ceil(x[i]))) if y[i]=='D': a.append(m.log2(x[i])) if y[i]!='A' or y[i]!='B' or y[i]!='C' or y[i]!='D': a.append(2*i) b=stats.mean(a) c=x.index(min(x)) print("a = ",a) print("b = ",b) print("c = ",c)