-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lista_1_Joisa.py
106 lines (89 loc) · 2.37 KB
/
Lista_1_Joisa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#1
def somaFracao(t1,t2):
denominador=t1[1]*t2[1]
return ((denominador/t1[1])*t1[0]+(denominador/t2[1])*t2[0],denominador)
print(somaFracao((2,3),(4,5)))
#2
def maiorDivComum(a,b):
if a>b:
b,a=a,b
while b!=0:
a,b=b,a%b
return a
def simplificaFracao(t):
mdc=maiorDivComum(t[0],t[1])
return(int(t[0]/mdc),int(t[1]/mdc))
print(simplificaFracao((20,48)))
#3
def exibeNoFormatoFracao(fr):
print('\nFração:%d/%d'%(fr[0],fr[1]))
return
exibeNoFormatoFracao((3,5))
exibeNoFormatoFracao((7,8))
#4
def multiplos3e7(a,b):
simult=0
num_simult=[]
inicio=a
final=b
if inicio>final:
inicio=b
final=a
while inicio<=final:
if inicio%21==0:
simult+=1
num_simult.append(inicio)
inicio+=1
t=tuple(num_simult)
return (simult,t)
print(multiplos3e7(30,11))
print(multiplos3e7(10,50))
#5
def ImpostoPlus(val_compra,val_venda):
lucro=val_venda-val_compra
if lucro<0.1*val_compra:
imposto=(2/100)*lucro
elif lucro>=0.5*val_compra:
imposto=0.4*lucro
elif lucro>=0.3*val_compra:
imposto=0.2*lucro
elif lucro>=0.1*val_compra:
imposto=(5/100)*lucro
if imposto<500:
parcela=1
elif imposto<2000:
parcela=2
else:
parcela=4
val_parcela=imposto/parcela
return (imposto,parcela,val_parcela)
print(ImpostoPlus(10,50))
#6
def antesDe(t1,t2):
if t1[0]>t2[0]:
return False
elif t1[0]==t2[0]:
if t1[1]>=t2[1]:
return False
return True
def depoisDe(t1,t2):
if t1[0]<t2[0]:
return False
elif t1[0]==t2[0]:
if t1[1]<=t2[1]:
return False
return True
print(antesDe((18,16),(16,16)))
print(depoisDe((18,16),(16,16)))
#7
def entradaNoIntervalo(t,inicio,fim):
entraram=0
l_placas=[]
for el in t:
if antesDe(inicio,el[1])==True and depoisDe(fim,el[1])==True:
entraram+=1
l_placas.append(el[0])
tup=tuple(l_placas)
return (entraram,tup)
tcarros=(('LCG1122', (13,45)),('XON2323', (15,45)),('LAB3456', (11,22)),('KRS3333', (21,10)),('OTV9876', (19,23)),('KTU1876', (16,30)),('LBZ4321', (12,14)),('KOX5656', (10,20)))
print(entradaNoIntervalo(tcarros,(13,30),(17,10)))