{"id":16058694,"url":"https://github.com/juzershakir/how-to-python","last_synced_at":"2025-04-05T08:15:58.012Z","repository":{"id":157834016,"uuid":"162858907","full_name":"JuzerShakir/How-to-Python","owner":"JuzerShakir","description":"Guide for beginners on the road to expert!","archived":false,"fork":false,"pushed_at":"2019-04-28T03:48:59.000Z","size":1741,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T15:50:47.269Z","etag":null,"topics":["basic-programming","coding","practice-programming","python3","python37","regular-expressions","tutorial"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuzerShakir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-23T03:21:08.000Z","updated_at":"2023-10-12T05:55:53.000Z","dependencies_parsed_at":"2024-06-23T01:18:16.412Z","dependency_job_id":null,"html_url":"https://github.com/JuzerShakir/How-to-Python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuzerShakir%2FHow-to-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuzerShakir%2FHow-to-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuzerShakir%2FHow-to-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuzerShakir%2FHow-to-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuzerShakir","download_url":"https://codeload.github.com/JuzerShakir/How-to-Python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305946,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["basic-programming","coding","practice-programming","python3","python37","regular-expressions","tutorial"],"created_at":"2024-10-09T03:40:23.614Z","updated_at":"2025-04-05T08:15:57.994Z","avatar_url":"https://github.com/JuzerShakir.png","language":"Python","readme":"# Guide on how to code in Python.\n*For beginners on the road to expert!*\n\n## Table of Contents\n\n- [Installing Python](#installation)\n- [Hello World](#1-hello-world)\n- [Hello User](#2-hello-user)\n- [Compute Gross Pay](#3-compute-gross-pay)\n- [Compute Gross Pay with Conditions](#4-gross-pay-with-conditions)\n- [Try Except](#try-except)\n  - [Gross Pay](#5-gross-pay)\n  - [Grading System](#6-grading-system)\n- [Functions](#functions)\n  - [Gross Pay](#7-gross-pay)\n  - [Grading System](#8-grading-system)\n- [Loop](#loop)\n  - [Compute Input](#9-compute-input)\n  - [Min \u0026 Max](#10-min-and-max)\n- [Strings](#11-string)\n- [File](#file)\n  - [Print text from a file](#12-print-text-from-file)\n  - [Compute values within file](#13-compute-values-within-file)\n- [List](#list)\n  - [Splitting and Sorting](#14-splitting-and-sorting)\n  - [Email Count](#15-email-count)\n- [Dictionary](#16-dictionary)\n- [Tuples](#17-tuples)\n- [Regular Expressions](#regular-expressions)\n  - [Compute values within file](#18-compute-values-within-file)\n  - [Highest Emails](#19-highest-emails)\n  - [Finding Number](#20-finding-number)\n\n----\n\n### Installation\nIn order to execute python files, we need to install python. Install the latest version of Python [here](https://www.python.org/downloads/). Once its successfully installed, you're now ready to code and execute commands or files in python.\n\n----\n\n###  1. Hello World\n**Q.  Output *'Hello World'* to the screen.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Hello%20World.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Hello World.png'\u003e\u003c/p\u003e\n\n\n\u003cbr\u003e\n\n**Output.**\n\n```\nHello World\n```\n\n---\n\n###  2. Hello User\n**Q. Greet *'Hello'* to the user with *it's name.***\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Hello%20User.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Hello User.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Input:**\n\n```\nJuzer Shakir\n```\n\n**Output:**\n\n```\nHello Juzer Shakir\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### 3. Compute Gross Pay\n**Q. Write a program to prompt user for hours and rate per hour to compute their gross pay.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Compute%20Gross%20Pay.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Compute Gross Pay.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Input:**\n\n```\nEnter Hours: 10\nEnter Rate: 10\n```\n**Output:**\n\n```\nPay: 1000.0\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### 4. Gross Pay with Conditions\n**Q. Rewrite your pay computation *([Exercise 3](#3-compute-gross-pay))* to give the employee 1.5 times the hourly rate for hours worked above 40 hours.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Compute%20Gross%20Pay%20with%20Conditions.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Compute Gross Pay with Conditions.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter Hours: 10\nEnter Rate: 10\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nPay: 1000.0\n```\n**Scenario 2:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter Hours: 45\nEnter Rate: 10\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nPay: 475.0\n```\n\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### Try Except\n#### 5. Gross Pay\n**Q. Rewrite your pay program *([Exercise 4](#4-gross-pay-with-conditions))* using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Try%20Except/Gross%20Pay.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Try Except/Gross Pay.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter Hours: five\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nError, please enter numeric input\n```\n**Scenario 2:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter Hours: 65\nEnter Rate: 8\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nPay: 620.0\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n#### 6. Grading System\n**Q. Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message.\u003cbr\u003e\nIf the score is between 0.0 and 1.0, print a grade using the following table:**\n\n| **Score** |  **Grade** |\n| --------- | ---------- |\n| **\u003e=0.9** |  A         |\n| **\u003e=0.8** |  B         |\n| **\u003e=0.7** |  C         |\n| **\u003e=0.6** |  D         |\n| **\u003c 0.6** |  F         |\n\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Try%20Except/Grading%20System.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Try Except/Grading System.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter score: 1.1\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nBad Score\n```\n**Scenario 2:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter score: 0.76\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nC\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### Functions\n#### 7. Gross Pay\n**Q. Rewrite your pay computation *([Exercise 5](#5-gross-pay))* and create a function called *'computepay'* which takes two parameters (hours and rate).**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Functions/Gross%20Pay.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Function/Gross Pay.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter Hours: 60\nEnter Rate: eleven\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nError, please enter numeric input\n```\n**Scenario 2:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter Hours: 40.5\nEnter Rate: 9.5\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nPay: 387.125\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n#### 8. Grading System\n**Q. Rewrite grading program *([Exercise 6](#6-grading-system))* using function named *'computegrade'*.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Functions/Grading%20System.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Function/Grading System.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter score: 0.52\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nF\n```\n**Scenario 2:**\n\u003cbr\u003e\n\n\u003ch6\u003eInput\u003c/h6\u003e\n\n```\nEnter score: 0.83\n```\n\n\u003ch6\u003eOutput:\u003c/h6\u003e\n\n```\nB\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### Loop\n#### 9. Compute Input\n**Q. Write a program which repeatedly reads numbers until the user inputs *\"done\"*. Once *\"done\"* is entered, print out the *total, count, and average* of the *input numbers*. If the user enters anything other than a number,  detect their mistake using try and except and print an error message and skip to the next number.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Loop/Compute%20Input.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Loop/Compute Input.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter a number: juzer\nInvalid input\nEnter a number: one\nInvalid input\nEnter a number: twenty\nInvalid input\nEnter a number: done\n```\n\n###### Output:\n```\nCanonot compute string input. Only numeric input allowed.\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter a number: 97\nEnter a number: 176\nEnter a number: 32\nEnter a number: forty \nInvalid input\nEnter a number: 40\nEnter a number: 64\nEnter a number: 21\nEnter a number: 99\nEnter a number: 58\nEnter a number: hundred\nInvalid input\nEnter a number: 100\nEnter a number: done\n```\n\n###### Output:\n```\nTotal of all 9 numeric inputs are 687.0 with an average of 76.33333333333333\n```\n\n**Scenario 3:**\n\n###### Input:\n```\nEnter a number: 97\nEnter a number: 11\nEnter a number: 41\nEnter a number: 86\nEnter a number: 191\nEnter a number: 80\nEnter a number: 23\nEnter a number: 153\nEnter a number: done\n```\n\n###### Output:\n```\nTotal of all 8 numeric inputs are 682.0 with an average of 85.25\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n#### 10. Min and Max\n**Q. Similar to *[Exercise 9](#9-compute-input)*, only output a minimum and a maximum number inputted by the user.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Loop/Min%20and%20Max.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Loop/Min and Max.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter a number: ww\nInvald input.\nEnter a number: nine\nInvald input.\nEnter a number: done\n```\n\n###### Output:\n```\nMinimum = None Maximum = None\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter a number: 70\nEnter a number: 80\nEnter a number: 37\nEnter a number: 49\nEnter a number: lalala \nInvald input.\nEnter a number: 56\nEnter a number: 1\nEnter a number: 6\nEnter a number: don \nInvald input.\nEnter a number: done\n```\n\n###### Output:\n```\nMinimum = 1.0 Maximum = 80.0\n```\n\n**Scenario 3:**\n\n###### Input:\n```\nEnter a number: 17\nEnter a number: 30\nEnter a number: 61\nEnter a number: 102\nEnter a number: 5\nEnter a number: 110\nEnter a number: 45\nEnter a number: 69\nEnter a number: 87\nEnter a number: done\n```\n\n###### Output:\n```\nMinimum = 5.0 Maximum = 110.0\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### 11. String\n**Q. Use *'find'* and *string slicing* to extract the portion of the string after the colon character and then use the float function to convert the extracted string into a floating point number.**\u003cbr\u003e\n*str = 'X-DSPAM-Confidence: 0.8475'*\n    \n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/String.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/String.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Output.**\n\n```\n0.8475\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### File\n#### 12. Print text from file\n**Q. Write a program to read through a file *[mbox-short.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/File/mbox-short.txt)* and print the contents of the file (line by line) all in upper case.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/File/Print%20text%20from%20a%20file.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/File/Print text from a File.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter a file name: short.txt\n```\n\n###### Output:\n```\nNo such file exists in this directory with this file name: short.txt\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter a file name: mbox-short.txt\n```\n\n###### Output:\n```\nFROM STEPHEN.MARQUARD@UCT.AC.ZA SAT JAN  5 09:14:16 2008\n\nRETURN-PATH: \u003cPOSTMASTER@COLLAB.SAKAIPROJECT.ORG\u003e\n\nRECEIVED: FROM MURDER (MAIL.UMICH.EDU [141.211.14.90])\n\n         BY FRANKENSTEIN.MAIL.UMICH.EDU (CYRUS V2.3.8) WITH LMTPA;\n\n         SAT, 05 JAN 2008 09:14:16 -0500\n\nX-SIEVE: CMU SIEVE 2.3\n\nRECEIVED: FROM MURDER ([UNIX SOCKET])\n\n         BY MAIL.UMICH.EDU (CYRUS V2.2.12) WITH LMTPA;\n\n         SAT, 05 JAN 2008 09:14:16 -0500\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n#### 13. Compute values within file\n**Q. Write a program to read through the file *[mbox-long.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/File/mbox-long.txt)* and look for lines of the form:**\u003cbr\u003e\n\n*X-DSPAM-Confidence: 0.8475* \u003cbr\u003e\n\n**When you encounter a line that starts with *\"X-DSPAM-Confidence:\"* pull apart the line to extract the floating-point number from that line. Count number of occurances on the file and then compute the total of the spam confidence values from these lines. Also print out the average spam confidence values.**\n\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/File/Compute%20values%20within%20file.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/File/Compute Values within File.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter a file name: short.txt\n```\n\n###### Output:\n```\nNo such file exists in this directory with this file name: short.txt\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter a file name: mbox-short.txt\n```\n\n###### Output:\n```\nThis file does not contain spam confidence values to compute. Please input file name of appropriate file.\n```\n\n**Scenario 3:**\n\n###### Input:\n```\nEnter a file name: mbox-long.txt\n```\n\n###### Output:\n```\nAverage spam confidence: 0.7507185185185187\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### List\n#### 14. Splitting and Sorting\n**Q.  Write a program to open the file *[romeo.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/List/romeo.txt)* and read it line by line.**\u003cbr\u003e\n**For each line, split the line into a list of words using the *'split'* function. For each word, check to see if the word is already in a list. If the word is not in the list, add it to the list. When the program completes, sort and print the resulting words in alphabetical order.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/List/Splitting%20and%20Sorting.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/List/Splitting and Sorting.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter a file name: domeo.txt\n```\n\n###### Output:\n```\ndomeo.txt doesnt exist!\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter a file name: romeo.txt\n```\n\n###### Output:\n```\n['Arise', 'But', 'It', 'Juliet', 'Who', 'already', 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', 'what', 'window', 'with', 'yonder']\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n#### 15. Email Count\n**Q. Write a program to read through a mail log from *[mbox-long.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/List/mbox-long.txt)*  file, line starting with *'From '*. You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a count at the end.**\n\n*Hint: make sure not to include the lines that start with 'From:'.*\n\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/List/Email%20Count.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics//List/Email Count.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter a file name: domeo.txt\n```\n\n###### Output:\n```\ndomeo.txt file doesnt exist!\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter a file name: romeo.txt\n```\n\n###### Output:\n```\nPlease input desired file name for computation.\n```\n\n**Scenario 3:**\n\n###### Input:\n```\nEnter a file name: mbox-long.txt\n```\n\n###### Output:\n```\nstephen.marquard@uct.ac.za\nlouis@media.berkeley.edu\nzqian@umich.edu\nrjlowe@iupui.edu\nzqian@umich.edu\nrjlowe@iupui.edu\ncwen@iupui.edu\ncwen@iupui.edu\ngsilver@umich.edu\ngsilver@umich.edu\nzqian@umich.edu\ngsilver@umich.edu\nwagnermr@iupui.edu\nzqian@umich.edu\nantranig@caret.cam.ac.uk\ngopal.ramasammycook@gmail.com\ndavid.horwitz@uct.ac.za\ndavid.horwitz@uct.ac.za\ndavid.horwitz@uct.ac.za\ndavid.horwitz@uct.ac.za\nstephen.marquard@uct.ac.za\nlouis@media.berkeley.edu\nlouis@media.berkeley.edu\nray@media.berkeley.edu\ncwen@iupui.edu\ncwen@iupui.edu\ncwen@iupui.edu\nThere were 27 lines in the file with 'From' as the first word\n```\n\n*[Back to Top](#table-of-contents)*\n\n----\n\n### 16. Dictionary\n**Q. Write a program to read through a mail log from *[mbox-long.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/Dictionary/mbox-long.txt)*  file, line starting with *'From '*. Build a histogram using a dictionary to count how many messages have come from each email address.** \u003cbr\u003e\n\n**Look through the dictionary using loop to find who has the most messages and print how many messages the person has.**\n\n*Note: make sure not to include the lines that start with 'From:'.*\n\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Dictionary/Most_email.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Most Email.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter file name: mbox.txt\n```\n\n###### Output:\n```\nmbox.txt file doesn't exist\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter file name: mbox-long.txt\n```\n\n###### Output:\n```\ncwen@iupui.edu has most messages of 5\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### 17. Tuples\n**Q. Write a program that counts the distribution of the hour of the day for each of the messages in the *[mbox-long.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/Tuples/mbox-long.txt)* file. You can pull the hour from the *'From '* line by finding the time string and then splitting that string into parts using the colon character.**\u003cbr\u003e\n**Once you have accumulated the counts for each hour, print out the counts, one per line, sorted by hour.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Tuples/Most_mail_hour.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Most Mail Hour.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter file name: 11\n```\n\n###### Output:\n```\n11 file doesn't exist\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter file name: mbox-long.txt\n```\n\n###### Output:\n```\n04 3\n06 1\n07 1\n09 2\n10 3\n11 6\n14 1\n15 2\n16 4\n17 2\n18 1\n19 1\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n### Regular Expressions\n\nRegular expressions cheat sheet:\n\n|    Regular Expressions |    Description                           |\n| ---------------------- | ---------------------------------------- |\n|    ^                   |    Matches the beginning of a line       |\n|    $                   |    Matches the end of the line           |\n|    .                   |    Matches any character                 |\n|    \\s                  |    Matches Whitespace                    |\n|    \\S                  |    Matches any non-whitespace character  |\n|     *                  | Repeats a character zero or more times   |\n|     *?                 | Repeats a character zero or more times (Non-Greedy) |\n|      +                 | Repeats a character one or more times    |\n|      +?                | Repeats a character one or more times  (Non-Greedy) |\n|  [aeiou]               | Matches a single character in the listed set|\n|     [^XYZ]             | Matches a single character not in the listed set|\n|     [a-z0-9]           | The set of characters can include a range |\n|      (                 | Indicates where string extraction is to start |\n|       )                | Indicates where string extraction is to end |\n\n*For more information on Regular Expression, visit [here](https://docs.python.org/3/howto/regex.html)*\n\n-----\n\n#### 18. Compute values within file\n**Q. Sum up all *'X-DSPAM-Confidence'* values from *[mbox.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/Expressions/mbox.txt)* file.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Expressions/Compute%20values%20within%20file.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Expressions/Compute values within file.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter file name: dummy\n```\n\n###### Output:\n```\nNo such file found! Try again!\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter file name: mbox.txt\n```\n\n###### Output:\n```\n667.8322999999995\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n#### 19. Highest Emails\n**Q. Write a program similar to *[Exercise 15](#15-dictionary)* but regardless of whether the line starts from *'From'* on *[mbox.txt](https://github.com/JuzerShakir/How-to-Python/blob/master/Expressions/mbox.txt)* file.**\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Expressions/Highest%20Email.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Expressions/Highest Email.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter file name: dummy\n```\n\n###### Output:\n```\nNo such file found! Try again!\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter file name: mbox.txt\n```\n\n###### Output:\n```\nNumeber of email id's:  746\n131 is highest number of mails done by cwen@iupui.edu email id.\n```\n\n*[Back to Top](#table-of-contents)*\n\n---\n\n#### 20. Finding Number\n**Q. Extract all the numbers in a file and compute the sum of the numbers.**\n***[File 1](https://github.com/JuzerShakir/How-to-Python/blob/master/Expressions/regex_sum_42.txt) and [File 2](https://github.com/JuzerShakir/How-to-Python/blob/master/Expressions/regex_sum_163439.txt)***\n\n\u003cbr\u003e\n\n*[Code](https://github.com/JuzerShakir/How-to-Python/blob/master/Expressions/Total.py)*\n\n\u003cp\u003e\u003cimg src = 'CodePics/Expressions/Total.png'\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n**Scenario 1:**\n\n###### Input:\n```\nEnter file name: ...\n```\n\n###### Output:\n```\nNo such file found! Try again!\n```\n\n**Scenario 2:**\n\n###### Input:\n```\nEnter file name: regex_sum_42.txt\n```\n\n###### Output:\n```\n445833\n```\n\n**Scenario 3:**\n\n###### Input:\n```\nEnter file name: regex_sum_163439.txt\n```\n\n###### Output:\n```\n297017\n```\n\n*[Back to Top](#table-of-contents)*\n\n-----","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuzershakir%2Fhow-to-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuzershakir%2Fhow-to-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuzershakir%2Fhow-to-python/lists"}