-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVar.py
More file actions
116 lines (78 loc) · 2.85 KB
/
Var.py
File metadata and controls
116 lines (78 loc) · 2.85 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
print('Learning about variables, how they work, and how to use them.\n')
'''
Im going to break this down into 3 parts, Simple, Intermediate, and Advanced Variables.
With that being said; The main reason that I would like to do this is the even tho all of these Variable types are
equally important, so may be harder to understand and fully grasp.
Note: Please disregard Empty `Print()` functions as they are used for spacing in the terminal.
'''
'''
Simple:
Strings; A string is a combination of chars or characters. chars can range from a-z, A-Z, 0-9, or even most special
characters like '?,.<>;: Etc...'. Strings are defined by putting quotes or double qoutes around the characters that
are to be included.
Int; An Int is a number that can be positive or negative.
Bool; Boolean variables have either two states, This is either True or False.
None; None is a special beast.. Well not really.. None is exactly what it sounds like, its nothing.
'''
# String
message = 'I am a String!'
print('String: {}'.format(message))
'''
For more information on Strings please see the Strings.py file.
'''
# Todo Create Strings.py.
# Int
real_int = 20
print('Real Int: {}'.format(real_int))
float_int = 20.053
print('Float Int: {}'.format(float_int))
'''
For more information on Ints please see the Numbers.py file.
'''
# Todo Create Numbers.py.
# Bool
boolean = True
print('Boolean: {}'.format(boolean))
print()
'''
Intermediate:
List: A list is exactly what it sounds like, Its a list of items. This can be Strings, Ints, Other lists, Anything.
Tuple: Much like a List a tuple is a list of items, the main difference being the Tuples are read-only meaning once
they are created they can not be modified or updated.
Dictionary: A dictionary again is like a List or Tuple except it uses Key:Value pairs.
'''
# List
list_var = ['Hello', 'their', 'I\'m', 'a', 'List']
for l in list_var:
print(l)
print()
# Tuple
tuple_var = ('Hello', 'their', 'I\'m', 'a', 'Tuple')
for t in tuple_var:
print(t)
dict_var = {'1': 'Hello', '2': 'their', '3': 'I\'m', '4': 'a', '5': 'Dict'}
for k, v in dict_var.items():
print('{}: {}'.format(k, v))
'''
For more information on Loops such as the `for` loop please see the Loops.py file.
For more information on Dictionaries please see the Dictionaries.py file.
'''
# Todo Create Loops.py and Dictionaries.py file.
print()
'''
Advanced:
Custom: These are variable types that can be created custom by you.
'''
# Custom
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def __str__(self):
return 'My name is {} and I\'m {} years old.'.format(self.name, self.age)
my_person = Person('Joe', 16)
print(my_person)
'''
For more information on Classes please see the Classes.py file.
'''
# Todo Create Classes.py file.