Python Programming-1.pptx of python by computer

sharanyarashmir5 196 views 40 slides May 01, 2024
Slide 1
Slide 1 of 40
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
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40

About This Presentation

If you're referring to acquisitions made by companies prior to the implementation of the Goods and Services Tax (GST), here are some acquisitions that occurred before GST was introduced:

Facebook (Meta Platforms, Inc.):
Instagram (Acquired in 2012)
WhatsApp (Acquired in 2014)
Oculus VR (Acquire...


Slide Content

PYTHON Programming

Introduction to Python

01 General Purpose python language is designed for developing software that applies in a wide range of application domains 02 Interpreted python uses an interpreter to translate the instruction into machine la n . g ua g e line by line. 03 High level Language python is very easy to learn and closer to human-readable lan g ua g e, w hi c h is ea s y t o un d er s t and 04 Object – Oriented Python is a model of programming which aims to work with the real-world entities in programming. Such as inheritance, data hiding, polymorphism etc. The main concept of OOP (Object Oriented Programming) is to bind a specific portion of data and functions together so that no other part, of rest of the code, can access them

History of Python 2008 Python 3.0 (also called "Py3K") was released. It was designed to rectify the fundamental flaw of the language . The implementation of Python was started in December 1989 by Guido Van Rossum at CWI in Netherland beautifully designed. 1989 Python 1.0 was released with new features . 1994 Python 3.8 was released 2019 1991 Guido Van Rossum published the code (labeled version 0.9.0) to alt.sources . 1980 Python laid its foundation in the late 1980

P y tho n V er si o n Released Date Python 1.0 January 1994 Python 1.5 December 31, 1997 Python 1.6 September 5, 2000 Python 2.0 October 16, 2000 Python 2.1 April 17, 2001 Python 2.2 December 21, 2001 Python 2.3 J ul y 29 , 2003 Python 2.4 November 30, 2004 Python 2.5 S e p t e m b e r 19 , 2006 Python 2.6 October 1, 2008 Python programming language is being updated regularly with new features and supports. There are lots of update in Python versions, started from 1994 to current release. A list of Python versions with its released date is given below. P y tho n V er si o n Re l ea s ed D a t e Python 2.7 July 3, 2010 Python 3.0 December 3, 2008 Python 3.1 J un e 27 , 2009 Python 3.2 February 20, 2011 Python 3.3 Se p t e m b e r 29 , 2012 Python 3.4 March 16, 2014 Python 3.5 Se p t e m b e r 13 , 2015 Python 3.6 December 23, 2016 Python 3.7 J un e 27 , 2018 Python 3.8 October 14, 2019

Applications of Python Web and Internet Development. Scientific and Numeric Operating. Software Deve lop me n t E n gin eer in g Application Education B u s i n es s A pp li ca t i on s . E n t er p r i s e Applications. S T A R T F I N I SH

Key Features of Python Easy to Learn - It is very easy to learn and understand. People of any age group can learn this language very easily. Its language syntax is very simple to understand. Free and Open Source - It is a free and open-source programming language and its source code is also available to the public. You don't have to acquire any licence for its uses . Interpreted Language - An interpreter is a translator that translates the code line by line into machine level language and this makes it easier to debug the code. Python uses an interpreter to translate the program from a high-level language to a machine level language so that the computer can understand our instruction . Large Standard Library - A Large Standard Library of already written modules and functions of Python is available in the market, making the coding easier and quicker in every aspect . Object-Oriented Language - It supports object-oriented programming which includes concepts of classes, data abstraction, polymorphism, encapsulation etc. GUI Programming Support - Python supports programming in Graphical Users Interfaces using already existing modules, such as PyQT5, wxPython, Tickler etc . Portable Language - Python supports portability for example if we have a python code for windows and we want to run this code on another platform such as, Unix, Linux or Mac then we do not need to change it, we can run this code on any platform . High-Level Language - Python is a high-level language. It means that it is easy to code, and once we write programs in python, we do not need to worry about the system architecture, nor do we need to manage the memory in python manually. Support Language Integration - Python supports language integration because we can easily integrated python with other languages like C, C++ etc.

Installation of Python Installation on Windows Visit the link https:// www.python.org/downloads/ to download the latest release of Python. In this process, we will install Python 3.8.6 on our Windows operating system. When we click on the above link, it will bring us the following page. . Step - 1: Select the Python's version to download. Click on the download button

Step - 2: Click on the Install Now D o ubl e - c l i ck t h e e x e c u t a bl e f i l e , w h i ch i s downloaded; the following window will open. Select Customize installation and proceed. C l i ck o n t h e A d d P a t h c h e ck b o x , i t w i l l s e t the Python path automatically.

Step - 3 Installation in Process

Now, try to run python on the command prompt. Type the command python -version in case of python3.

downlo a d and install Python Latest Version on Android Download Pydroid 3 – IDE for Python 3 app from Play store T o i n s t a l l Py d r oi d a p p g o t o pl a y s t o re link here –

After installation is complete, Run the app and it will show as installing python.

Working with python Input and output in Python Environment Setup for Coding in Python Environment Setup is the process of installation and configuration of software required for coding programs in Python. To start coding in Python we need two things: Text Editor - A text editor is a software used for writing code in Python. Example Windows Notepad, Notepad++, vim for Linux. Python Interpreter - A Python interpreter is a software required to interpret your source code into machine- executable code. use free software for Python programming. This type of software is known as an IDE (Integrated Development Environment). Free IDE software available on the internet for Python programming. You can download any of the software mentioned below for Python programming. S p y d e r PyDev IDLE (This is the default IDE that comes with Python.) V i s u a l S t ud i o Co d e Wing Free Version

print() Function and its Use The print() function is used in the Python program to print text as well as the value of the variables on the screen. Example : print('Hello World') print("Hello World") Output : Hello World Hello World Example : print('Sunday') p r i n t ( ' M o n da y ' ) OUTPUT : Sunday M ond a y

VARIABLES IN PYTHON A variable in Python is just a human-readable name used to store data in computer memory. A variable is also used in a computer program to store, read and change the data in computer memory. A variable is also known as Identifier because it is used for identifying values in a computer program. When you declare a variable in Python programming language, it means that you are asking the operating system to reserve a piece of memory with that variable name for storing data.

What is meant by Data Data is a collection of facts or figure or combination of both (facts and figure). Facts - Any word that is consist of only alphabets is known as Facts. Example: john, mango, book, etc these words are consist of only alphabets. So each of them is a data but consist of Facts. Figure - Any number whether it is whole number or real number is a Figure. Example: 15, 84.13, 5486, etc. So each of them is a data but consist of Figure . Combination of Both (Facts and Figure) - Anything which is consist of Facts and Figure is known as Alphanumeric Text. Example: 13street, alpha56, dx14c5, etc . So each of them is a data but consist of Alphanumeric Text. Note : Like other programming languages like C , C++, Python do not have any commands to create variable

What is Data Type Data Type in Python is used to classify the value stored in a variable during the program execution. Whenever a variable is defined in Python, the interpreter allocates some memory according to the data stored in the variable. Python supports the following data types given below .

Data Types in Python Integer - It is used to storewhole numbers such as 56, 8, 493 etc. Complex Number - It is used to store complex number which is created from real numbers such as 9+21j, -3-9j, -72+81j etc. A complex number has two parts a real part and an imaginary part . Floa t - It is used to storenumbers with a decimal point such as 2.3, 18.12, 294.0 etc. Boolean - It is used to store logical values such as True or False.String - It is used to store text such as "hello", "Peter", "4586" etc. Dictionary - It is used to store an unordered key and its value pairs such as {"name" : "frankie" , "age" : "18"}. Set - It is used to store an unordered and unindexed collection of unique objects such as {"a", "b“, "c"}. List - It is used to storean ordered and changeable collection of objects such as ["apple", "banana", "cherry"]. Tuple - It is used to storean ordered and unchangeable collection of objects such as (15, "Albert", 18.20)

To declare an integer and float variable in python. x=5 x = 4 . 2 3 Explanation : we have declared a variable x and assigned the value 5 in it so, it becomes an integer variable. We can use the same variable to store another type of value in it as you can see, on line number 2 we have used the same variable name x to store a float value 4.23 in it so, now the variable x becomes a float variable To declare a string variable in python . y=“Python” in it so, it becomes a string Explanation : we have declared a variable y and assigned a string value python variable . 3. To declare a boolean variable in python . z=True Explanation : we have declared a variable z and assigned a boolean value True in it so, it becomes a boolean variable. 4. To declare multiple variables and assign multiple values in a single line. a, b, c, d = 5, 4.26, "apple", True a=5; b=4.26; c="apple"; d=True Explanation :We have declared 4 variables a, b, c, d and assigned values 5, 4.26, "apple", True respectively in a single line in two different ways, one using comma (,) and another using semicolon (;). We Can use any one method that you like. So the value of a is 5, value of b is 4.23, value of c is apple and value of d is True which becomes a boolean variable.

5. To declare same value in multiple variables in a single line . a=b=c=15 Explanation : We have declared 3 variables a, b, c and assigned the same value 15 in all the variables respectively in a single line. I N P U T A N D O U T P U T I N PY T H ON E n v i r o nm e nt S e t u p f o r P yt h o n P r o g r a mm i n g Environment Setup is the process of installation and configuration of softwarerequired for coding programs in Python. To start coding in Python we need two things: Text Editor - A text editor is a software used for writing code in Python. Example Windows Notepad, Notepad++, vim for Linux. Python Interpreter - A Python interpreter is a software required to interpret your source code into machine-executable code.

PRINT() FUNCTION : The print() function is used in the Python program to print text as well as the value of t h e v a r i a b l e s o n t h e s c r een . Program to print Sunday and Monday on separate lines using single print() function. print('Sunday\nMonday') print('\nSunday\n\n\nMonday') OUTPUT : Sunday M o nd a y Sunday M o nd a y (Use of sep (separator) parameter in print() function) Python program to show the use of sep parameter in print() function . print('Sunday','Monday',sep='-') print('18','06','2020',sep='/') p r i n t ( ' i s T hu rs d a y ' ) OUTPUT :\ S u nd a y - M ond a y 18/06/2020 is Thursday

3. (Use of end parameter in print() function) Py t h o n p r o g r a m t o s h o w t h e u se o f e n d p a r a m e t e r i n p r i n t () f un c t io n . p r i n t ( ' S un da y ' , ' M o nd a y ' , en d = ' - ') print('Tuesday') print('Wednesday') OUTPUT : S u nd a y M o nd a y - T u e s d a y Wednesday 4. (Use of sep and end parameters together in print() function) print(‘sudha',’nmkrv',sep='',end='@') print(‘gmail.com') OUTPUT : [email protected] 5. Python program to print integer and float data type values on the screen. a=10 b=20.32 print('a=',a,' b=',b,sep='',end='\n\n') print('a=',a,sep='') print('b=',b,sep='') b = 2 OUTPUT :a=10 a=10 b=20.32

Print Python Variables and Literals Program : number = -10.6 name = " Programiz " # print literals print(5) # print variables print(number) print(‘the value of the variable number is ‘ , number) print(name) OUTPUT : 5 10.6 Programiz

Print Concatenated Strings We can also join two strings together inside the  print()   statement print( 'Python is ' + 'awesome .') OutPut : Python is awesome Output formatting Sometimes we would like to format our output to make it look attractive. This can be done by using the  str.format ()  method. x = 5 y = 10 print('The value of x is {} and y is {}'.format( x,y ))

Python Input :  Python provides us with two inbuilt functions to read the input from the keyboard.    input ( prompt ) raw_input ( prompt ) input ():  This function first takes the input from the user and converts it into a string. The type of the returned object always will be <class ‘ str ’>. It does not evaluate the expression it just returns the complete statement as String Input(prompt) prompt is the string we wish to display on the screen. It is optional # using input() to take user input num = input('Enter a number: ') print('You Entered:', num ) Enter a number: 10 You Entered: 10

Operators : Operators are special symbols that perform operations on variables (name of the values ) and values Example : print(5 + 6) >> 11 Here + is a operator and 5 , 6 are values Example :2 : x =10 y =12 print( x+y ) Types of Python Operators The different types of python operators are as follows : 1. Arithmetic operators 2. Assignment Operators 3. Comparison Operators 4. Logical Operators 5. Bitwise Operators 6. Special Ope rators

1. Python Arithmetic Operators Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, etc. For example, Operator Operation Example + Addition 5 + 2 = 7 - Subtraction 4 - 2 = 2 * Multiplication 2 * 3 = 6 / Division 4 / 2 = 2 // Floor Division 10 // 3 = 3 % Modulo 5 % 2 = 1 ** Power 4 ** 2 = 16

a . Arithmetic Operators Arithmetic operations between two operands are carried out using arithmetic operators. Operator Description + (Addition) It is used to add two operands. For example, if a = 10, b = 10 => a+b = 20 - (Subtraction) It is used to subtract the second operand from the first operand. If the first operand is less than the second operand, the value results negative. For example, if a = 20, b = 5 => a - b = 15 / (divide) It returns the quotient after dividing the first operand by the second operand. For example, if a = 20, b = 10 => a/b = 2.0 * (Multiplication) It is used to multiply one operand with the other. For example, if a = 20, b = 4 => a * b = 80 % (reminder) It returns the reminder after dividing the first operand by the second operand. For example, if a = 20, b = 10 => a%b = 0 ** (Exponent) As it calculates the first operand's power to the second operand, it is an exponent operator. // (Floor division) It provides the quotient's floor value, which is obtained by dividing the two operands.

a = 7 b = 2 # addition (Comment Statement ) print ('Sum: ', a + b) # subtraction print ('Subtraction: ', a - b) # multiplication print ('Multiplication: ', a * b) # division print ('Division: ', a / b) # floor division print ('Floor Division: ', a // b) # modulo print ('Modulo: ', a % b) # a to the power b print ('Power: ', a ** b) Program to perform Arithmetic operation:

Write a python program to add three numbers . Write a Python program to calculate the simple interest of an amount : Formula : ( pxnxr ) / 100. 3. Write a python program to calculate the area of a circle : Formula : (3.14 x r 2 ) 4. Write a python program to calculate area of a square: Formula : a 2 5. Write a python program to add 5 subjects marks and find the average. Write a python program to find the percentage of the above total marks obtained by the student. Write a python program to calculate the area of a triangle : Formula : 1/2xbxh (b is breath and h is height )

2. Python Assignment Operators Assignment operators are used to assign values to variables. For example, Var x=5 list of different assignment operators Operator Name Example = Assignment Operator a = 7 += Addition Assignment a += 1 # a = a + 1 -= Subtraction Assignment a -= 3 # a = a - 3 *= Multiplication Assignment a *= 4 # a = a * 4 /= Division Assignment a /= 3 # a = a / 3 %= Remainder Assignment a %= 10 # a = a % 10 **= Exponent Assignment a **= 10 # a = a ** 10

Operator Description = It assigns the value of the right expression to the left operand. += By multiplying the value of the right operand by the value of the left operand, the left operand receives a changed value. For example, if a = 10, b = 20 => a+ = b will be equal to a = a+ b and therefore, a = 30. -= It decreases the value of the left operand by the value of the right operand and assigns the modified value back to left operand. For example, if a = 20, b = 10 => a- = b will be equal to a = a- b and therefore, a = 10. *= It multiplies the value of the left operand by the value of the right operand and assigns the modified value back to then the left operand. For example, if a = 10, b = 20 => a* = b will be equal to a = a* b and therefore, a = 200. %= It divides the value of the left operand by the value of the right operand and assigns the reminder back to the left operand. For example, if a = 20, b = 10 => a % = b will be equal to a = a % b and therefore, a = 0. **= a**=b will be equal to a=a**b, for example, if a = 4, b =2, a**=b will assign 4**2 = 16 to a. //= A//=b will be equal to a = a// b, for example, if a = 4, b = 3, a//=b will assign 4//3 = 1 to a.

# assign 10 to a (Comment statement : this statement will not be printed on the screen ) a = 10 # assign 5 to b b = 5 # assign the sum of a and b to a a += b # a = a + b p rint(a) a -= b # a = a – b p rint(a) a *= b # a = a * b p rint(a) a %= b # a= a% b p rint(a) a **=b # a= a ** b print(a) a//=b # a= a//b p rint(a)

Operator Description == If the value of two operands is equal, then the condition becomes true. != If the value of two operands is not equal, then the condition becomes true. <= The condition is met if the first operand is smaller than or equal to the second operand. >= The condition is met if the first operand is greater than or equal to the second operand. > If the first operand is greater than the second operand, then the condition becomes true. < If the first operand is less than the second operand, then the condition becomes tru Comparison operator Comparison operators compare the values of the two operands and return a true or false Boolean value in accordance. The following table lists the comparison operators.

a = 5 b = 2 # equal to operator print('a == b =', a == b) # not equal to operator print('a != b =', a != b) # greater than operator print('a > b =', a > b) # less than operator print('a < b =', a < b) # greater than or equal to operator print('a >= b =', a >= b) # less than or equal to operator print('a <= b =', a <= b) OUTPUT : a == b = False a != b = True a > b = True a < b = False a >= b = True a <= b = False

F o r m a t t i n g S y m b o l s Description %d Used for integer printing %i Used for integer printing %f Used for decimal number (float) printing %c Used for character printing %s Used for string (text) printing %o Used for octal number printing %x Used for lowercase hexadecimal number printing %X Used for uppercase hexadecimal number printing L i s t o f F o r m a tt in g S y m bol s list of symbols used with % operator for formatting outputs on the screen.

Escape Sequence Character in Python An escape sequence is a sequence of characters that does not represent itself when used inside a character or string literal, but is translated into another character or a sequence of characters that may be difficult or impossible to represent directly Escape Sequence Character Description \n Insert a linefeed (new line) \r Insert a carriage return \f Insert a form feed \b Insert a backspace \t Insert a tab \\ Insert a backslash \" Insert a double quote \' Insert a single quote

Frequently Asked Questions What is Python Programming Language History of Python Applications of Python Key Features of Python Installation of Python on a Computer How to use output function to print / write the values in Python How to use input function to read the integer vales in python How to do read(input ) and write (output) the string value in python What are variables What are Data What are the different data types in python Write a note on data types What are different types of operators supported in python, explain with examples