-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod.py
More file actions
91 lines (73 loc) · 1.71 KB
/
method.py
File metadata and controls
91 lines (73 loc) · 1.71 KB
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
i = -20
print(abs(i))
f = -30.92
print(abs(f))
mylist = [1,2,3,0]
print(any(mylist))
"""
x=10
print(eval('x+1'))
exp = input("input arithmetic expression :")
print(eval(exp))
"""
s=[1,2,3,4]
print(sum(s))
def square(n):
return n*n
mylist=[1,2,3,4,5]
result = list(map(square, mylist))
print(result)
seasons = ['봄', '여름', '가을', '겨울']
print(list(enumerate(seasons, start=1)))
def myfilter(x):
return x>3
result = filter(myfilter, (1,2,3,4,5,6))
print(list(result))
numbers = [ 1 , 2 , 3 , 4 ]
slist = [ '하나' , '둘' , '셋' , '넷' ]
print ( list ( zip (numbers, slist)))
print(sorted([4, 2, 3, 5, 1]))
myList = [4, 2, 3, 5, 1]
myList.sort()
print(myList)
students = [
('Hong', 3.9, 20160303),
('Kim', 3.0, 20160302),
('Choi', 4.3, 20160301)
]
print(sorted(students, key=lambda student:student[0], reverse=True))
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
def __repr__(self):
return "<Name: %s, Age: %s>" % (self.name, self.age)
def keyName(person):
return person.name
def keyAge(person):
return person.age
people = [Person("Hong", 20), Person("Kim", 35), Person("Choi", 38)]
print(sorted(people, key=keyName))
list_a = [ 1, 2, 3, 4, 5 ]
f = lambda x : 2*x
result = map(f, list_a)
print(list(result))
list_a = [1,2,3,4,5,6]
result = filter(lambda x: x%2 == 0, list_a)
print(list(result))
def celsius(T):
return (5.0/9.0)*(T-32.0)
f_temp = [0, 10, 20, 30, 40, 50]
c_temp = map(celsius, f_temp)
print(list(c_temp))
def myGenerator():
yield 'first'
yield 'second'
yield 'third'
for word in myGenerator():
print(word)
import sys
import time
import calendar
cal = calendar.month(2024, 6)
print(cal)