-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathz026.py
More file actions
executable file
·56 lines (46 loc) · 1.07 KB
/
z026.py
File metadata and controls
executable file
·56 lines (46 loc) · 1.07 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
#!/usr/bin/env python
import math as m
class robot:
def __init__(self):
self.x = 0
self.y = 0
# self.x = x
# self.y = y
def position(self):
print("os x: ", self.x)
print("os y: ", self.y)
def left(self, n):
if type(n) is not type(int()):
n = round(n)
self.x -= n
print("LEFT ", n)
def right(self, n):
if type(n) is not type(int()):
n = round(n)
self.x += n
print("RIGHT", n)
def up(self, n):
if type(n) is not type(int()):
n = round(n)
self.y += n
print("UP ", n)
def down(self, n):
if type(n) is not type(int()):
n = round(n)
self.y -= n
print("DOWN ", n)
def distance(self):
print(
"Distance from (0,0) to ({},{}) is: {}".format(
self.x, self.y, m.sqrt(self.x ** 2 + self.y ** 2)
)
)
# n = input("Type some number: ")
r = robot()
r.position()
r.up(5)
r.down(3)
r.left(3)
r.right(2)
r.position()
r.distance()