0% found this document useful (0 votes)
11 views

Programming With Python

Uploaded by

Vimalesh Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Programming With Python

Uploaded by

Vimalesh Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

PROGRAMMING WITH PYTHON

PRESENTED BY:
SACHIN KUMAR
ROLL NO. =1873720044
ELECTRICAL ENGINEERING
CONTENTS

1. About Python.
2. Using the Python Interpreter IDLE
3. Various valid arithmetic expressions and implementation in IDLE are
4. Features of Python.
5. Python Interfaces
6. Data types and variables
7. Operators.
8. Numeric data types
9. Sequence data type
10. Decision Making.
11. Control Flow.
12. Constructing module and packages.
13. Object-oriented program
About Python

1. Python is an open source, general purpose programming language that is


easy to read and powerful.
2. It is an interpreted language, which do not need to be compiled to run.
3. Python is high level language that will make a programmer focus on what to
do instead of how to do.
4. Writing programs in Python is less time consuming compared to any other
languages.
Using the Python Interpreter IDLE

IDLE stands for Integrated DeveLopment Enviornment . It is an integrated


development environment for Python which has been bundled with the default
implementation of language.

 IDLE helps you program in Python by:


color-coding your program code
debugging
auto-indent
interactive shell
Various valid arithmetic expressions and
implementation in IDLE are
Features of Python

1. Easy to code.
2. Free and Open Source
3. Object and Oriented Language
4. GUI Programming Support
5. High-Level Language
6. Extensible feature
7. Python is Portable language
8. Python is Integrated language
Python Interfaces

 IDLE - a cross-platform Python development environment.

 Python Win - a Windows only interface to Python.

 Python Shell – running 'python' from the Command Line opens this interactive
shell.
For the exercises, we'll use IDLE, but you can try them all and pick a
favorite.
Data types and variables
Operators
1. Operators are used to perform operations on variables and Operators are the
main building block of any programming language. Operators allow the
programmer to perform different kinds of operations on operands values.
2. Example:
print(10+5)
Python divides the operators in the following groups:
 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Identity operators
 Membership operators
 P Search for anything
 Bitwise operators
Numeric data types
Any representation of data which has numeric value. Python identifies three types of numbers
integer, float and complex number.
• Integer
Positive and negative whole numbers .
Examples: 1234, -234, 0x46 (hexadecimal number), 00123 (octal number)) Note: In C and related
programming languages such as Python, a hexadecimal number is prefixed with Ox and an octal
number is prefixed with 0 or O.
• Float
Real numbers with a floating point representation in which the fractional component is
denoted by a decimal or scientific notation Examples:-55.550,0.005,1.32E10 (scientific notation)
• Complex number
A number with a real and imaginary component is represented
as a+bj in Python where a and b are floats and j=V-1
Examples:4+6j,-2.3+6.4j
Sequence data type

In Python, sequence is the ordered collection of similar or different data types. Sequences
allows to store multiple values in an organized and efficient fashion. There are several
sequence types in Python
 String
 List
 Tuple
String
In python, strings are arrays of bytes representing Unicode characters. A string is a
collection of one or more characters put in single-quote, double quote or triple-quote.
In python there is no character data type, a character is a string of length one. It is
represent by str class. Strings in Python can be created using single quotes or double
quotes or even triple quotes.
Exa: Input:
my_string = 'Hello' print (my string)
my_string = "Hello" print(my_string)
my_string=**Hello** print (my_string)
Output:
Hello
Hello
Hello
Dictionary data type
• Dictionary in Python is an unordered collection of data values, used to store
data values like a map, which unlike other Data Types that hold only single
value as an element, Dictionary holds key:value pair. Key-value is provided in
the dictionary to make it more optimized. Each key-value pair in a Dictionary
is separated by a colon :, whereas each key is separated by a 'comma’.
• Creating Dictionary: A dictionary can be created by placing a sequence of
elements within curly{} braces, seperated by 'comma'. value in the dictionary
is of any datatype and can be duplicated, whereas keys can't be repeated and
must be immutable. Dictionary can be created by built-in function dict(). An
empty dictionary can be created by placing it to curly braces{}.
Input Output:
Decision Making

1. Decisions in a program are used when the program has conditional choices
to execute a code block. Let's take an example of traffic lights, where
different colors of lights lit up in different situations based on the conditions
of the road or any specific rule.
 If statement
 if else statements
 nested if statements
 If-elif ladder
Using conditionals
Programs using if, if- else and elif
A program to check if a number is positive and print the message
Control Flow

1. Loops in programming come into use when we need to repeatedly Execute a


block of statements. For example: Suppose we want to print "Hello World"
10 times. This can be done with the help of loops. The loops in Python are:
 While and while-else loop
 For and for-else loop:
Constructing module and packages
Object-oriented program
 Object-oriented programming (OOP) is a method of structuring a program by
bundling related properties and behaviors into individual object.
Class
 A class is a blueprint for the object. We can think of class as a sketch of a
parrot with labels. It contains all the details about the name, colors, size etc.
Object
 An object (instance) is an instantiation of a class. When class is defined, only
the description for the object is defined. Therefore, no memory or storage is
allocated.
Application of python
THANK
YOU

You might also like