Introduction-to-Python-Programming1.pptx

vijayalakshmi257551 406 views 20 slides Sep 18, 2024
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

Introduction-to-Python-Programming


Slide Content

Introduction to Python Programming Python is a powerful and versatile programming language that has become increasingly popular in recent years. It's known for its clear syntax and beginner-friendliness, making it ideal for both learning and building complex applications. Python has a huge community of developers, making it easy to find help and resources. by Vijaya Lakshmi A

Session ObjectivesSession Objectives Learning python data types

What is Python? Python is a high-level, interpreted programming language. Its design focuses on code readability and simplicity. This makes it easier to write and maintain code, even for complex projects. Python can be used for various tasks, including web development, data science, machine learning, scripting, and more. Easy to Learn Python's syntax is intuitive and straightforward, making it a great choice for beginners. Versatile It can be used for a wide range of applications, from simple scripts to complex software. Large Community There's a vast community of Python developers, providing ample resources and support. Cross-Platform Python runs on various operating systems, including Windows, macOS, Linux, and Unix.

Why Learn Python? Learning Python opens doors to exciting career opportunities and personal projects. With its widespread use, Python skills are highly sought after in various industries. Furthermore, Python's versatility allows you to explore different areas of programming and pursue your interests. 1 High Demand Python skills are in high demand in the tech industry, leading to lucrative career paths. 2 Versatile Applications Python can be used for web development, data analysis, automation, and more. 3 Growing Community The Python community is vast and supportive, providing abundant resources and help. 4 Open Source Python is an open-source language, meaning it's free to use and modify.

Invented at Netherlands, early 90s by Guido van Rossum Named after Monty Python Open sourced, Scalable, object oriented and functional Programming language Used by Google as one of its official programming language Increasingly popular Python - Introduction

Python’s Benevolent Dictator For Life “Python is an experiment in how much freedom program-mers need. Too much freedom and nobody can read another's code; too little and expressive-ness is endangered.” - Guido van Rossum

http:// docs.python.org /

Call python program via the python interpreter % python fact.py Make a python file directly executable by Adding the appropriate path to your python interpreter as the first line of your file #!/usr/bin/python Making the file executable % chmod a+x fact.py Invoking file from Unix command line % fact.py Running Programs on UNIX

In interactive mode, you type Python programs, and the interpreter displays the result. $ python 3 >>> 2 + 3 >>> 5 python3 command enters into python prompt. >>> is called the Python prompt in linux. The interpreter evaluates the expression and replies. New prompt indicates it is ready for more input. Working directly in the interpreter is convenient for testing short bits of code because we get immediate feedback. Interactive Mode

The set of Python instructions are written in a file called as program with extension .py also called as script. The program file is referred as source code. The compiler is used to convert the source code to byte code. The interpreter is used to interpret the byte code and produce the result. $ g ed i t f i r s t . py # F i r s t Program Script Mode

Indentation matters to code meaning Block structure indicated by indentation First assignment to a variable creates it Variable types don’t need to be declared. Python figures out the variable types on its own. Assignment is = and comparison is == For numbers + - * / % are as expected Special use of + for string concatenation and % for string formatting (as in C’s printf) Logical operators are words ( and, or, not ) not symbols The basic printing command is print Enough to Understand the Code

Naming Rules Names are case sensitive and cannot start with a number. They can contain letters, numbers, and underscores. bob Bob _bob _2_bob_ bob_2 BoB There are some reserved words: and, assert, break, class, continue, def, del, elif , else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while

Operators and Expressions Operators are symbols that perform specific operations on values. Expressions are combinations of operators and values that result in a new value. Understanding these is essential for writing calculations, comparisons, and logical operations. Operator Description + Addition - Subtraction * Multiplication / Division == Equality != Inequality < Less than > Greater than

In Python, the input() function is used to take input from the user. This function reads a line from input (usually from the keyboard), converts it into a string, and returns it. Basic Usage of input() Here is the basic syntax for the input() function: By default, input() returns a string. If you need to handle other data types (like integers or floats), you'll need to convert the input using typecasting:

In Python, the print() function is the most commonly used statement for displaying output. It allows you to print text, variables, and formatted data to the console.

s imple Python program to add two numbers

Total Salary Calculation

Python Libraries and Frameworks Python's vast collection of libraries and frameworks extends its capabilities. Libraries provide pre-written code for various tasks, saving you time and effort. Frameworks provide a structure for building applications, simplifying the development process. Web Development Frameworks like Django and Flask simplify web application development. Data Science Libraries like NumPy, Pandas, and Matplotlib are essential for data analysis and visualization. Machine Learning Libraries like scikit-learn, TensorFlow, and PyTorch empower you to build machine learning models.

Python - Introduction Interactive Mode Script Mode Debugging Summary
Tags