SW Expert Acadamy: Python

2020. 2. 13. 23:32Python/Programming

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
# -*- coding: utf-8 -*-
 
str_1 = "Hello, World"
str_2 = 'hello, world'
str_3 = "150"
 
int_1 = 3
float_1 = 3.5
 
# print(int(str_3))
# print(str(int_1))
 
list_1 = [123'a''b''c']
tuple_1 = (456'd''e''f')
dict_1 = {
    "name""eunhwan",
    "age"27,
    "len"170,
}
 
# print('%s is %d years old' % (dict_1['name'],dict_1["age"]) )
 
def add(num1, num2):
    res = num1 + num2
    return res
 
# print(add(1, 2))
 
class Person:
    def __init__(self,name,age):
        self.name = name
        self.age = age
 
    def sayHi(self):
        print("""
        hello
        I am %s""" % self.name)
 
p1 = Person('eunhwan',25)
p2 = Person('kyodong',25)
 
 
list_2 = [5,2,3,1,4]
 
list_2_sorted = sorted(list_2, reverse=False)
print(list_2)
print(list_2_sorted)
print("리스트 길이 : " + str(len(list_2)))
print("요소들의 합 : " + str(sum(list_2)))
print(list_2)
if 6 in list_2:
    list_2.remove(6)
print(list_2)
 
class Hacker(Person):
    def __init__(self, name, age,national):
        Person.__init__(self,name, age)
        self.national = national
 
= Hacker('eunhwan',25,'Korea')
h.sayHi()
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter