Ejercicios de Programacion
Ejercicios de Programacion
Ejercicio 6.
import cmath
d = (b**2) - (4*a*c)
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)
if usuario == 1:
if usuario == 2:
elif usuario == 3:
c= "*"
if usuario == 0:
else:
x,tyu=str(y),print("\n")
import sys
def
num1wrd(x,w={0:"",1:"One",2:"Two",3:"Three",4:"Four",5:"Five",6:"Six",7:"Seven",8:"Ei
ght",9:"Nine"},f={2:"Twen",3:"Thir",4:"For",5:"Fif",6:"Six",7:"Seven",8:"Eigh",9:"Nin
e"},t={11:"Eleven",12:"Twelve",13:"Thirteen",14:"Fourteen",15:"Fifteen",16:"Sixteen",
17:"Seventeen",18:"Eighteen",19:"Nineteen"}):
if len(x)==1:return(w[int(x)])
elif len(x)==2:
if int(x) in range(11,20):return(t[int(x)])
elif int(x[1])==0:
if int(x)==10:return("Ten")
else:return(f[int(x[0])]+"ty")
else:return(f[int(x[0])]+"ty"+"-"+w[int(x[1])])
def
hun_num(x,w1={0:"",1:"One",2:"Two",3:"Three",4:"Four",5:"Five",6:"Six",7:"Seven",8:"E
ight",9:"Nine"}):
a1=(x[1]+x[2])
else: return(num1wrd(x))
out.insert(0, s[-3:])
s = s[:-3]
return out
def q(x):
if x=="000":return(0)
elif x=="00":return(0)
elif x=="0":return(0)
else:return(1)
aa,v={0:"",1:"Thousand",2:"Million",3:"Billion",4:"Trillion",5:"Quadrillion",6:"Quint
illion",7:"Hextillion",8:"Septillion",9:"Octillion",10:"Nonillion",11:"Decillion",12:
"Undecillion",13:"Duodecillion",15:"Quattuordecillion",16:"Quindecillion",17:"Hexdeci
llion",18:"Septdecillion",19:"Octodecillion",20:"Novemdecillion",21:"Vigintillion",14
:"Tredecillion",22:"Unvigintillion",23:"Duovigintillion",24:"Trevigintillion",25:"Qua
ttuorvigintillion",26:"Quinvigintillion",27:"Hexvigintillion",28:"Septvigintillion",2
9:"Octovigintillion",30:"Novemvigintillion",31:"Trigintillion",32:"Untrigintillion",3
3:"Duotrigintillion"},seg3(x)
else:
s1=""
s=s1[:len(s1)-3]
print("》 "+s+".")
Ejercicio 7.
if usuario > usuario_2 and usuario > usuario_3 and usuario > usuario_4 and
usuario > usuario_5:
elif usuario_2 > usuario and usuario_2 > usuario_3 and usuario_2 > usuario_4 and
usuario_2 > usuario_5:
elif usuario_3 > usuario and usuario_3 > usuario_2 and usuario_3 > usuario_4 and
usuario_3 > usuario_5:
elif usuario_4 > usuario and usuario_4 > usuario_2 and usuario_4 > usuario_3 and
usuario_2 > usuario_5:
elif usuario_5 > usuario and usuario_5 > usuario_2 and usuario_5 > usuario_3 and
usuario_5 > usuario_4:
Ejercicio 6.
if numero1 >= 0:
factorial = 1
if numero1 == 0 or numero1 == 1:
factorial = 1
else:
factorial *= i
if numero2 >= 0:
factorial2 = 1
if numero2 == 0 or numero1 == 1:
factorial2 = 1
else:
factorial2 *= i
print ()
calculo = factorial/factorial2
print (calculo)
Ejercicio 7.
#Write a program that calculates N!*K!/(N-K)! for given N and K (1 < K < N)
if numero1 > 0:
factorial = 1
if numero1 == 0 or numero1 == 1:
factorial = 1
else:
factorial*= i
if numero2 >= 0:
factorial2 = 1
if numero2 == 0 or numero1 == 1:
factorial2 = 1
else:
factorial2*= i
print (calculo)
Ejercicio 10.
print ("\n")
print ("")
print (matriz)
Ejercicio 12.
contenedor = numero_decimal
numero_binario = 0
multiplicador = 1
while numero_decimal != 0:
numero_decimal //= 2
multiplicador *= 10