Added week 5
This commit is contained in:
@@ -26,6 +26,8 @@ def main():
|
|||||||
SEPREATE_VAR_WORD_BOY,
|
SEPREATE_VAR_WORD_BOY,
|
||||||
end=SEPREATE_VAR_WORD_DOT)
|
end=SEPREATE_VAR_WORD_DOT)
|
||||||
|
|
||||||
|
print("\n")
|
||||||
|
|
||||||
print('pls ignore the following line if youre using windows\' default cmd prompt e.g. cmd.exe. using bash to make it display properly.')
|
print('pls ignore the following line if youre using windows\' default cmd prompt e.g. cmd.exe. using bash to make it display properly.')
|
||||||
|
|
||||||
print('\033[3m\t',
|
print('\033[3m\t',
|
||||||
@@ -41,6 +43,8 @@ def main():
|
|||||||
SEPREATE_VAR_WORD_BOY,
|
SEPREATE_VAR_WORD_BOY,
|
||||||
end=SEPREATE_VAR_WORD_DOT)
|
end=SEPREATE_VAR_WORD_DOT)
|
||||||
|
|
||||||
|
print("\n")
|
||||||
|
|
||||||
print('==End Of Ex1==')
|
print('==End Of Ex1==')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
13
week5/ex1.py
Normal file
13
week5/ex1.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print('==Exercise 1==')
|
||||||
|
sample_tuple = (100, 200, 300)
|
||||||
|
|
||||||
|
print(f"This is a tuple {sample_tuple}")
|
||||||
|
|
||||||
|
print('==End Of Ex1==')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
12
week5/ex2.py
Normal file
12
week5/ex2.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
def main():
|
||||||
|
print('==Exercise 2==')
|
||||||
|
|
||||||
|
tuple_output = (1,2.0,'c',[4],{"value":5})
|
||||||
|
|
||||||
|
print(f"tuple: {tuple_output}")
|
||||||
|
|
||||||
|
print('==End Of Ex2==')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
9
week5/ex3.py
Normal file
9
week5/ex3.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
def main():
|
||||||
|
print('==Exercise 3==')
|
||||||
|
t = (1,2,3,4,5,6,7,8,9,10)
|
||||||
|
print(f'tuple:{t}\n3rd number of tuple:{t[2]}')
|
||||||
|
print('==End Of Ex3==')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
17
week5/ex4.py
Normal file
17
week5/ex4.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
def main():
|
||||||
|
print('==Exercise 4==')
|
||||||
|
|
||||||
|
# Create a tuple containing a sequence of numbers
|
||||||
|
tuplex = (4, 6, 2, 8, 3, 1)
|
||||||
|
# Print the contents of the 'tuplex' tuple
|
||||||
|
print(tuplex)
|
||||||
|
|
||||||
|
t_o = (*tuplex,999)
|
||||||
|
|
||||||
|
print(f"Modified tuple: {t_o}")
|
||||||
|
|
||||||
|
print('==End Of Ex4==')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
15
week5/ex5.py
Normal file
15
week5/ex5.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
def main():
|
||||||
|
d1 = {0: 10, 1: 20}
|
||||||
|
print('==Exercise 5==')
|
||||||
|
|
||||||
|
print(f"Before: {d1}")
|
||||||
|
|
||||||
|
d1[2] = 30
|
||||||
|
|
||||||
|
print(f"After: {d1}")
|
||||||
|
|
||||||
|
print('==End Of Ex5==')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
12
week5/ex6.py
Normal file
12
week5/ex6.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
def main():
|
||||||
|
d1 = {'a': 100, 'b': 200}
|
||||||
|
d2 = {'x': 300, 'y': 200}
|
||||||
|
|
||||||
|
print('==Exercise 6==')
|
||||||
|
d_o = {**d1,**d2}
|
||||||
|
print(f"Merged dict: {d_o}")
|
||||||
|
print('==End Of Ex6==')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
7
week5/run_all.py
Normal file
7
week5/run_all.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import ex1,ex2,ex3,ex4,ex5,ex6
|
||||||
|
ex1.main()
|
||||||
|
ex2.main()
|
||||||
|
ex3.main()
|
||||||
|
ex4.main()
|
||||||
|
ex5.main()
|
||||||
|
ex6.main()
|
||||||
Reference in New Issue
Block a user