-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
142 lines (107 loc) · 2.93 KB
/
main.py
File metadata and controls
142 lines (107 loc) · 2.93 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# This is a sample Python script.
import enum
import turtle
from enum import Enum
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
# ==========================================================
# EXERCISE SOLUTION
# ==========================================================
# square solutions
#
# def square_turtle(tutle, size):
# for squares in range(4):
# tutle.forward(size)
# tutle.left(90)
# if squares == 3:
# sweet.penup()
# if squares > 3:
# continue
#
#
# turtle_screen = turtle.Screen()
# turtle_screen.bgcolor("lightgreen")
# sweet = turtle.Turtle()
# sweet.color("orange")
# sweet.pensize(5)
# sizes = 20
#
#
# for sides in range(5):
# square_turtle(sweet, 20)
# sweet.forward(50)
# sweet.pendown()
#
# turtle_screen.mainloop()
# ====================================================================
# SQUARE LIKE RIPPLE
def ripple_squares(the_square, sizes):
for ripple in range(4):
the_square.forward(sizes)
the_square.left(90)
# the_square.forward(sizes)
ripple_screen = turtle.Screen()
ripple_turtle = turtle.Turtle()
size = 10
for squares in range(4):
ripple_squares(ripple_turtle, size)
ripple_turtle.forward(60)
if squares >= 0:
size = size + 10
ripple_turtle.forward(90)
# ripple_turtle.left(90)
ripple_screen.mainloop()
def exam_mark(grade):
if grade >= 75:
return "FIRST"
elif grade >= 70:
return "UPPER SECOND"
elif grade >= 60:
return "SECOND"
elif grade >= 50:
return "THIRD"
elif grade >= 45:
return "F1 Supp"
elif grade >= 40:
return "F2"
else:
return "F3"
mark = exam_mark(48)
print(mark)
grade_points = [83, 75, 74.9, 70, 69.9, 65, 60, 59.9, 55, 50, 49.9, 45, 44.9, 40, 39.9, 2, 0]
def grade_mark(grade_point):
for grade in grade_point:
if grade >= 75.0:
return "FIRST"
elif grade >= 70.0:
return "UPPER SECOND"
elif grade >= 60.0:
return "SECOND"
elif grade >= 50.0:
return "THIRD"
elif grade >= 45.0:
return "F1 Supp"
elif grade >= 40.0:
return "F2"
else:
return "F3"
pass_mark = grade_mark(grade_points)
print(pass_mark)
what_is_abs = abs(3 - 11) + 10
print(what_is_abs)
def area(radius):
print(3.14159 * radius * radius)
area(3)
def absolute_value(x):
if x < 0:
print(-x)
else:
print(x)
absolute_value(5)