https://github.com/Asabeneh/30-Days-Of-Python Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} Asabeneh / 30-Days-Of-Python Public * Notifications * Fork 4.5k * Star 20.4k 30 days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than100 days, follow your own pace. 20.4k stars 4.5k forks Star Notifications * Code * Issues 64 * Pull requests 115 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights Asabeneh/30-Days-Of-Python This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 3 branches 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/A] Use Git or checkout with SVN using the web URL. [gh repo clone Asaben] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @Asabeneh Asabeneh Merge pull request #328 from kjs1019/kjs1019 ... c6f7d5b Dec 11, 2022 Merge pull request #328 from kjs1019/kjs1019 Add Day 3 Korean translation c6f7d5b Git stats * 390 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time 01_Day_Introduction minor fixes July 10, 2021 05:32 02_Day_Variables_builtin_functions HOF July 8, 2021 05:29 03_Day_Operators testimonial November 17, 2021 22:48 04_Day_Strings testimonial November 17, 2021 22:48 05_Day_Lists Typo error December 9, 2022 14:44 06_Day_Tuples second version -set July 7, 2021 04:54 07_Day_Sets HOF July 8, 2021 05:29 08_Day_Dictionaries minor fixes July 10, 2021 05:32 09_Day_Conditionals typo fix July 8, 2021 04:21 10_Day_Loops HOF July 8, 2021 05:29 11_Day_Functions testimonial November 17, 2021 22:50 12_Day_Modules minor fixes July 10, 2021 05:32 13_Day_List_comprehension list comprehensin July 8, 2021 04:37 14_Day_Higher_order_functions HOF July 8, 2021 05:29 15_Day_Python_type_errors python type error July 8, 2021 06:06 16_Day_Python_date_time datetime July 8, 2021 06:21 17_Day_Exception_handling exception July 8, 2021 06:40 18_Day_Regular_expressions regex July 8, 2021 07:20 19_Day_File_handling python for web July 10, 2021 01:52 20_Day_Python_package_manager packages July 8, 2021 22:16 21_Day_Classes_and_objects classes July 8, 2021 22:35 22_Day_Web_scraping scrapping July 8, 2021 23:04 23_Day_Virtual_environment vitrual env July 8, 2021 23:16 24_Day_Statistics pandas July 9, 2021 02:10 25_Day_Pandas pandas July 9, 2021 02:10 26_Day_Python_web python for web July 10, 2021 01:52 27_Day_Python_with_mongodb mongodb July 10, 2021 04:19 28_Day_API building API July 10, 2021 04:50 29_Day_Building_API final July 10, 2021 05:00 30_Day_Conclusions testimonial November 17, 2021 22:50 Korean Merge pull request #329 from jshyun1/master December 11, 2022 02:13 data day 25 December 14, 2019 02:33 files day 19 December 7, 2019 23:30 images second version list July 7, 2021 04:14 korean Update 03_operators.md December 8, 2022 21:52 mypackage day 21 fixes December 10, 2019 21:42 numpy_files day 24 December 12, 2019 23:59 old_files each challenge has been separated April 29, 2020 09:44 python_for_web day 25 fixes December 15, 2019 14:34 test_files day 24 fixes December 13, 2019 21:04 .gitignore some changes July 6, 2021 20:55 mymodule.py day 12 December 1, 2019 00:03 numpy.md typo fixes August 5, 2020 23:25 readme.md minor fixes July 10, 2021 05:57 View code [ ] 30 Days Of Python 30 Days Of Python: Day 1 - Introduction Day 1 Welcome Introduction Why Python ? Environment Setup Installing Python Python Shell Installing Visual Studio Code How to use visual studio code Basic Python Python Syntax Python Indentation Comments Data types Number String Booleans List Dictionary Tuple Set Checking Data types Python File Exercises - Day 1 Exercise: Level 1 Exercise: Level 2 Exercise: Level 3 readme.md 30 Days Of Python # Day Topics 01 Introduction 02 Variables, Built-in Functions 03 Operators 04 Strings 05 Lists 06 Tuples 07 Sets 08 Dictionaries 09 Conditionals 10 Loops 11 Functions 12 Modules 13 List Comprehension 14 Higher Order Functions 15 Python Type Errors 16 Python Date time 17 Exception Handling 18 Regular Expressions 19 File Handling 20 Python Package Manager 21 Classes and Objects 22 Web Scraping 23 Virtual Environment 24 Statistics 25 Pandas 26 Python web 27 Python with MongoDB 28 API 29 Building API 30 Conclusions HAPPY CODING Support the author to create more educational materials Paypal Logo 30 Days Of Python: Day 1 - Introduction [6874747073] Twitter Follow [Author: Asabeneh Yetayeh Second Edition: July, 2021 ] Day 2 >> 30DaysOfPython * 30 Days Of Python * Day 1 + Welcome + Introduction + Why Python ? + Environment Setup o Installing Python o Python Shell o Installing Visual Studio Code # How to use visual studio code + Basic Python o Python Syntax o Python Indentation o Comments o Data types # Number # String # Booleans # List # Dictionary # Tuple # Set o Checking Data types o Python File + Exercises - Day 1 o Exercise: Level 1 o Exercise: Level 2 o Exercise: Level 3 Day 1 Welcome Congratulations for deciding to participate in a 30 days of Python programming challenge . In this challenge you will learn everything you need to be a python programmer and the whole concept of programming. In the end of the challenge you will get a 30DaysOfPython programming challenge certificate. If you would like to actively engage in the challenge, you may join the 30DaysOfPython challenge telegram group. Introduction Python is a high-level programming language for general-purpose programming. It is an open source, interpreted, objected-oriented programming language. Python was created by a Dutch programmer, Guido van Rossum. The name of Python programming language was derived from a British sketch comedy series, Month Python's Flying Circus. The first version was released on February 20, 1991. This 30 days of Python challenge will help you learn the latest version of Python, Python 3 step by step. The topics are broken down into 30 days, where each day contains several topics with easy-to-understand explanations, real-world examples, many hands on exercises and projects. This challenge is designed for beginners and professionals who want to learn python programming language. It may take 30 to 100 days to complete the challenge, people who actively participate on the telegram group have a high probability of completing the challenge. If you are a visual learner or in favor of videos, you may get started with this Python for Absolute Beginners video. Why Python ? It is a programming language which is very close to human language and because of that it is easy to learn and use. Python is used by various industries and companies (including Google). It has been used to develop web applications, desktop applications, system adminstration, and machine learning libraries. Python is highly embraced language in the data science and machine learning community. I hope this is enough to convince you to start learning Python. Python is eating the world and you are killing it before it eats you. Environment Setup Installing Python To run a python script you need to install python. Let's download python. If your are a windows user. Click the button encircled in red. installing on Windows If you are a macOS user. Click the button encircled in red. installing on Windows To check if python is installed write the following command on your device terminal. python --version Python Version As you can see from the terminal, I am using Python 3.7.5 version at the moment. Your version of Python might be different from mine by but it should be 3.6 or above. If you mange to see the python version, well done. Python has been installed on your machine. Continue to the next section. Python Shell Python is an interpreted scripting language, so it does not need to be compiled. It means it executes the code line by line. Python comes with a Python Shell (Python Interactive Shell). It is used to execute a single python command and get the result. Python Shell waits for the Python code from the user. When you enter the code, it interprets the code and shows the result in the next line. Open your terminal or command prompt(cmd) and write: python Python Scripting Shell The Python interactive shell is opened and it is waiting for you to write Python code(Python script). You will write your Python script next to this symbol >>> and then click Enter. Let us write our very first script on the Python scripting shell. Python script on Python shell Well done, you wrote your first Python script on Python interactive shell. How do we close the Python interactive shell ? To close the shell, next to this symbol >> write exit() command and press Enter. Exit from python shell Now, you know how to open the Python interactive shell and how to exit from it. Python will give you results if you write scripts that Python understands, if not it returns errors. Let's make a deliberate mistake and see what Python will return. Invalid Syntax Error As you can see from the returned error, Python is so clever that it knows the mistake we made and which was Syntax Error: invalid syntax. Using x as multiplication in Python is a syntax error because (x) is not a valid syntax in Python. Instead of (x) we use asterisk (*) for multiplication. The returned error clearly shows what to fix. The process of identifying and removing errors from a program is called debugging. Let us debug it by putting * in place of x. Fixing Syntax Error Our bug was fixed, the code ran and we got a result we were expecting. As a programmer you will see such kind of errors on daily basis. It is good to know how to debug. To be good at debugging you should understand what kind of errors you are facing. Some of the Python errors you may encounter are SyntaxError, IndexError, NameError, ModuleNotFoundError, KeyError, ImportError, AttributeError , TypeError, ValueError, ZeroDivisionError etc. We will see more about different Python error types in later sections. Let us practice more how to use Python interactive shell. Go to your terminal or command prompt and write the word python. Python Scripting Shell The Python interactive shell is opened. Let us do some basic mathematical operations (addition, subtraction, multiplication, division, modulus, exponential). Let us do some maths first before we write any Python code: * 2 + 3 = 5 * 3 - 2 = 1 * 3 * 2 = 6 * 3 / 2 = 1.5 * 3 ^ 2 = 3 x 3 = 9 In python we have the following additional operations: * 3 % 2 = 1 => which means finding the remainder * 3 // 2 = 1 => which means removing the remainder Let us change the above mathematical expressions to Python code. The Python shell has been opened and let us write a comment at the very beginning of the shell. A comment is a part of the code which is not executed by python. So we can leave some text in our code to make our code more readable. Python does not run the comment part. A comment in python starts with hash(#) symbol. This is how you write a comment in python # comment starts with hash # this is a python comment, because it starts with a (#) symbol Maths on python shell Before we move on to the next section, let us practice more on the Python interactive shell. Close the opened shell by writing exit() on the shell and open it again and let us practice how to write text on the Python shell. Writing String on python shell Installing Visual Studio Code The Python interactive shell is good to try and test small script codes but it will not be for a big project. In real work environment, developers use different code editors to write codes. In this 30 days of Python programming challenge we will use visual studio code. Visual studio code is a very popular open source text editor. I am a fan of vscode and I would recommend to download visual studio code, but if you are in favor of other editors, feel free to follow with what you have. Visual Studio Code If you installed visual studio code, let us see how to use it. If you prefer a video, you can follow this Visual Studio Code for Python Video tutorial How to use visual studio code Open the visual studio code by double clicking the visual studio icon. When you open it you will get this kind of interface. Try to interact with the labeled icons. Visual studio Code Create a folder named 30DaysOfPython on your desktop. Then open it using visual studio code. Opening Project on Visual studio Opening a project After opening it you will see shortcuts for creating files and folders inside of 30DaysOfPython project's directory. As you can see below, I have created the very first file, helloworld.py. You can do the same. Creating a python file After a long day of coding, you want to close your code editor, right? This is how you will close the opened project. Closing project Congratulations, you have finished setting up the development environment. Let us start coding. Basic Python Python Syntax A Python script can be written in Python interactive shell or in the code editor. A Python file has an extension .py. Python Indentation An indentation is a white space in a text. Indentation in many languages is used to increase code readability, however Python uses indentation to create block of codes. In other programming languages curly brackets are used to create blocks of codes instead of indentation. One of the common bugs when writing python code is wrong indentation. Indentation Error Comments Comments are very important to make the code more readable and to leave remarks in our code. Python does not run comment parts of our code. Any text starting with hash(#) in Python is a comment. Example: Single Line Comment # This is the first comment # This is the second comment # Python is eating the world Example: Multiline Comment Triple quote can be used for multiline comment if it is not assigned to a variable """This is multiline comment multiline comment takes multiple lines. python is eating the world """ Data types In Python there are several types of data types. Let us get started with the most common ones. Different data types will be covered in detail in other sections. For the time being, let us just go through the different data types and get familiar with them. You do not have to have a clear understanding now. Number * Integer: Integer(negative, zero and positive) numbers Example: ... -3, -2, -1, 0, 1, 2, 3 ... * Float: Decimal number Example ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ... * Complex Example 1 + j, 2 + 4j String A collection of one or more characters under a single or double quote. If a string is more than one sentence then we use a triple quote. Example: 'Asabeneh' 'Finland' 'Python' 'I love teaching' 'I hope you are enjoying the first day of 30DaysOfPython Challenge' Booleans A boolean data type is either a True or False value. T and F should be always uppercase. Example: True # Is the light on? If it is on, then the value is True False # Is the light on? If it is off, then the value is False List Python list is an ordered collection which allows to store different data type items. A list is similar to an array in JavaScript. Example: [0, 1, 2, 3, 4, 5] # all are the same data types - a list of numbers ['Banana', 'Orange', 'Mango', 'Avocado'] # all the same data types - a list of strings (fruits) ['Finland','Estonia', 'Sweden','Norway'] # all the same data types - a list of strings (countries) ['Banana', 10, False, 9.81] # different data types in the list - string, integer, boolean and float Dictionary A Python dictionary object is an unordered collection of data in a key value pair format. Example: { 'first_name':'Asabeneh', 'last_name':'Yetayeh', 'country':'Finland', 'age':250, 'is_married':True, 'skills':['JS', 'React', 'Node', 'Python'] } Tuple A tuple is an ordered collection of different data types like list but tuples can not be modified once they are created. They are immutable. Example: ('Asabeneh', 'Pawel', 'Brook', 'Abraham', 'Lidiya') # Names ('Earth', 'Jupiter', 'Neptune', 'Mars', 'Venus', 'Saturn', 'Uranus', 'Mercury') # planets Set A set is a collection of data types similar to list and tuple. Unlike list and tuple, set is not an ordered collection of items. Like in Mathematics, set in Python stores only unique items. In later sections, we will go in detail about each and every Python data type. Example: {2, 4, 3, 5} {3.14, 9.81, 2.7} # order is not important in set Checking Data types To check the data type of certain data/variable we use the type function. In the following terminal you will see different python data types: Checking Data types Python File First open your project folder, 30DaysOfPython. If you don't have this folder, create a folder name called 30DaysOfPython. Inside this folder, create a file called helloworld.py. Now, let's do what we did on python interactive shell using visual studio code. The Python interactive shell was printing without using print but on visual studio code to see our result we should use a built in function *print(). The print() built-in function takes one or more arguments as follows print('arument1', 'argument2', 'argument3'). See the examples below. Example: The file name is helloworld.py # Day 1 - 30DaysOfPython Challenge print(2 + 3) # addition(+) print(3 - 1) # subtraction(-) print(2 * 3) # multiplication(*) print(3 / 2) # division(/) print(3 ** 2) # exponential(**) print(3 % 2) # modulus(%) print(3 // 2) # Floor division operator(//) # Checking data types print(type(10)) # Int print(type(3.14)) # Float print(type(1 + 3j)) # Complex number print(type('Asabeneh')) # String print(type([1, 2, 3])) # List print(type({'name':'Asabeneh'})) # Dictionary print(type({9.8, 3.14, 2.7})) # Set print(type((9.8, 3.14, 2.7))) # Tuple To run the python file check the image below. You can run the python file either by running the green button on Visual Studio Code or by typing python helloworld.py in the terminal . Running python script You are amazing. You have just completed day 1 challenge and you are on your way to greatness. Now do some exercises for your brain and muscles. Exercises - Day 1 Exercise: Level 1 1. Check the python version you are using 2. Open the python interactive shell and do the following operations. The operands are 3 and 4. + addition(+) + subtraction(-) + multiplication(*) + modulus(%) + division(/) + exponential(**) + floor division operator(//) 3. Write strings on the python interactive shell. The strings are the following: + Your name + Your family name + Your country + I am enjoying 30 days of python 4. Check the data types of the following data: + 10 + 9.8 + 3.14 + 4 - 4j + ['Asabeneh', 'Python', 'Finland'] + Your name + Your family name + Your country Exercise: Level 2 1. Create a folder named day_1 inside 30DaysOfPython folder. Inside day_1 folder, create a python file helloworld.py and repeat questions 1, 2, 3 and 4. Remember to use print() when you are working on a python file. Navigate to the directory where you have saved your file, and run it. Exercise: Level 3 1. Write an example for different Python data types such as Number (Integer, Float, Complex), String, Boolean, List, Tuple, Set and Dictionary. 2. Find an Euclidian distance between (2, 3) and (10, 8) CONGRATULATIONS ! Day 2 >> About 30 days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than100 days, follow your own pace. Topics github python heroku flask mongodb numpy pandas python3 matplotlib 30-days-of-python Resources Readme Stars 20.4k stars Watchers 648 watching Forks 4.5k forks Releases No releases published Packages 0 No packages published Contributors 10 * @Asabeneh * @pkiczko * @kjs1019 * @jshyun1 * @Rasbin * @ShinYooJung * @mesfint * @Sumanth-Talluri * @jchuerva * @arctouch-jonathansouza Languages * Python 94.7% * CSS 2.7% * HTML 2.6% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.