From 4f2dd9107a0a55eefd842c18caf64b60f1c15a6d Mon Sep 17 00:00:00 2001 From: Liron-Mizrahi <91504420+lironmiz@users.noreply.github.com> Date: Thu, 5 Jan 2023 07:32:00 +0200 Subject: [PATCH 1/6] Create unit9_ex9.3.2.py --- unit9_ex9.3.2.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 unit9_ex9.3.2.py diff --git a/unit9_ex9.3.2.py b/unit9_ex9.3.2.py new file mode 100644 index 0000000..4a21691 --- /dev/null +++ b/unit9_ex9.3.2.py @@ -0,0 +1,63 @@ +# exercise 9.3.2 from unit 9 +''' +def my_mp4_playlist(file_path, new_song): +The function accepts as parameters: + +Path to the file (string). +Just like in the previous exercise, the file represents a playlist of songs and has a fixed format built from the name of the song, the name of the performer (singer/band) and the length of the song, separated by a semicolon (;) without spaces. + +An example of an input file called songs.txt: +Tudo Bom; Static and Ben El Tavori; 5:13; +I Gotta Feeling; The Black Eyed Peas; 4:05; +Instrumental; Unknown; 4:15; +Paradise; Coldplay; 4:23; +Where is the love?; The Black Eyed Peas; 4:13; +A string representing the name of a new song. +The operation of the function my_mp4_playlist: + +The function writes to the file the string representing the name of a new song (new_song) instead of the name of the song that appears in the third line of the file (if the file contains less than three lines, write empty lines to the file so that the name of the song is written in the third line). +The function prints the contents of the file after the change has been made. +An example of running the my_mp4_playlist function on the songs.txt file +>>> my_mp4_playlist(r"c:\my_files\songs.txt", "Python Love Story") +Tudo Bom; Static and Ben El Tavori; 5:13; +I Gotta Feeling; The Black Eyed Peas; 4:05; +Python Love Story;Unknown;4:15; +Paradise; Coldplay; 4:23; +Where is the love?; The Black Eyed Peas; 4:13; +The contents of the songs.txt file after + +Tudo Bom;Static and Ben El Tavori;5:13; +I Gotta Feeling;The Black Eyed Peas;4:05; +Python Love Story;Unknown;4:15; +Paradise;Coldplay;4:23; +Where is the love?;The Black Eyed Peas;4:13; + +''' +def my_mp4_playlist(file_path, new_song): + with open(file_path, 'r') as f: + lines = f.readlines() + + while len(lines) < 3: + lines.append(";;\n") + + song_parts = new_song.split(';') + song_name = song_parts[0] + artist = "Unknown" + if len(song_parts)> 1: + artist = song_parts[1] + + lines[2] = f"{song_name};{artist};\n" + + with open(file_path, 'w') as f: + f.writelines(lines) + + with open(file_path, 'r') as f: + print(f.read()) + +def main(): + my_mp4_playlist(r"c:\my_files\songs.txt", "Python Love Story") + +if __name__ == "__main__": + main() + + From aa813498b0b7bebbdb856fb2bb4f591271f5227e Mon Sep 17 00:00:00 2001 From: Liron-Mizrahi <91504420+lironmiz@users.noreply.github.com> Date: Thu, 5 Jan 2023 12:31:19 +0200 Subject: [PATCH 2/6] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index b853b24..12b3372 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ this repository contains solutions in python to the python course problems of th 9. Files 10. Final project from scratch hangman game. +# video of the final project π€ + + +https://user-images.githubusercontent.com/91504420/210758896-10ba6b90-9aa2-49ca-8f73-7fdf5c3ed5b0.mp4 + + From 3e44ba3183e58f0da409420211a86069868f8212 Mon Sep 17 00:00:00 2001 From: Liron-Mizrahi <91504420+lironmiz@users.noreply.github.com> Date: 2023εΉ΄1ζ17ζ₯ 19:38:30 +0200 Subject: [PATCH 3/6] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 12b3372..eef80c5 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ this repository contains solutions in python to the python course problems of th
+ + + # course material: 1. Introduction to the Python language 2. Variables From 9cef46c4a4608c8e9a61f24fe23ec90a8bd92222 Mon Sep 17 00:00:00 2001 From: Liron-Mizrahi <91504420+lironmiz@users.noreply.github.com> Date: 2023εΉ΄1ζ17ζ₯ 19:40:46 +0200 Subject: [PATCH 4/6] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eef80c5..66a458e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ this repository contains solutions in python to the python course problems of th  + # course material: 1. Introduction to the Python language From 032f6bd1a28b320cea7ca1205cca38accbd654c6 Mon Sep 17 00:00:00 2001 From: Liron-Mizrahi <91504420+lironmiz@users.noreply.github.com> Date: 2023εΉ΄1ζ18ζ₯ 12:34:27 +0200 Subject: [PATCH 5/6] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 66a458e..827580d 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ this repository contains solutions in python to the python course problems of th  + +  # course material: From 10c841a6e8a0ef433173f0507a9783972ae048bb Mon Sep 17 00:00:00 2001 From: Liron-Mizrahi <91504420+lironmiz@users.noreply.github.com> Date: 2023εΉ΄1ζ18ζ₯ 14:02:00 +0200 Subject: [PATCH 6/6] Update README.md --- README.md | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 827580d..50669d3 100644 --- a/README.md +++ b/README.md @@ -19,25 +19,33 @@ this repository contains solutions in python to the python course problems of th +# The Graduation Certificate π€© + + +  +# Examiner's Notes π«‘ +  +# Progress Graph π +  -# course material: -1. Introduction to the Python language -2. Variables -3. String in python -4. Conditions -5. functions -6. Lists -7. Loops -8. Advanced data structure e.g (tuple, Dictionary ) -9. Files -10. Final project from scratch hangman game. - -# video of the final project π€ +# Course Material: + * Introduction to the Python language + * Variables + * String in python + * Conditions + * Functions + * Lists + * Loops + * Advanced data structure e.g (tuple, Dictionary ) + * Files + * Final project from scratch hangman game. + +# Video Of The Final Project π€ https://user-images.githubusercontent.com/91504420/210758896-10ba6b90-9aa2-49ca-8f73-7fdf5c3ed5b0.mp4