-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
200 lines (146 loc) · 5.39 KB
/
Copy pathindex.py
File metadata and controls
200 lines (146 loc) · 5.39 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# variables
# data types
# type casting
# input in python
# madlibs game in python #
# basic arithmetic operation in python
# the math module
# if statements in python
# Logical operators in python
# string method in python
# string indexing
# Format specifiers in py #
# while loop in python
# for loops in python
# compound interest calculator in py
# countdown timer in py
# nested loop
# collections in pyton
# shopping cart program #
# ths i a python code of about 2000 lines to master python programming language
print("cup cake is my favourite food")
# varibales
# variables are container for a value
# the diferent variables we have are (strings, integer, float, boolean)
# this are not container types of variables
# variables behve as if it was the value it containes
# ensure it variables has a unique name #
first_name = "festus" # this ia astring
print(first_name)
# to write our variables along with some text we use a f-string
# where f stands for format#
print(f"okay you might not know but my name is {first_name}")
# more example of variables will be used to explain data types in python
# exmple of integer #
age = 40 # this is an integer
print(f"okay you might not know but my age is {age}")
# if thiss numbers are placed within quotes then they become strings
# Float- this is a number but that contains a decimal number
price = 40.00
print(f"the price is ${price}")
# boolean this is either true or false
is_student = True
print(f"Is he a student? {is_student}")
# type casting in python
# this is the process of converting a variable from one data type to another
# str() int() float() bool() this are metods
# @bro-code @typecasting.py#
# Input () method
# accepting user input in python
# this is a method that prompts users to empty input and returns the input as a string
# @bro-code @input.py #
# madlibs game
# a word game where you create a story by filling in blanks with random words
# @test-runs @mathlib-game.py #
# math in python
# basic arithmetic operatons
# talking about argumented assignmnt operator.
# then built in mathrelated variables or method....
# round()
# abs()
# max()
# min()
# math module#
# math.pow
# math.sqrt
# math.random #
# if statements in python
# do some code only if some consition istrue else do something else
# #
for_sale = True
if for_sale:
print("this goods are for_ sale ")
else:
print("this goods arenot for sale ")
# python calculator program-------- this was built using an if statement and the order of arrangment is essential
# python weight converter program--------- this also takes the metho of if statement wth a clear arrangement of order
# and logic specifying the weight from and the weight to and the deeds that amounrts when condiion isn't met at all
# Temperature calculator program---------- this isalso done with an if statement followoing the rues
# this is done to solidify the knowledge of if statements
#
# because conditionls are really essentials to programs and writing a clear logic of conditionals
# ensure a smooth running program that it logic won't break despite the value inputedd
#
# think of this as a word provblem #
# logical operators in python
# this alows evaluation of multiple condition {or, and, not}
# or--- at lest one condition must be true
# and--- both conditions must be true
# not--- invrts the condition {not fase, not true
# or, and, and not is the syntax for writing these
# condtional expression
# this is one-line shortcut for the if else statement (tenery operator) in js
# print of assign one or two value based on a condition
# syntax-analogy--- X if condition else Y #
# String methods in python.. #
# string indexing
# alloes aessing element of a sequence using []
# indexing operator
# [start, end, step]
# [] called an indexing operator #
credicCard_number = "1234-5678-1313-7373737"
# if i meed the first character in this string it coud be accessed through indexing
credicCard_number[0]
print(credicCard_number)
# Format specifiers in py
# {:flags} this formats a value based on what flags are inserted
# .(number)f to round to that many decimal places
# :(number) allocate that many spaces
# :03 allocate and zero pad that many spaces
# :< left justify
# :> right justify
# :^ center align
# :+ use a plus sign to indicate positive value
# := place sign to leftmost position\
# : insert a space before positive numbers
# :, comma separatr #
# While loop in python
# A while loop will execurte some code while some conditionns are true
# #
# compound interest calc in py
#
# for loops in python
# execute a block of code a fixed number of times
# you can iterate over a range, string, sequence etc #
# countdown timer in python
# in this case we use time modulem in this case
# an esential feature in python to handle time
#
# the sleep function of the time module allows out program to sleep for a
# given time before execution #
# nested loop in py
# a loop within another loop
# outer and inner
# syntax of how nested loop looks like
# outer loop:
# inner loop:
# and the rest of the code till we exit both loop by ending the indentation
# it could literarily be any loop inside any loop
# #
# collections in py
# single "variale" used to store multiple vlues
# list [] it is ordered and changeable, Duplicates ok
# set {} unordered and immutable, but add/remove Ok, No Duplicates
# tupple () ordered and unchangeable, Duplicates OK #
# shopping cart program #
# dictionary in python