Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11
Chapter-02
Getting Started with Python
1 Access Learner Academy
Getting Started With Python: Downloading and Installation of Python IDE Step 1) To download and install Python, visit the official website of Python https://www.python.org/downloads/ and choose your version. Step 2) Once the download is completed, run the .exe file to install Python. Now click on Install Now. Step 3) You can see Python installing at this point. Step 4) When it finishes, you can see a screen that says the Setup was successful. Now click on “Close”.
2 Access Learner Academy
How to Install PyCharm Step 1) To download PyCharm visit the website https://www.jetbrains.com/pycharm/download/ and Click the “DOWNLOAD” link under the Community Section. Step 2) Once the download is complete, run the exe for install PyCharm. The setup wizard should have started. Click “Next”. Step 3) On the next screen, Change the installation path if required. Click “Next”. Step 4) On the next screen, you can create a desktop shortcut if you want and click on “Next”. Step 5) Choose the start menu folder. Keep selected JetBrains and click on “Install”.
Step 6) Wait for the installation to finish.
Step 7) Once installation finished, you should receive a message screen that PyCharm is installed. If you want to go ahead and run it, click the “Run PyCharm Community Edition” box first and click “Finish” Step 8) After you click on “Finish,” the Following screen will appear.
3 Access Learner Academy
Anatomy of Python Program The anatomy of python program typically consists of the following components. 1-Shebang line: The shebang line is the first line of the python program and it specifies the location of the python interpreter. This line is optional and is used only in executable scripts. 2 Comments: Comments are used to add human-readable explanation and annotations to the code. In python comments starts with the “#” symbol. 3 Variable: Variables are used to sore data in a program in python variables do not need to be declared with a specific data type, as the type is determined automatically based on the data stored in the variable. 4 Access Learner Academy 4-Operator: Operators are used to perform operations on variable, such as arithmetic's, comparison, and assignment operators. 5-Control Structures: Control structures are used to control the flow of execution in a program. Common control structures in python include “If” statements “for” and “while” loops, and “try” and “except” blocks. 6-Function: Functions are blocks of code that can be executed repeatedly by calling the function name Functions allow code to be organized and reused, and they can accept and return data. 7-Classes and objects: Classes and objects are used to define and create objects, which are instances of a class. Classes can contain data and behavior, and they can be used to models real-word objects and their relationships.
5 Access Learner Academy
8-Modules: Modules are collections of related code that can be imported and used in other python programs. This allows code to be organized and reused across multiples projects Write your first Hello! Script 1 open PyCharm/vs code and click on “Create New Project” 2 Provide the location where you want to create the project. PyCharm will find the python interpreter you have installed earlier. 3 Right click on project name > New> python file. 4 Give name “hello_world.py” and click OK Hello_world.py Print(“Hello World!!!) 6 Access Learner Academy Guidelines for creating Script 2.4.1 Importance of Comments Comments in Python are lines of text in the code that are ignored by the interpreter. They are used to explain the code’s purpose, provide context, and help other developers understand what is happening in the code. In python, comments are denoted by a has symbol(#) at the beginning of the line. Everything that appears after the hash symbol on the same line is considered a comments and will be ignored by the interpreter. 2.4.2 Spacing Spacing in Python is important because it determines the structure of the code and how the interpreter will understand and execute it. In python indentation is used to define blocks of code, such as loops and functions. The level of indentation determines the scope of the code block, and incorrect indentation can lead to syntax errors or unintended behavior.
7 Access Learner Academy
Programming Errors:
2.5.1 Syntax Error:
A syntax error in python is an error in the code that occurs when the python interpreter is unable to parse the code due to incorrect syntax. This type of error usually occurs when there is a typo, missing punctuation, o incorrect indentation in the code, causing the interpreter to raise a “syntax error” exception . To resolve a syntax error you need to correct the incorrect syntax in your code and run it again . 2.5.2 Runtime Error: Runtime errors, also known as exception occur during the execution of a program in python. These errors are caused by conditions that are not anticipated or handled properly in the code, such as trying to access an index that doesn’t exist in a list, dividing by zero, or using an undefined variable.
8 Access Learner Academy
2.4.3 Logical Error
A logical error in python refers to a mistake in the program’s logic that
cause the code to produce unintended results lor behave in an unexpected way.. Some common example of logical errors include: 1 off-by-one errors, where the code is written to process an array with a length of n elements, but only process n-1 of them. 2 Incorrect comparison operators, such as using = instead of == when testing for equality.
Python Programming Illustrated For Beginners & Intermediates“Learn By Doing” Approach-Step By Step Ultimate Guide To Mastering Python: The Future Is Here!
Python Programming Illustrated For Beginners & Intermediates: “Learn By Doing” Approach-Step By Step Ultimate Guide To Mastering Python: The Future Is Here!: The Future Is Here!
Python Programming: 8 Simple Steps to Learn Python Programming Language in 24 hours! Practical Python Programming for Beginners, Python Commands and Python Language
The Best Python Programming Step-By-Step Beginners Guide Easily Master Software engineering with Machine Learning, Data Structures, Syntax, Django Object-Oriented Programming, and AI application
Python Programming Illustrated For Beginners & Intermediates“Learn By Doing” Approach-Step By Step Ultimate Guide To Mastering Python: The Future Is Here!
Python Programming Illustrated For Beginners & Intermediates: “Learn By Doing” Approach-Step By Step Ultimate Guide To Mastering Python: The Future Is Here!: The Future Is Here!
Python Programming: 8 Simple Steps to Learn Python Programming Language in 24 hours! Practical Python Programming for Beginners, Python Commands and Python Language
The Best Python Programming Step-By-Step Beginners Guide Easily Master Software engineering with Machine Learning, Data Structures, Syntax, Django Object-Oriented Programming, and AI application