-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnw.py
238 lines (198 loc) · 5.73 KB
/
nw.py
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
from ast import And, FloorDiv
from optparse import Values
import this
#working with varaibles
message="you are useless"
message="reall use less"
print(message)
#working with strings
first_name="ada lovelace"
last_name ="Jude"
print(first_name.title()) #using the .title methiod to change the case of the case
print(first_name.upper()) #changinr the entire first_name to upper case
print(first_name.lower()) #Changing all to lowe case
print(f"{first_name} {last_name.title()}") #using formated string
print("languages: Python \n java \n c\n R") #Using the escape character \n to move to a new line
from email.policy import strict
name ="Eric"
print(f"Hello {name} would you like to learn some python today?")
print(name.title())
print(name.upper())
print(name.lower())
famous_person = "Albert Einstein"
print(f"{famous_person} once said, 'A person who never made a mistake never tried anything new'")
stripping =" Jude "
print(f"name:\n {stripping}")
print(stripping.rstrip())
print(stripping.strip())
print(stripping.lstrip())
#working with numbers
2 + 3
3 - 2
3/2
10 ** 6 # intergers
10 * 6
(2+3) * 4
0.1 #floats
number=8
print(number + 7 * 4 - 5 / number)
print(f"my favorite number is {number}")
#this is a comment
'''this is a mul;tiple line comment'''
#list
Friend=["drew", "nkini", "adi", "laura","zack", "mark", "steve"]
print(Friend[0])
print(f"i would prefer {Friend[1].title()} to all")
Friend[0]="vince"
Friend.append("Ebenezar")
Friend.pop(-2)
del Friend[2]
print(Friend)
Guest_list= ["john", "peter", "james", "paul"]
print(f"{Guest_list[0].title()} you are invited for a dinner")
print(f"{Guest_list[1].title()} you are invited for a dinner")
print(f"{Guest_list[2].title()} you are invited for a dinner")
print(f"{Guest_list[3].title()} you are invited for a dinner")
Guest_list.pop(2)
Guest_list.append("bih")
Guest_list[3]="new"
Guest_list.append("trash")
print(Guest_list)
# looping through an entire list
pizzas =['pepperoni', 'jinjer', 'tomatoe', 'nular']
for pizza in pizzas:
print(f" i like {pizza.title()} pizza \n")
print("my love for pizza is immeaqsurable to anything on earth")
animals =['dog', 'cat', 'rabbit', 'rat']
for animal in animals:
print(f"A {animal.title()} will make a great pet \n")
print("these are the best pets i know so far")
#making numerical list
for values in range(1, 21):
print(values)
one_milion=[]
for values in range (1, 10000001):
one_milion.append(values)
# print(one_milion)
min(one_milion)
max(one_milion)
odd=[]
for values in range (1,20,2): # odd numbers from 1 to 20
odd.append(values)
print(odd)
threes=list(range(3,30,3)) #printing multiples of 3
print(threes)
cube=[]
print (cube)
#working with part of a list
print("my firts friends are")
for Friend in Friend[:3]:
print(Friend)
print("my middle friends are")
for Friend in Friend[1:4]:
print(Friend)
print("my last friends are")
for Friend in Friend[2:5]:
print(Friend)
frind_pizza =pizzas[:]
frind_pizza.append("egg")
print(frind_pizza)
print(f"my favorite pizzas are")
for pizza in pizzas:
print(pizza)
print("my friend's favourite pizzaS are:")
for frind_pizza in frind_pizza:
print(frind_pizza)
#tuples (fixed list)
foods=("rice", "beans", "spaghetti", "plantains", "yams")
print('\n These are the avialable foods we have today')
for food in foods:
print(food)
#foods[0]="g.nut soup"
foods=("rice", "beans", "spaghett", "plantains", "irish")
print("this is the menu for today")
for food in foods:
print(food)
#If statements
car ="bmw"
print("Is car =='bmw'? i predict True.")
print(car =='bmw')
print ("\n is car =='audi'? i predict false")
print(car =='audi')
print (3 < 2)
print (3 == 2)
print( 3 <= 3)
print
print(car.lower() =="bmw")
print("rice" in foods)
print("pork" in foods)
#if-else statements
alien_colors=['green', 'red', 'yellow', ]
if alien_colors == 'green':
print("you just earned 5noints")
elif alien_colors == "yellow":
print("you just earned 10 points")
elif alien_colors =='red':
print("you earned 15 points")
else:
print("you loose")
age = 10
if age < 2:
print("pedrson is still a baby")
elif age == 2 and age <4:
print('person is a toodler')
elif age <=4 and age < 13:
print("person is a kid")
elif age <=13 and age <20:
print("person is a teenager")
elif age <=20 and age < 65:
print('person is an adult')
elif age > 65:
print("print person is an elder")
fav_fruits=['pine', 'range', 'nion', 'grape']
if 'pine' in fav_fruits:
print("i really like pine")
if "range" in fav_fruits:
print("worst")
if "nion" in fav_fruits:
print("manageble")
#if statements with list
hello_admins=['nico', 'drew', 'jardon', 'blaise', 'dart']
for hello_admin in hello_admins:
if hello_admin =="jardon":
print(f"hello {hello_admin.title()} would you like a status report?")
else:
print(f"hello {hello_admin.title()}, thanks for logging in")
if hello_admins ==[]:
print("we need to find more users")
else:
print("users look good")
currenr_users=['bj', 'be', 'ben', 'james', 'jude']
New_Users=['Bless', 'jude', 'bj', 'marie', 'claire']
for New_User in New_Users:
if New_User in currenr_users:
print("take a new user name")
else:
print("user name is available")
ord_numbers=[1, 2, 3, 4, 5, 6, 7, 8, 9]
for ord_number in ord_numbers:
if ord_numbers[0] ==1:
print("1st")
if ord_numbers[1] ==2:
print("2nd")
elif ord_numbers[2] ==3:
print("3rd")
elif ord_numbers[3] ==4:
print("4th")
elif ord_numbers[4] ==5:
print("5th")
elif ord_numbers[5] ==6:
print("6th")
elif ord_numbers[6] ==7:
print("7th")
elif ord_numbers[7] ==8:
print("8th")
elif ord_numbers[8] ==9:
print("9th")
else:
print('stop')