Python 1 - Fundamentals

DESCRIPTION

This Python course is designed to enhance your programming skills and cultivate logical thinking, empowering you to proficiently write applications for statistical analysis, financial modeling, and mathematical computations. You'll gain expertise in code structuring through the use of while and for loops, conditional statements (if), and functions. Additionally, you'll learn how to leverage libraries and develop a deep understanding of Python's data structures.

In the advanced course, participants will acquire proficiency in utilizing Python for various applications, including data science, user interface development, and object-oriented programming with classes.

1. Python Basics

•      a. Setup Python and PyCharm
•      b. Your first Python program
•      c. The print function
•      e. Using the Python Interpreter

2. Data Structure

•      a. Lists
•      b. Tuples
•      c. Dictionaries
•      d. Operators
•      e. Arrays
•      f. Sets
•      g. Data Structure Applications

3. Conditional Loops

•      a. Conditional Statements
•      b. For And While Loops
•      c. Break Continue Pass
•      d. Oops

4. Strings

•      a. Strings
•      b. String Strip Functions
•      c. String Count
•      d. String Format
•      e. String Len
•      f. String Find

5. Functions

•      a. Main Function
•      b. Function Examples
•      c. Lambda Function
•      d. Round Function
•      e. Range Function
•      f. Timeit Function
•      g. Generator Yield Return
•      h. Queue
•      i. Counter in Collections
•      j. Enumerate Function
•      k. Timesleep Function
•      l. Type and isinstance
•      m. New Line

6. File Handling

•      a. File Handling
•      b. Directory Management
•      c. Copy File
•      d. Rename File
•      e. ZIP File
•      f. Exception Handling

AUDIENCE

This course is ideal for teenagers, university students, and anyone who wants to learn coding.

PREREQUISITES

Basic computer skills.

▶ ASSIGNMENTS

▶ Assignment 01 - Temperature Converter

 Use google to search for the formulas used to convert from Celsius to Fahrenheit and vise versa. Then, write a Python program that will do the conversion. Get the input from the users.

▶ Assignment 02 - Calculating Simple Interest

 Write a Python program that will calculate the simple interest rate. Simple Interest = (P x T x R)/100. P is the principal amount; T is the time; R is the interest rate.

▶ Assignment 03 - Calculating Compound Interest

 Use google to study how compound interest are calculated. Write a Python program that will do the calculation.

▶ Assignment 04 - Calculating Averages

 Without using any library, write a program that will calculate the class score average. class_scores=[90, 87, 68, 77, 50, 80, 83, 92, 75, 71, 86]

▶ Assignment 05 - Armstrong Numbers

 Use google to study how Armstrong Numbers are calculated. Write a Python program that will create a list out of Armstrong Numbers between 0 and 10,000.

▶ Assignment 06 - Sorting Players by Their Salary

 The following tuple contains famous soccer players' names and their salaries. Write two Python programs that will sort the players by their salaries in descending order. The first should use the bubble sort method, and the second should use the sort and lambda methodâ€”print the players' rank, names, and salaries line by line. players_salary_tuple=(('Neyma',83600),('Lionel Messi',1325000),('Gareth Bale',690000),('Kevin de Bruyne',531000),('Robert Lewandowski',483,000),('Cristiano Ronaldo',531000),('Antoine Griezmann',793000))

▶ Assignment 07 - Possible Words

 Given the word list below, which words can be created by using letters from the character list. The same letter can be used more than once. What if you can use the same letter only once? words = ['hello', 'baby', 'momy', 'money', 'love', 'girl', 'go','run','win'] characters = ['e', 'o', 'b', 'a', 'm', 'g', 'l','n','y','r','w']

▶ Assignment 08 - Maximum Oven Temperature

 Given the following array, write a program that finds the largest number in the array without using numpy. oven_temperature = myarray.array('d',[10.1, 15.6, 22.4, 30.5, 27.3, 21.9, 17.7])

▶ Assignment 09 - Sorting a Phone List

 Write a python program that sorts student phones by country code. Copy the data, paste it into a Notepad file and save it under the name student_phone_list.txt. Read the data file. Sort it. Remove the duplicates. Split by country code into multiple lists. Start by creating a dictionary containing list of country codes: country_codes_dict={'961':'Lebanon','971':'UAE','966':'KSA','467':'Sweden','248':'Seychelles','234':'Nigeria','642':'New Zealand'} Phone list 96171404775 96171762030 2482640202 2482539100 9613794439 23471505185 96176612007 96670140947 96176070478 46770615072 96178828854 0447310029391 642108970245 96171103101 96671451900 9613339464 96676915953 96176070478 96171754411 97171331691 97171381150 96176906370 2482642301 9666330002 0016192428888 46770615072 9613536667 966532973094 96171004034 96171178747 2482642301 46760299220 96171449266 96171446396 23470748175 2349036934993 96179156930 96170331262 97171615917 96170999707 Output Out of 41, 3 duplicates found and removed. 38 remain in list. 9 different country Codes found: {'044', '248', '961', '234', '467', '971', '001', '642', '966'} 044 country is found in student list but not found in dictionary. 001 country is found in student list but not found in dictionary. Seychelles 3 ['2482640202', '2482642301', '2482539100'] Lebanon 18 ['9613536667', '9613339464', '96171449266', '9613794439', '96178828854', '96171103101', '96170331262', '96171754411', '96170999707', '96171004034', '96176612007', '96171446396', '96176906370', '96171404775', '96176070478', '96171762030', '96171178747', '96179156930'] Nigeria 3 ['23471505185', '2349036934993', '23470748175'] Sweden 2 ['46760299220', '46770615072'] UAE 3 ['97171331691', '97171381150', '97171615917'] New Zealand 1 ['642108970245'] KSA 5 ['966532973094', '96671451900', '96670140947', '96676915953', '9666330002']

▶ Assignment 10 - Multiplication Table

 Write a program that will generate the multiplication table for given numbers input by users. Send this table to a text file. Separate the values with Tab.

▶ Assignment 11 - Picking Lottery Numbers Randomly

 Write a program that will get from the use the number of lottery balls and the number of picks. Randomly, generate for the user the lottery numbers. Start by importing the random library. Output The highest number in the lottery is: 42 There are: 42 balls in the list. [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42] Your random numbers are with possible duplicates: [22, 26, 19, 5, 33, 5] Your random numbers are without possibility of duplicates: [21, 8, 40, 14, 18, 2]

▶ Assignment 12 - Primary Numbers

 Write a program that will list the primary numbers between two numbers entered by the user.

▶ Assignment 13 - Analyzing Student Grades

 Write a program that will read from a text file the student grades. Use the data below to create the text file. Naji Sfeir, 87 Rita Moussallem, 75 Cynthia Khoury, 65 Ahmed Ali, 91 Mazen Youssef, 70 Hanane Sarrouf, 92 Moustafa Hamoud, 83 Wafa Haidar, 84 Ella Moubarak, 77 The below code will help you get started # Analyzing Student Scores from tkinter import filedialog # Standard GUI library - Object Oriented interface import os import statistics # So we can use the mean function def main():  file_path=filedialog.askopenfilename() # This will open the file dialogue box  filesize = os.path.getsize(file_path) # Calculating the file size  f = open(file_path, 'r') Output The file is not empty. Its size is in bytes: 166 The original student score list: {'Naji Sfeir': '87', 'Rita Moussallem': '75', 'Cynthia Khoury': '65', 'Ahmed Ali': '91', 'Mazen Youssef': '70', 'Hanane Sarrouf': '92', 'Moustafa Hamoud': '83', 'Wafa Haidar': '84', 'Ella Moubarak': '77'} The scores list sorted in ascending order: ['65', '70', '75', '77', '83', '84', '87', '91', '92'] Student names and scores in ascending order: {'Cynthia Khoury': '65', 'Mazen Youssef': '70', 'Rita Moussallem': '75', 'Ella Moubarak': '77', 'Moustafa Hamoud': '83', 'Wafa Haidar': '84', 'Naji Sfeir': '87', 'Ahmed Ali': '91', 'Hanane Sarrouf': '92'} The number of the students in the class: 9 The sum of the scores is: 724 The average score is: 80.4 _____ The END ________

▶ Assignment 14 - Factorials, Combinations, and Permutations

 Use Google to search for topics on Factorials, Combinations, and Permutations. Write a program that will get from the user the number of elements in a set and the number of selected objects. Based on the user input, calculate the factorials, combinations, and permutations.

▶ Assignment 15 - Card Game - Harb

 There a popular card game 'HARB' or War. The following code will help you get started. This game will help you understand how to use FIFO and LIFO queues. Run it and develop it to make it deal properly between the two players. Download cardgame.py