- Notifications
You must be signed in to change notification settings - Fork1
A 30 days of python programming challenge
codeater7/30-Days-Of-Python
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Congratulations for deciding to participate in a30 days of Python programming challenge . In this challenge you will learn everything you need to be a python programmer and the whole concepts of programming. In the end of the challenge you will get a30DaysOfPython programming challenge certificate.
Python is a high-level programming language. It is an open source. This 30 days 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 days contains several topics with easy-to-understand explanations, real-world examples and many hands on exercises.
This challenge is designed for beginners and professionals who want to learn python programming language.
It is a programming language which is very close to human language and because of that it is easy to learn and easy to use.Python used in varies industries 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.
To run python script you need to install python. Let'sdownload python.If your are a windows user. Click the button encircled in red.
If you are a macOS user. Click the button encircled in red.
To check if python is installed write the following command on your device terminal.
python --version
As you can see from the terminal, I am usingpython 3.7.5 version at the moment. If you mange to see the python version, well done. Python has been installed on your machine. Continue to the next section.
Python is an interpreter scripting language. It means it executes the code line by line. Python comes with aPython 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 cmd and write:
python
The python interactive shell is opened and it is waiting for you to write python code. You will write your python script next to this symbol >>> and then click Enter.Lets write our very first script on the python scripting shell.
Well done, you wrote your first python script on python interactive shell. How do we close this shell ?To close the shell, next to this symbol >> writeexit() command and press Enter.
Now, you knew how to open the python interactive shell and how to exit from it.
Python can give you result if you write scripts what python understands if not it returns errors. Let's make a deliberate mistake and see what python will return.
As you can see from the returned error, python is so clever that it knows the mistake we made and which wasSyntax 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 calleddebugging. Let's debug it by replacing * in place ofx.
Our bug was fixed and the code run 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:SyntaxError, IndexError, ModuleNotFoundError, KeyError, ImportError etc. We will see more about different pythonerror types in later section .
Let's practice more , how to use python interactive shell. Go to your terminal or command prompt and write the wordpython.
The python interactive shell is open and lets do some basic mathematics operations(addition, subtraction, multiplication, division, modulus, exponential).Lets 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
Lets change the above mathematical expressions to code. The python shell has opened and lets write a comment at the very beginning of the shell.Acomment 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 a how you write comment in python
# comment starts with hash# this is a python comment itself because it starts with a (#) symbol
Before we move on to the next section, lets practice more on the python interactive shell. Close the opened shell by writingexit() on the shell and open it again and lets practice how to write text on the python shell.
The python interactive shell is good to try and test small script codes but it won't be for a big project. In real work environment, developers use different code editors to write codes. In this 30 days python programming challenge we will use visual studio code. Visual studio code is a very popular open source text editor. I am a fun of vscode and I would recommend todownload visual studio code, but if you are in favor of other editors, feel free to follow with what you have.
If you installed visual studio code, let's see how to use it.
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 labelled icons.
Create a folder name 30DaysOfPython on your desktop. Then open it using visual studio code.
After you opened you can create file and folder inside the your project directory which is 30DaysOfPython. As you can see below, I have created the very first file, helloworld.py. You can do the same.
After a long day of coding, you want to close your code editor, right ?. This is how you will close the opened project.
Congratulations, you have finished setting up the development environment. Let's start coding.
Comment is very important to make code more readable and to leave to remark in our code. Python doesn't run comment part of our code.Any text starts with hash(#) in python is a comment.
Example:
# This is the first comment# This is the second comment# Python is eating the world
In python there are several types of data types. We will get started with the most common ones.
- 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
A collection of one or more characters under in single or double quote. If a string is more than one sentence we use triple quote.
Example:
'Asabeneh''Finland'"Python""I love teaching""I hope you are enjoying the first day"
A boolean data type is either True or False value.
Example:
True# if the light on, if it is on the value is TrueFalse# if the light off, if it is off the value is False
Python list is an ordered collection which allows to store of different data type items. A list is similar to an array in JavaScript.
Example:
['Banana','Orange','Mango','Avocado']# all the same data type in the list ['Banana',10,False,9.81]# different data types in the list
A python dictionary object is an unordered collection of data in a key:value pair.
Example:
{"name":"Asabeneh","country":"Finland",age:250,"is_married":True}
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','Brook','Abraham','Lidiya')
A set is a collection 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 store only unique elements.
In later sections, we will go in detail in each and every python data types.
Example:
{3.14,9.81,2.7}# order is not important in set
To check the data type of a certain data type we use thetype function. In the following terminal you will see the different python data types:
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 usingprint but on visual studio code to see our result we should use a built in functionprint(some data to print).
Example:helloworld.py
# Day 1 - 30DaysOfPython Challengeprint(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 typesprint(type(10))# Intprint(type(3.14))# Floatprint(type(1+3j))# Complex numberprint(type('Asabeneh'))# Stringprint(type([1,2,3]))# Listprint(type({'name':'Asabeneh'}))#Dictionaryprint(type({9.8,3.14,2.7}))#Tuple
- Check the python version you are using
- Open the python interactive shell and do the following operations. The operands are 3 and 4. Check the example above
- addition(+)
- subtraction(-)
- multiplication(*)
- modulus(%)
- division(/)
- exponential
- floor division operator(//).
- 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
- 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
- Create a folder name day_1 inside 30DaysOfPython folder. Inside day_1 folder, create a file python file helloword.py and repeat question 1, 2, 3 and 4. Remember to useprint() when you are working on a python file. Navigate to the directory where you saved your file, and run it.
About
A 30 days of python programming challenge
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Python100.0%