-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_structures.py
More file actions
78 lines (65 loc) · 1.57 KB
/
basic_structures.py
File metadata and controls
78 lines (65 loc) · 1.57 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
#
# Copyright Nate Stone 2023
#
# BSD License
#
#
# Usage: python3.10 basic_structures.py [-h|-g] [name]
#
#
# https://github.com/Makeblock-official/PythonForMegaPi
# https://support.makeblock.com/hc/en-us/articles/1500012868722-Program-mBot-Mega-with-Raspberry-Pi-in-Python
# https://gist.github.com/xeecos/5fa6cb5876a8c9449562d8026942fff1/revisions
# https://gist.github.com/xeecos/0a326e03f44633fed726867b0e71a3fe
# https://gist.github.com/xeecos/ceeb8fd83cc15b4e83b713bb75a982fd
#
#
# Firmware
# https://mblock.makeblock.com/en-us/download/
# https://support.makeblock.com/hc/en-us/articles/1500013010242
# https://ide.mblock.cc/
#
#
import sys
import math
import numpy as np
import cyberpi
#from makeblock import MegaPi,SerialPort
#print(sys.argv[1])
#print(sys.argv[2])
# Check if the user input the correct number of inputs
if (len(sys.argv) != 3):
print("usage: python3.10 basic_structures.py [-h|-g] [name]")
quit()
opt = sys.argv[1]
person = sys.argv[2]
# Greeting Function
def greeting(greetingType):
i = 0
while i < 12:
i = i + 1
print(greetingType + ", " + person + "! (" + str(i) + ")")
# Main Code
if opt == '-h':
greeting('Hello')
elif opt == '-g':
greeting('Goodbye')
fruits = ["apple", "banana", "cherry"]
#
# [
# 0 => "apple",
# 1 => "banana",
# 2 => "cherry"
# ]
#
# python
for index, fruit in enumerate(fruits):
print((index + 1), fruit)
# Now for some math
print("Math Time")
theNumber = 8.2394290
print(math.ceil(theNumber))
print(math.pi)
# Standard deviation example
a = np.array([1, 2, 3, 4])
print(np.std(a))