Skip to content

Commit 5eb4630

Browse files
authored
wk 4 tasks
1 parent 5e93cd5 commit 5eb4630

File tree

4 files changed

+88
-3
lines changed

4 files changed

+88
-3
lines changed

Tasks/Wk2Scratch.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
1-
import sys
21

3-
for d in sys.path:
4-
print ( d )
2+
# #// this will work as its replacing the entire contents.
3+
# my_song = "All Too Wall"
4+
# print ( my_song )
5+
# my_song = 'All Too Well'
6+
# print ( my_song )
7+
8+
# #// this will crash as I can't change PART of
9+
# # (comment this out to test the next part)
10+
# # my_song[6] = 'e'
11+
# # print ( my_song )
12+
13+
# # this all works. because each is a replacement
14+
# my_list = ["bob",1,2.3,"steve"]
15+
# print ( my_list )
16+
# my_list[3]=12.23
17+
# print ( my_list )
18+
# my_list[3]=my_list[3]*5 # this doesn't amend the value, it replaces it with a new one.
19+
# print ( my_list )
20+
21+
# # this will work as the entire string part of the list can be replaced.
22+
# my_list[0]="flip"
23+
# print ( my_list )
24+
25+
# # this will crash because the string part cannot be manipulated inside itself
26+
# # my_list[0][2]="o"
27+
# # print ( my_list )
28+
29+
lst = []
30+
31+
n = int(input("Enter number of employees"))
32+
#a = 0
33+
for a in range(0, n):
34+
name = input("Enter name of employees")
35+
lst.append(name)
36+
#a=a+1
37+
38+
print(lst)

Tasks/list_of_employees.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
emps=[]
3+
new_name = input("Enter name please (enter empty string to end): ")
4+
while new_name != "":
5+
emps.append(new_name)
6+
new_name = input("Enter name please (enter empty string to end): ")
7+
8+
print ( emps )

Tasks/tuple.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# do tuple stuff
2+
3+
tup=("abc","bcd","1","2","3","4",5,6,7,8,9)
4+
print (tup)
5+
6+
tup2=(tup)
7+
#print ("tup2: " + ','.join(tup2))
8+
9+
print ( "tup is tup2: " + str(tup is tup2))
10+
print ( "tup == tup2: " + str(tup == tup2))
11+
12+
tup3=tuple(str(val) for val in tup)
13+
print ( tup3 )
14+
print ("tup3: " + ', '.join(tup3))
15+
16+
print ( "tup is tup3: " + str(tup is tup3))
17+
print ( "tup == tup3: " + str(tup == tup3))
18+
19+
tup4=tuple(tup)
20+
print ( "tup is tup4: " + str(tup is tup4))
21+
print ( "tup == tup4: " + str(tup == tup4))

Tasks/vowels.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# check for vowels
2+
3+
#inits
4+
tup_tests=('a','e','i','o','u')
5+
tup_found=()
6+
tup_notfound=()
7+
8+
test_word=input("Please enter the test word: ").lower()
9+
10+
print ( f'Testing the word {test_word}')
11+
12+
for tc in tup_tests :
13+
if tc in test_word :
14+
num_hits=test_word.count(tc)
15+
tup_found+=(str(num_hits)+'*'+tc,)
16+
#print ( "Does contains " + tc)
17+
else:
18+
tup_notfound += (tc,)
19+
#print ("Does NOT contain " + tc)
20+
21+
print ( "Found " + ', '.join(tup_found) )
22+
print ( "No " + ','.join(tup_notfound) )

0 commit comments

Comments
 (0)