Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c61aba2

Browse files
committed
add exemplo de livro e estudando junto
1 parent 1ef5809 commit c61aba2

File tree

6 files changed

+119
-0
lines changed

6 files changed

+119
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
# eu usei ipython para fazer esses codigos
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# coding: utf-8
2+
bob = ['bob smith', 39, 6000, 'software']
3+
sue = ['sue james', 52, 4000, 'hardware']
4+
bob
5+
sue
6+
bob[0].split()[-1]
7+
bob
8+
sue
9+
sue[2]*=1.25
10+
sue
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# coding: utf-8
2+
get_ipython().run_line_magic('ls', '')
3+
get_ipython().run_line_magic('run', '1-usingLists.py')
4+
people = [bob, sue]
5+
for person in people:
6+
print(person)
7+
8+
people[1][0]
9+
for person in people:
10+
print(person[0].split()[-1])
11+
person[2] *= 1.20 # dar a cada 20 porcento de aumento
12+
13+
for person in people: print(person[2])
14+
pays = [person[2] for person in people] # coletar todos os pagamentos
15+
pays
16+
pays = map((lambda x: x[2]), people)
17+
list(pays)
18+
sum(person[2] for person in people)
19+
people.append(['Tom', 50, 0, None])
20+
people
21+
len(people)
22+
people[-1]
23+
people[-1][0]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# coding: utf-8
2+
get_ipython().run_line_magic('run', '2-aDataBaseList.py')
3+
get_ipython().run_line_magic('ls', '')
4+
bob
5+
NAME, AGE, PAY = range(3)
6+
bob = ['Bob smith', 42, 10000]
7+
bob[NAME]
8+
PAY, bob[PAY]
9+
bob
10+
bob = [['name', 'bob smith'], ['age', 45], ['pay', 10000]]
11+
sue [['name', 'sue Jones'], ['age', 60], ['pay', 20000]]
12+
sue = [['name', 'sue Jones'], ['age', 60], ['pay', 20000]]
13+
bob
14+
jonas = [['jonas', 'teixeira'], ['age', 50], ['pay', 10000]]
15+
people
16+
people = [bob, sue, jonas]
17+
for person in people:
18+
print(person[0][1], person[2][1]) # nome a pegamento
19+
20+
jonas
21+
sue
22+
jonas = [['name', 'jonas teixeira'], ['age', 50], ['pay', 10000]]
23+
for person in people:
24+
print(person[0][1], person[2][1])
25+
26+
[person[0][1] for person in people]
27+
people
28+
people = [bob, sue, jonas]
29+
for person in people:
30+
print(person[2][1].split()[-1])
31+
person[2][1] *= 1.10
32+
33+
for person in people:
34+
print(person[2][1].split()[-1])
35+
36+
person[2][1] *= 1.10
37+
38+
for person in people:
39+
print(str(person[2][1]).split()[-1])
40+
person[2][1] *= 1.10
41+
42+
43+
for person in people:
44+
print(str(person[2][1]).split()[-1])
45+
#person[2][1] *= 1.10
46+
47+
48+
[person[0][1] for person in people]
49+
for person in people:
50+
for (name, value) in person:
51+
if name == 'name': print(value)
52+
53+
for person in people:
54+
for (name, value) in person:
55+
if name == 'name': print(value.title())
56+
57+
58+
def field(record, label):
59+
for (fname, fvalue) in record:
60+
if fname == label:
61+
return fvalue
62+
63+
field(bob, 'name')
64+
field(bob, 'pay')
65+
field(bob, 'age')
66+
for rec in people:
67+
print(field(rec, 'age'))
68+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from tkinter import *
2+
3+
Label(text='spam').pack()
4+
mainloop()
5+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from tkinter import *
2+
from tkinter.messagebox import showinfo
3+
4+
def reply():
5+
showinfo(title='popup', message='Botão foi apertado')
6+
7+
window = Tk()
8+
botao = Button(window, text='\n aperte \n', command=reply)
9+
botao.pack()
10+
window.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /