Python is an interpreted, interactive, object-oriented programming language. It has a simple syntax and is used for rapid application development. Python supports procedural, object-oriented, and functional programming. It has a large standard library and can connect to existing components. Python is easy to read and maintain due to its clear syntax and structure. It is also portable and has broad library support.
This document provides information about Jupyter Notebook, including:
- Jupyter Notebook is an open-source web application for creating and sharing documents containing live code, equations, visualizations, and narrative text.
- It works locally on localhost port 8888 and the easiest way to install it is through Anaconda which includes Jupyter Notebook and popular Python libraries.
- Notebooks use kernels to run code in different programming languages, with IPython being the default Python kernel.
The document provides an introduction to Python programming and application development. It discusses that Python is an interpreted, high-level and object-oriented programming language. It then covers key Python concepts like data types, variables, operators, expressions and statements. The document also lists some common Python applications like data science, web development, AI and more.
4_Introduction to Python Programming.pptxGnanesh12
This document provides an introduction to Python programming. It discusses the fundamentals of computing and problem solving, including algorithms and pseudocodes. It then describes the history and development of the Python programming language. Key features of Python like being easy to learn, cross-platform, and having a large standard library are outlined. Different modes of running Python like interactive and script modes are explained. Finally, it covers basic Python concepts like data types, values, variables, and statements.
This document provides an overview of the Python programming language. It discusses that Python is an interpreted, high-level, general-purpose programming language created by Guido van Rossum in 1991. It is commonly used for web development, software development, data science, and more. The document then covers Python syntax, basic programming concepts like variables and data types, and how to set up a Python environment and write simple Python programs.
Python is a popular, high-level programming language used for web development, software development, data science, and more. It can be used to build both simple scripting programs as well as large-scale applications. Key characteristics of Python include being dynamically typed, having automatic memory management, and using indentation to define code blocks rather than curly braces. Python supports procedural, object-oriented, and functional programming styles and has a large standard library.
Python is a general-purpose, high-level programming language that is widely used for web and application development, data science, and machine learning. It was created by Guido van Rossum in 1991 and takes inspiration from languages like C, Java, Lisp, and Modula-3. Python code is human-readable and has an easy to learn syntax that uses indentation rather than brackets to indicate blocks of code. It supports multiple programming paradigms including object-oriented, imperative, and functional programming.
Python is a high-level, interpreted, interactive and object-oriented scripting language. It is designed to be highly readable using English keywords. Python is interpreted at runtime and does not require compilation. It supports both procedural and object-oriented programming. Python is beginner friendly and supports a wide range of applications. It is portable, extensible, and has a large standard library. Variables are dynamically typed and support integers, floating point numbers, complex numbers, strings, lists, tuples and dictionaries.
Python is a cross-platform programming language that can run on Windows, macOS, Linux, and other platforms. It is free and open-source. While most modern operating systems come with Python pre-installed, it is generally recommended to install the latest version separately. The Thonny IDE is a simple Python IDE that bundles the latest Python version, so it can run Python programs without requiring a separate Python installation. Thonny has features like an easy-to-use debugger and code completion that make it suitable for beginners learning Python.
Python is a high-level programming language for computers that gives instructions on how to do something. It has efficient high-level data structures and a simple but effective object-oriented programming style. Python is a high-level computer programming language that is meant to represent the needs of a problem and looks like natural language or mathematical notation. It is a free language with open-source code. This means that the source code of Python scripts is free to read, change, and share. Python is a language that is used to interpret other languages. Tutorials Freak is an online resource that offers tutorials on cutting-edge software and hardware. It also has a Python tutorial that's been put together by the field's experts in such an easy-to-understand way. It will really make it easier for you to learn.
The document compares interpreters and compilers. It states that interpreters translate code line-by-line while compilers scan the entire program at once. Interpreters have faster analysis time but slower overall execution, while compilers have slower analysis but faster execution. Interpreters do not generate object code so are more memory efficient. Languages like JavaScript, Python and Ruby use interpreters, while C, C++ and Java use compilers.
Interpreter v/s Compiler summarizes the key differences between interpreters and compilers. Interpreters translate programs one statement at a time with no object code generated, making them more memory efficient. Compilers scan entire programs and translate them into machine code at once, generating object code and requiring more memory but providing faster overall execution time. Popular languages like JavaScript, Python, and Ruby use interpreters while C, C++, and Java use compilers.
The document presents an overview of the Python programming language. It discusses that Python was created by Guido van Rossum in 1991 and is commonly used for web development, software development, mathematics, and system scripting. The document then covers various features of Python, including that it is an interpreted, interactive, object-oriented, and high-level language. It also discusses Python's use, history, syntax elements like indentation and comments, variables, data types, and string operations.
This is a presentation which is an introduction to python language.
The presentation is contributed by me for educational purpose and this presentation is
Only introduction.
The Basic python data types and how to use python for Data Science,
Python is a popular programming language that can be used for web development, software development, mathematics, and system scripting. It works on different platforms and has a simple English-like syntax. Python code is executed as it is written due to its interpreter system and can be treated procedurally, object-orientedly, or functionally. It uses indentation rather than brackets to define scope and has built-in data types like strings, integers, lists, dictionaries, sets, booleans, and binary types.
Guido Van Rossum created the Python programming language in 1991. Some key facts about Python's history and creator include that Python was inspired by the ABC programming language and that Van Rossum named Python after the Monty Python comedy group. Python has grown tremendously over the years and is now a simple, general purpose, high-level programming language used widely for tasks like web development, data science, and artificial intelligence.
Introduction to the Python Programming Language. More information can be found at https://www.spiraltrain.nl/course-python-programming/?lang=en
Python is a general-purpose, high-level programming language that is widely used for web and application development, data science, and machine learning. It was created by Guido van Rossum in 1991 and takes inspiration from languages like C, Java, Lisp, and Modula-3. Python code is human-readable and has an easy to learn syntax that uses indentation rather than brackets to indicate blocks of code. It supports multiple programming paradigms including object-oriented, imperative, and functional programming.
Python is a high-level, interpreted, interactive and object-oriented scripting language. It is designed to be highly readable using English keywords. Python is interpreted at runtime and does not require compilation. It supports both procedural and object-oriented programming. Python is beginner friendly and supports a wide range of applications. It is portable, extensible, and has a large standard library. Variables are dynamically typed and support integers, floating point numbers, complex numbers, strings, lists, tuples and dictionaries.
Python is a cross-platform programming language that can run on Windows, macOS, Linux, and other platforms. It is free and open-source. While most modern operating systems come with Python pre-installed, it is generally recommended to install the latest version separately. The Thonny IDE is a simple Python IDE that bundles the latest Python version, so it can run Python programs without requiring a separate Python installation. Thonny has features like an easy-to-use debugger and code completion that make it suitable for beginners learning Python.
Python is a high-level programming language for computers that gives instructions on how to do something. It has efficient high-level data structures and a simple but effective object-oriented programming style. Python is a high-level computer programming language that is meant to represent the needs of a problem and looks like natural language or mathematical notation. It is a free language with open-source code. This means that the source code of Python scripts is free to read, change, and share. Python is a language that is used to interpret other languages. Tutorials Freak is an online resource that offers tutorials on cutting-edge software and hardware. It also has a Python tutorial that's been put together by the field's experts in such an easy-to-understand way. It will really make it easier for you to learn.
The document compares interpreters and compilers. It states that interpreters translate code line-by-line while compilers scan the entire program at once. Interpreters have faster analysis time but slower overall execution, while compilers have slower analysis but faster execution. Interpreters do not generate object code so are more memory efficient. Languages like JavaScript, Python and Ruby use interpreters, while C, C++ and Java use compilers.
Interpreter v/s Compiler summarizes the key differences between interpreters and compilers. Interpreters translate programs one statement at a time with no object code generated, making them more memory efficient. Compilers scan entire programs and translate them into machine code at once, generating object code and requiring more memory but providing faster overall execution time. Popular languages like JavaScript, Python, and Ruby use interpreters while C, C++, and Java use compilers.
The document presents an overview of the Python programming language. It discusses that Python was created by Guido van Rossum in 1991 and is commonly used for web development, software development, mathematics, and system scripting. The document then covers various features of Python, including that it is an interpreted, interactive, object-oriented, and high-level language. It also discusses Python's use, history, syntax elements like indentation and comments, variables, data types, and string operations.
This is a presentation which is an introduction to python language.
The presentation is contributed by me for educational purpose and this presentation is
Only introduction.
The Basic python data types and how to use python for Data Science,
Python is a popular programming language that can be used for web development, software development, mathematics, and system scripting. It works on different platforms and has a simple English-like syntax. Python code is executed as it is written due to its interpreter system and can be treated procedurally, object-orientedly, or functionally. It uses indentation rather than brackets to define scope and has built-in data types like strings, integers, lists, dictionaries, sets, booleans, and binary types.
Guido Van Rossum created the Python programming language in 1991. Some key facts about Python's history and creator include that Python was inspired by the ABC programming language and that Van Rossum named Python after the Monty Python comedy group. Python has grown tremendously over the years and is now a simple, general purpose, high-level programming language used widely for tasks like web development, data science, and artificial intelligence.
Introduction to the Python Programming Language. More information can be found at https://www.spiraltrain.nl/course-python-programming/?lang=en
The Pala kings were people-protectors. In fact, Gopal was elected to the throne only to end Matsya Nyaya. Bhagalpur Abhiledh states that Dharmapala imposed only fair taxes on the people. Rampala abolished the unjust taxes imposed by Bhima. The Pala rulers were lovers of learning. Vikramshila University was established by Dharmapala. He opened 50 other learning centers. A famous Buddhist scholar named Haribhadra was to be present in his court. Devpala appointed another Buddhist scholar named Veerdeva as the vice president of Nalanda Vihar. Among other scholars of this period, Sandhyakar Nandi, Chakrapani Dutta and Vajradatta are especially famous. Sandhyakar Nandi wrote the famous poem of this period 'Ramcharit'.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 795 from Texas, New Mexico, Oklahoma, and Kansas. 95 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
How to Set warnings for invoicing specific customers in odooCeline George
Odoo 16 offers a powerful platform for managing sales documents and invoicing efficiently. One of its standout features is the ability to set warnings and block messages for specific customers during the invoicing process.
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schoolsdogden2
Algebra 1 is often described as a “gateway” class, a pivotal moment that can shape the rest of a student’s K–12 education. Early access is key: successfully completing Algebra 1 in middle school allows students to complete advanced math and science coursework in high school, which research shows lead to higher wages and lower rates of unemployment in adulthood.
Learn how The Atlanta Public Schools is using their data to create a more equitable enrollment in middle school Algebra classes.
GDGLSPGCOER - Git and GitHub Workshop.pptxazeenhodekar
This presentation covers the fundamentals of Git and version control in a practical, beginner-friendly way. Learn key commands, the Git data model, commit workflows, and how to collaborate effectively using Git — all explained with visuals, examples, and relatable humor.
Title: A Quick and Illustrated Guide to APA Style Referencing (7th Edition)
This visual and beginner-friendly guide simplifies the APA referencing style (7th edition) for academic writing. Designed especially for commerce students and research beginners, it includes:
✅ Real examples from original research papers
✅ Color-coded diagrams for clarity
✅ Key rules for in-text citation and reference list formatting
✅ Free citation tools like Mendeley & Zotero explained
Whether you're writing a college assignment, dissertation, or academic article, this guide will help you cite your sources correctly, confidently, and consistent.
Created by: Prof. Ishika Ghosh,
Faculty.
📩 For queries or feedback: [email protected]
How to Subscribe Newsletter From Odoo 18 WebsiteCeline George
Newsletter is a powerful tool that effectively manage the email marketing . It allows us to send professional looking HTML formatted emails. Under the Mailing Lists in Email Marketing we can find all the Newsletter.
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsesushreesangita003
what is pulse ?
Purpose
physiology and Regulation of pulse
Characteristics of pulse
factors affecting pulse
Sites of pulse
Alteration of pulse
for BSC Nursing 1st semester
for Gnm Nursing 1st year
Students .
vitalsign
The ever evoilving world of science /7th class science curiosity /samyans aca...Sandeep Swamy
The Ever-Evolving World of
Science
Welcome to Grade 7 Science4not just a textbook with facts, but an invitation to
question, experiment, and explore the beautiful world we live in. From tiny cells
inside a leaf to the movement of celestial bodies, from household materials to
underground water flows, this journey will challenge your thinking and expand
your knowledge.
Notice something special about this book? The page numbers follow the playful
flight of a butterfly and a soaring paper plane! Just as these objects take flight,
learning soars when curiosity leads the way. Simple observations, like paper
planes, have inspired scientific explorations throughout history.
Understanding P–N Junction Semiconductors: A Beginner’s GuideGS Virdi
Dive into the fundamentals of P–N junctions, the heart of every diode and semiconductor device. In this concise presentation, Dr. G.S. Virdi (Former Chief Scientist, CSIR-CEERI Pilani) covers:
What Is a P–N Junction? Learn how P-type and N-type materials join to create a diode.
Depletion Region & Biasing: See how forward and reverse bias shape the voltage–current behavior.
V–I Characteristics: Understand the curve that defines diode operation.
Real-World Uses: Discover common applications in rectifiers, signal clipping, and more.
Ideal for electronics students, hobbyists, and engineers seeking a clear, practical introduction to P–N junction semiconductors.
As of Mid to April Ending, I am building a new Reiki-Yoga Series. No worries, they are free workshops. So far, I have 3 presentations so its a gradual process. If interested visit: https://www.slideshare.net/YogaPrincess
https://ldmchapels.weebly.com
Blessings and Happy Spring. We are hitting Mid Season.
This chapter provides an in-depth overview of the viscosity of macromolecules, an essential concept in biophysics and medical sciences, especially in understanding fluid behavior like blood flow in the human body.
Key concepts covered include:
✅ Definition and Types of Viscosity: Dynamic vs. Kinematic viscosity, cohesion, and adhesion.
⚙️ Methods of Measuring Viscosity:
Rotary Viscometer
Vibrational Viscometer
Falling Object Method
Capillary Viscometer
🌡️ Factors Affecting Viscosity: Temperature, composition, flow rate.
🩺 Clinical Relevance: Impact of blood viscosity in cardiovascular health.
🌊 Fluid Dynamics: Laminar vs. turbulent flow, Reynolds number.
🔬 Extension Techniques:
Chromatography (adsorption, partition, TLC, etc.)
Electrophoresis (protein/DNA separation)
Sedimentation and Centrifugation methods.
Python_Programming_PPT Basics of python programming language
1. •PYTHO N AS A PRO G RAM MI NG LANG UAG E
•PYTHO N DATA TYPE S
•STR IN GS: BASI C O PER ATIO N, O PER ATOR S, PR ECEDE NCE AND ASSO CIATI VI TY
•I NDE XI NG AND SL ICI N G
•STR IN G ME THO DS, STRI N G FO R MATTI NG EXPR ESSI O NS, STR I NG F OR MATTI NG
M ETHO D CAL LS
•CO MM ENTS
•EXPR ESSI O NS
•VAR IAB LE S,ASSI G NM ENTS
•CO NTRO L STRU CTUR ES
•LO OPI NG AND BR ANCHI N G STATEME NTS
PYTHON PROGRAMMING
UNIT-I:
2. Python Introduction
• Python is a dynamic, high level, free open source and interpreted
programming language. It supports object-oriented programming
as well as procedural oriented programming.
• Python is a programming language that includes features of C and
Java. It provides the style of writing an elegant code like C, and for
object-oriented programming, it offers classes and objects like
Java.
• It was created by Guido van Rossum, and released in 1991.
• Python is commonly used for developing websites and software,
game development, data analysis, and data visualization.
2
3. Python Interpreter
• Machines only understand machine code or machine language, a
language represented by strings of bits — 1s and 0s.
• A python interpreter is a computer program that converts each
high-level program statement into machine code.
• An interpreter translates the command that you write out into
code that the computer can understand.
• Python is the most famous example of a high-level language.
3
4. Features of Python
1. Free and Open Source:
• Python language is freely available at the official website and you
can download it. Since it is open-source, this means that source
code is also available to the public. So you can download it, use it
as well as share it.
2. Easy to code:
• Python is a high-level programming language. Python is very easy
to learn the language as compared to other languages like C, C#,
Javascript, Java, etc. It is very easy to code in the Python
language and anybody can learn Python basics in a few hours or
days. It is also a developer-friendly language.
4
5. Features of Python
3. Easy to Read:
• Python’s syntax is straightforward. The code block is defined by the
indentations rather than by semicolons or brackets.
4. Object-Oriented Language:
• One of the key features of Python is Object-Oriented programming.
Python supports object-oriented language and concepts of classes,
object encapsulation, etc.
5. GUI Programming Support:
• Graphical User interfaces can be made using a module such
as PyQt5, PyQt4, wxPython, or Tk in Python. PyQt5 is the most
popular option for creating graphical apps with Python.
5
6. Features of Python
6. High-Level Language:
• Python is a high-level language. When we write programs in
Python, we do not need to remember the system architecture, nor
do we need to manage the memory.
7. Large Community Support:
• Python has gained popularity over the years. Our questions are
constantly answered by the enormous StackOverflow community.
8. Easy to Debug:
• Excellent information for mistake tracing. You will be able to quickly
identify and correct the majority of your program’s issues once you
understand how to interpret Python’s error traces.
6
7. Features of Python
9. Python is a Portable language:
• If we have Python code for Windows and if we want to run this code
on other platforms such as Linux, Unix, and Mac then we do not need
to change it, we can run this code on any platform.
10. Python is an Integrated language:
• Python is also an Integrated language because we can easily integrate
Python with other languages like C, C++, etc.
11. Interpreted Language:
• Python is an Interpreted Language because Python code is executed
line by line at a time. like other languages C, C++, Java, etc. there is no
need to compile Python code this makes it easier to debug our code.
The source code of Python is converted into an immediate form
called bytecode. 7
8. Features of Python
12. Large Standard Library:
• Python has a large standard library that provides a rich set of modules
and functions so you do not have to write your own code for every
single thing. There are many libraries present in Python such as regular
expressions, unit-testing, web browsers, etc.
13. Dynamically Typed Language:
• Python is a dynamically-typed language. That means the type for a
variable is decided at run time not in advance because of this feature
we don’t need to specify the type of variable.
15. Allocating Memory Dynamically:
• In Python, the variable data type does not need to be specified. The
memory is automatically allocated to a variable at runtime when it is
given a value. 8
10. First Python Program Execution
1) Interactive Mode Programming
• Invoking the interpreter without passing a script file as a
parameter brings up the following prompt
10
11. First Python Program Execution
2) Script Mode Programming
• Invoking the interpreter with a script parameter begins execution
of the script and continues until the script is finished. When the
script is finished, the interpreter is no longer active.
• Let us write a simple Python program in a script. Python files
have extension .py. Type the following source code in a test.py
file −
• print ("Hello, Python!“)
11
12. Python Indentation
• Indentation refers to the spaces at the beginning of a code line.
• Where in other programming languages the indentation in code
is for readability only, the indentation in Python is very
important.
• Python uses indentation to indicate a block of code.
• Example
• if 5>2:
print("Five is greater than two!")
12
13. Python Comment
• Comments can be used to explain Python code.
• Comments can be used to make the code more readable.
• Comments can be used to prevent execution when testing code.
• Creating a Comment: Comments starts with a #, and Python will
ignore them.
• Example
• #This is a comment
print("Hello, World!")
13
14. Python Multi Line Comment
• To add a multiline comment:
1. insert a # for each line.
2. you can add a multiline string (triple quotes) in your code, and
place your comment inside it
• Example
• """
This is a comment
written in
more than just one line
"""
print("Hello, World!")
14
15. Python Variables
• Variables are containers for storing data values.
• Unlike other programming languages, Python has no command
for declaring a variable.
• A variable is created the moment you first assign a value to it.
• Variables do not need to be declared with any particular type and
can even change type after they have been set.
• Example: Assign Value to Variable
• x = 5
y = "John"
print(x)
print(y)
15
16. Python Identifiers
• Identifier is a user-defined name given to a variable, function,
class, module, etc.
• The identifier is a combination of character digits and an
underscore.
• They are case-sensitive i.e., ‘num’ and ‘Num’ and ‘NUM’ are
three different identifiers.
16
17. Python Identifiers
• Rules for Naming Python Identifiers
1. It cannot be a reserved python keyword.
2. It should not contain white space.
3. It can be a combination of A-Z, a-z, 0-9, or underscore.
4. It should start with an alphabet character or an underscore ( _ ).
5. It should not contain any special character other than an
underscore ( _ ).
17
19. Python Operators
• Operators in general are used to perform operations on values
and variables. These are standard symbols used for the purpose
of logical and arithmetic operations.
• OPERATORS: These are the special symbols. Eg- + , * , /, etc.
• OPERAND: It is the value on which the operator is applied.
• Types of Operators in Python
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Bitwise Operators
5. Assignment Operators
6. Identity Operators and Membership Operators
19
20. Python Arithmetic Operators
20
Operator Description Syntax
+ Addition: adds two operands x + y
– Subtraction: subtracts two operands x – y
* Multiplication: multiplies two operands x * y
/
Division (float): divides the first operand by
the second
x / y
//
Division (floor): divides the first operand by
the second
x // y
%
Modulus: returns the remainder when the
first operand is divided by the second
x % y
** Power: Returns first raised to power second x ** y
21. Python Comparison Operators
21
Operator Description Syntax
>
Greater than: True if the left operand is greater than the
right
x > y
< Less than: True if the left operand is less than the right x < y
== Equal to: True if both operands are equal x == y
!= Not equal to – True if operands are not equal x != y
>=
Greater than or equal to True if the left operand is greater
than or equal to the right
x >= y
<=
Less than or equal to True if the left operand is less than or
equal to the right
x <= y
22. Python Logical Operators
22
Operator Description Syntax
and Logical AND: True if both the operands are true x and y
Or Logical OR: True if either of the operands is true x or y
not Logical NOT: True if the operand is false not x
23. Python Bitwise Operators
23
Operator Description Syntax
& Bitwise AND x & y
| Bitwise OR x | y
~ Bitwise NOT ~x
^ Bitwise XOR x ^ y
>> Bitwise right shift x>>
<< Bitwise left shift x<<
24. Python Assignment Operators
24
Operator Description Syntax
= Assign the value of the right side of the expression to the left side operand x = y + z
+=
Add AND: Add right-side operand with left-side operand and then assign to left
operand
a+=b a=a+b
-=
Subtract AND: Subtract right operand from left operand and then assign to left
operand
a-=b a=a-b
*=
Multiply AND: Multiply right operand with left operand and then assign to left
operand
a*=b a=a*b
/= Divide AND: Divide left operand with right operand and then assign to left operand a/=b a=a/b
%=
Modulus AND: Takes modulus using left and right operands and assign the result to
left operand
a%=b a=a%b
//=
Divide(floor) AND: Divide left operand with right operand and then assign the
value(floor) to left operand
a//=b a=a//b
**=
Exponent AND: Calculate exponent(raise power) value using operands and assign
value to left operand
a**=b a=a**b
25. Python Identity Operators
• In Python, is and is not are the identity operators both are used to
check if two values are located on the same part of the memory.
• Two variables that are equal do not imply that they are identical.
• is : True if the operands are identical
• is not: True if the operands are not identical
25
26. Python Membership Operators
• In Python, in and not in are the membership operators that are used
to test whether a value or variable is in a sequence.
• in :True if value is found in the sequence
• not in :True if value is not found in the sequence
26
27. Python Operator Precedence
27
Operator Description Operator Description
** Exponentiation I Bitwise OR
+x, -x Positive, negative <, , >=, !=, == Comparison operators
*, /, //, %
Multiplication, division, floor
division, modulo
is, is not Identity operators
+, – Addition, subtraction in, not in Membership operators
<> Bitwise shift operators not Logical NOT
& Bitwise AND and Logical AND
^ Bitwise XOR or Logical OR
29. Python Data Types
• Variables can store data of different types, and different types can do
different things.
• Python has the following data types built-in by default, in these
categories:
1. Text Type: str
2. Numeric Types: int, float, complex
3. Sequence Types: list, tuple, range
4. Mapping Type: dict
5. Set Types: set, frozenset
6. Boolean Type: bool
29
30. Python Data Types
• Getting the Data Type:
• You can get the data type of any object by using the type() function:
• Example: Print the data type of the variable x:
x = 5
print(type(x))
Output:
<class 'int'>
30
31. Python Data Types
31
Example Data Types
x = "Hello World" str
x = 20 int
x = 20.5 float
x = 1j complex
x = ["apple", "banana", "cherry"] list
x = ("apple", "banana", "cherry") tuple
x = range(6) range
x = {"name" : "John", "age" : 36} dict
x = {"apple", "banana", "cherry"} set
x = frozenset({"apple", "banana", "cherry"}) frozenset
x = True bool
32. Python Strings
• A String is a data structure in Python that represents a sequence of
characters.
• It is an immutable data type, meaning that once you have created a
string, you cannot change it.
• Strings are used widely in many different applications, such as storing
and manipulating text data, representing names, addresses, and
other types of data that can be represented as text.
• Python does not have a character data type, a single character is
simply a string with a length of 1.
32
33. Python Strings
Creating a String in Python:
• Strings in Python can be created using single quotes or double
quotes or even triple quotes. Let us see how we can define a string in
Python.
Example:
String1 = 'Welcome to DSU‘
print(String1)
Output:
Welcome to DSU
33
34. Python String Indexing
• Accessing characters in Python String (String Indexing)
• In Python, individual characters of a String can be accessed by using
the method of Indexing.
• Indexing allows negative address references to access characters
from the back of the String, e.g. -1 refers to the last character, -2
refers to the second last character, and so on.
• While accessing an index out of the range will cause an IndexError.
• Only Integers are allowed to be passed as an index, float or other
types that will cause a TypeError.
34
36. Python String Indexing
36
Example:
String1 = "GeeksForGeeks"
print("Initial String: ")
print(String1)
print("nFirst character of String is: ")
print(String1[0])
print("nLast character of String is: ")
print(String1[-1])
Output:
Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
37. Python String Indexing
• Reversing a Python String:
• By accessing characters from a string, we can also reverse strings in
Python.
• We can Reverse a string by using String slicing method.
37
Example:
str = "geeksforgeeks"
print(str[::-1])
Output:
skeegrofskeeg
38. Python String Slicing
• String Slicing:
• In Python, the String Slicing method is used to access a range of
characters in the String.
• Slicing in a String is done by using a Slicing operator, i.e., a colon (:).
• String returned after slicing includes the character at the start index
but not the character at the last index.
• In this example, we will use the string-slicing method to extract a
substring of the original string. The [3:12] indicates that the string
slicing will start from the 3rd index of the string to the 12th index,
(12th character not including). We can also use negative indexing in
string slicing.
38
39. Python String Slicing
39
Example:
String1 = "GeeksForGeeks"
print("Initial String: ")
print(String1)
print("nSlicing characters from 3-12: ")
print(String1[3:12])
print("nSlicing characters between " +
"3rd and 2nd last character: ")
print(String1[3:-2])
Output:
Initial String:
GeeksForGeeks
Slicing characters from 3-12:
ksForGeek
Slicing characters between 3rd and 2nd
last character:
ksForGee
40. Python String
• Deleting from a String:
• In Python, the Updation or deletion of characters from a String is not
allowed.
• This will cause an error because item assignment or item deletion
from a String is not supported.
• Although deletion of the entire String is possible with the use of a
built-in del keyword.
• This is because Strings are immutable, hence elements of a String
cannot be changed once assigned. Only new strings can be
reassigned to the same name.
40
41. Python String
• Updating a character
• A character of a string can be updated in Python by first converting
the string into a Python List and then updating the element in the
list.
• As lists are mutable in nature, we can update the character and then
convert the list back into the String.
• Another method is using the string slicing method. Slice the string
before the character you want to update, then add the new
character and finally add the other part of the string again by string
slicing.
41
42. Python String
42
# Python Program to Update character of a String
String1 = "Hello, I'm a Geek"
print("Initial String: ")
print(String1)
list1 = list(String1)
list1[2] = 'p'
String2 = ''.join(list1)
print("nUpdating character at 2nd Index: ")
print(String2)
String3 = String1[0:2] + 'p' + String1[3:]
print(String3)
Output:
Initial String:
Hello, I'm a Geek
Updating character at 2nd Index:
Heplo, I'm a Geek
Heplo, I'm a Geek
43. Python String
• Updating Entire String:
• As Python strings are immutable in nature, we cannot update the
existing string. We can only assign a completely new value to the
variable with the same name.
43
String1 = "Hello, I'm a Geek"
print("Initial String: ")
print(String1)
String1 = "Welcome to the Geek World"
print("nUpdated String: ")
print(String1)
Output:
Initial String:
Hello, I'm a Geek
Updated String:
Welcome to the Geek World
44. Python String
• Deleting a character
• Python strings are immutable, that means we cannot delete a
character from it. When we try to delete the character using
the del keyword, it will generate an error.
• So we will first slice the string up to the character that we want to
delete and then concatenate the remaining string next from the
deleted character.
44
45. Python String
45
Example:
String1 = "Hello, I'm a Geek"
print("Initial String: ")
print(String1)
String2 = String1[0:2] + String1[3:]
print("nDeleting character at 2nd
Index: ")
print(String2)
Output:
Initial String:
Hello, I'm a Geek
Deleting character at 2nd Index:
Helo, I'm a Geek
46. Python String Escape Sequences
• Escape Sequencing in Python:
• While printing Strings with single and double quotes in it
causes SyntaxError because String already contains Single and
Double Quotes and hence cannot be printed with the use of either of
these.
• Hence, to print such a String either Triple Quotes are used or Escape
sequences are used to print Strings.
• Escape sequences start with a backslash and can be interpreted
differently.
• If single quotes are used to represent a string, then all the single
quotes present in the string must be escaped and the same is done
for Double Quotes.
46
47. Python String Escape Sequences
47
String1 = '''I'm a "Geek"'''
print("Initial String with use of Triple Quotes: ")
print(String1)
# Escaping Single Quote
String1 = 'I'm a "Geek"'
print("nEscaping Single Quote: ")
print(String1)
# Escaping Double Quotes
String1 = "I'm a "Geek""
print("nEscaping Double Quotes: ")
print(String1)
# Printing Paths with the use of Escape Sequences
String1 = "C:PythonGeeks"
print("nEscaping Backslashes: ")
print(String1)
# Printing Paths with the use of Tab
String1 = "HitGeeks"
print("nTab: ")
print(String1)
# Printing Paths with the use of New Line
String1 = "PythonnGeeks"
print("nNew Line: ")
print(String1)
Output:
Initial String with use of Triple Quotes:
I'm a "Geek"
Escaping Single Quote:
I'm a "Geek"
Escaping Double Quotes:
I'm a "Geek"
Escaping Backslashes:
C:PythonGeeks
Tab:
Hi Geeks
New Line:
Python
Geeks
48. Python String Escape Sequences
48
String1 = '''I'm a "Geek"'''
print("Initial String with use of Triple Quotes: ")
print(String1)
# Escaping Single Quote
String1 = 'I'm a "Geek"'
print("nEscaping Single Quote: ")
print(String1)
# Escaping Double Quotes
String1 = "I'm a "Geek""
print("nEscaping Double Quotes: ")
print(String1)
# Printing Paths with the use of Escape Sequences
String1 = "C:PythonGeeks"
print("nEscaping Backslashes: ")
print(String1)
# Printing Paths with the use of Tab
String1 = "HitGeeks"
print("nTab: ")
print(String1)
# Printing Paths with the use of New Line
String1 = "PythonnGeeks"
print("nNew Line: ")
print(String1)
Output:
Initial String with use of Triple Quotes:
I'm a "Geek"
Escaping Single Quote:
I'm a "Geek"
Escaping Double Quotes:
I'm a "Geek"
Escaping Backslashes:
C:PythonGeeks
Tab:
Hi Geeks
New Line:
Python
Geeks
49. Python Conditionals
• Python supports the usual logical conditions from mathematics :
These conditions can be used in several ways, most commonly in "if
statements" and loops.
• Equals: a == b
• Not Equals: a != b
• Less than: a < b
• Less than or equal to: a <= b
• Greater than: a > b
• Greater than or equal to: a >= b
49
50. Python If Condition
• An "if statement" is written by using the if keyword.
• Example of If statement:
• a = 33
b = 200
if b > a:
print("b is greater than a")
• Output:
• b is greater than a
50
51. Python Elif Condition
• The elif keyword is Python's way of saying "if the previous
conditions were not true, then try this condition".
• Example
• a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
51
52. Python Else Condition
• The else keyword catches anything which isn't caught by the
preceding conditions.
• Example
• a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
52
53. Python And Condition
• The and keyword is a logical operator, and is used to combine
conditional statements:
• Example
• Test if a is greater than b, AND if c is greater than a:
• a = 200
b = 33
c = 500
if a > b and c > a:
print("Both conditions are True")
• Output:
• Both conditions are True
53
54. Python Or Condition
• The or keyword is a logical operator, and is used to combine
conditional statements:
• Example
• Test if a is greater than b, OR if a is greater than c:
• a = 200
b = 33
c = 500
if a > b or a > c:
print("At least one of the conditions is True")
• Output:
• At least one of the conditions is True
54
55. Python not Condition
• The not keyword is a logical operator, and is used to reverse the
result of the conditional statement:
• Example
• Test if a is NOT greater than b:
• a = 33
b = 200
if not a > b:
print("a is NOT greater than b")
• Output:
• a is NOT greater than b
55
56. Python Nested if Condition
• You can have if statements inside if statements, this is called nested
if statements.
• Example
• x = 41
if x > 10:
print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
• Output:
• Above ten,
and also above 20! 56
57. Python Loops
• A loop is an instruction that repeats multiple times as long as some
condition is met.
• Types of Python Loops:
• While Loop
• For Loop
• Break Statement
57
58. While Loop
• The while loop is used to execute a set of statements as long as a
condition is true.
58
59. While Loop
• While Loop Syntax:
while expression:
statement(s)
59
Example:
count = 0
while (count < 3):
count = count + 1
print("Hello GM")
Output:
Hello GM
Hello GM
Hello GM
60. For Loop
• A for loop in Python is used to iterate over a sequence (list, tuple,
set, dictionary, and string).
60
61. For Loop
• For Loop Syntax:
for iterator_var in sequence:
statements(s)
61
Example:
n = 4
for i in range(0, n):
print(i)
Output:
0 1 2 3
62. Nested Loop
• Python programming language allows to use one loop inside another
loop which is called nested loop.
• Nested Loops Syntax:
for iterator_var in sequence:
for iterator_var in sequence:
statements(s)
statements(s)
62
64. Continue Statement
• The continue statement in Python returns the control to the
beginning of the loop.
64
Example:
for letter in 'geeksfor':
if letter == 'e' or letter == 's':
continue
print('Current Letter :', letter)
Output:
Current Letter : g
Current Letter : k
Current Letter : f
Current Letter : o
Current Letter : r
65. Break Statement
• The break statement in Python brings control out of the loop.
65
Example:
for letter in 'geeksforgeeks':
if letter == 'e' or letter == 's':
break
print('Current Letter :', letter)
Output:
Current Letter : e
66. Pass Statement
• We use pass statement in Python to write empty loops. Pass is also
used for empty control statements, functions and classes.
• Example: This Python code iterates through the characters of the
string ‘geeksforgeeks’ using a ‘for' loop. However, it doesn’t perform
any specific action within the loop, and the ‘pass' statement is used.
After the loop, it prints “Last Letter :” followed by the last character
in the string, which is ‘s’.
66
Example:
for letter in 'geeksforgeeks':
pass
print('Last Letter :', letter)
Output:
Last Letter : s
67. Questions From Unit-1
1) Explain Features of Python Programming Language.
2) Explain different types of comments in Python.
3) What is Variable? How to assign Value to variable in python?
4) What is Python identifier? Write rules for naming the identifiers. Give some examples
of legal names of identifiers.
5) What are Python Operators? Explain Types of operators in detail with example.
6) What is difference between == and ‘is’ operator in python?
7) Explain Built-in data types of python.
8) What is string in python? Explain String Indexing and slicing with example.
9) Explain Escape Sequences in python.
10)Explain if, elif and else with example.
11)Explain while loop and for loop with syntax and example.
12)Explain usage of continue, break and pass keyword in python.
67