Skip to content
Snippets Groups Projects
Commit f124450b authored by KimMinSeob's avatar KimMinSeob
Browse files

Upload New File

parent 1837eb26
Branches
No related tags found
No related merge requests found
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> #연습문제 1. 1부터 100까지 출력
>>> for i in range(1,101)
SyntaxError: invalid syntax
>>> for i in range(1,101):
print(i)
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
>>> #문제2. 5의 배수의 총합
>>> sum = 0
>>> for i range(1,100):
SyntaxError: invalid syntax
>>> for i in range(1,1000):
if i%5 == 0 :
sum=sum +i
>>> print(sum)
99500
>>> sum2=0
>>> for i in range(1,50):
if i%5 == 0 :
sum2= sum2+i
>>> print(sum2)
225
>>> #문제3. 학급의 평균 점수
>>> A = [70,60,55,75,95,90,80,80,85,100]
>>> sum = 0
>>> for i in A:
sum = sum + A[i]
Traceback (most recent call last):
File "<pyshell#25>", line 2, in <module>
sum = sum + A[i]
IndexError: list index out of range
>>> for i in A:
sum = sum +i
>>> print(sum)
790
>>> count = 0
>>> for i in A:
count = count+1
print(sum/count)
SyntaxError: invalid syntax
>>> count = 0
>>> sum =0
>>> for i in A:
count = count+1
sum = sum + i
>>> print(sum/count)
79.0
>>> #문제4. 각 혈액형별 학생수의 합계를 구하시오.
>>> B = ['A','B','A','O','AB','AB','O','A','B','O','B','AB']
>>> a=0
>>> b=0
>>> ab=0
>>> o=0
>>> for s in B:
if s=='A':
a=a+1
elif s==
SyntaxError: invalid syntax
>>> for s in B:
if s=='A':
a=a+1
elif s=='B':
b=b+1
elif s=='AB':
ab=ab+1
else:
o=o+1
>>> print(a,b,ab,o)
3 3 3 3
>>>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment