8th day of python challenges 105-110
This commit is contained in:
3
challenges105-110/challenge-105.py
Normal file
3
challenges105-110/challenge-105.py
Normal file
@@ -0,0 +1,3 @@
|
||||
file = open('Numbers.txt', 'w')
|
||||
file.write('1, 2, 3, 4, 5')
|
||||
file.close()
|
7
challenges105-110/challenge-106.py
Normal file
7
challenges105-110/challenge-106.py
Normal file
@@ -0,0 +1,7 @@
|
||||
file = open('Names.txt', 'w')
|
||||
file.write('Abdullah\n')
|
||||
file.write('Ahmed\n')
|
||||
file.write('Ali\n')
|
||||
file.write('Yaser\n')
|
||||
file.write('Hasanen\n')
|
||||
file.close()
|
2
challenges105-110/challenge-107.py
Normal file
2
challenges105-110/challenge-107.py
Normal file
@@ -0,0 +1,2 @@
|
||||
file_open = open('Names.txt', 'r')
|
||||
print(file_open.read())
|
9
challenges105-110/challenge-108.py
Normal file
9
challenges105-110/challenge-108.py
Normal file
@@ -0,0 +1,9 @@
|
||||
file_open = open('Names.txt', 'r')
|
||||
print(file_open.read())
|
||||
file_open.close()
|
||||
ask = str(input('Enter a name to add to file : '))
|
||||
file_write = open('Names.txt', 'a')
|
||||
file_write.write(file_write + '\n')
|
||||
file_write.close()
|
||||
file_open = open('Names.txt', 'r')
|
||||
print(file_open.read())
|
25
challenges105-110/challenge-109.py
Normal file
25
challenges105-110/challenge-109.py
Normal file
@@ -0,0 +1,25 @@
|
||||
count = 0
|
||||
while count < 5:
|
||||
print('1) Create a new file')
|
||||
print('2) Display the file')
|
||||
print('3) Add a new item to the file ')
|
||||
selection_input = int(input('Make a selection 1, 2 or 3 : '))
|
||||
if selection_input == 1:
|
||||
file = open('Subject.txt', 'w')
|
||||
subject_name = str(input('Enter school subject name : '))
|
||||
file.write(subject_name + '\n')
|
||||
file.close()
|
||||
elif selection_input == 2:
|
||||
file = open('Subject.txt', 'r')
|
||||
print(file.read())
|
||||
file.close()
|
||||
elif selection_input == 3:
|
||||
file = open('Subject.txt', 'a')
|
||||
subject_name = str(input('Enter school subject name to add into file : '))
|
||||
file.write(subject_name + '\n')
|
||||
file.close()
|
||||
count = count + 1
|
||||
|
||||
file = open('Subject.txt', 'r')
|
||||
print(file.read())
|
||||
file.close()
|
15
challenges105-110/challenge-110.py
Normal file
15
challenges105-110/challenge-110.py
Normal file
@@ -0,0 +1,15 @@
|
||||
file = open('Names.txt', 'r')
|
||||
print(file.read())
|
||||
file.close()
|
||||
file2 = open('Names2.txt', 'w')
|
||||
file2.close()
|
||||
ask = str(input('Enter one of names : '))
|
||||
with open('Names.txt', 'rt') as myFile:
|
||||
for myLine in myFile:
|
||||
if myLine != ask:
|
||||
file2 = open('Names2.txt', 'a')
|
||||
file2.write(myLine + '\n')
|
||||
file2.close()
|
||||
myFile.close()
|
||||
file = open('Names2.txt', 'r')
|
||||
print(file.read())
|
Reference in New Issue
Block a user