What is Python
•It is general purpose and dynamic language
• It is high level and interpreted programming language
• It is simple and easy to learn
• It is object – oriented programming language
3.
Features of Python
•Readability
• Dynamic typing
• Standard Library
• OOP
• Interpreted Nature
Python Installation
• Visitofficial Python Website
• Select it for windows or Linux
• Run the downloaded installer
and follow the steps.
www.python.org/downloads/
Download python installer that matches your
system requirements
Run the downloaded installer and follow the
instructions to install python
Let’s break downthe code:
• The print() Function is used to display the specified message
or value on the console.
• In this case, we the pass the string “Hello World!” as an
argument. The string is enclosed in double quotes.
• The # symbol indicates a comment in python.
• Comments are ignored by the interpreter and are used to
provide explanations or notes to the code.
8.
Comments in Python
•Comments in Python are used to provide explanatory
notes within the code that are not executed by the
computer
• Types of Comments
1. Single line Comment (#)
2. Multi line Comment (‘’’ ‘’’)
9.
Variables in Python
•Variables are used to store values that can be used later in a
program
• You can easily assign value to variable using “=“ operator
• Example:
Name: Ram
10.
Identifier in Python
•An Identifier is a name used to identify a variable function,
class, module, or any other user-defined object..
• An Identifier can be made up of latters, digits and
underscores ( it must start with a letter or an underscore).
11.
Rules for definingIdentifier in Python
• Valid Characters: a-z, A-Z, 0-9 and underscore.
• Case sensitivity: Python is case- sensitive language.
• Reserved Words: Reserved word can’t used as variable name.
• Length: Identifiers can be of any length.
• Readability: Variable name should be descriptive for more readability.
12.
Examples of validand invalid identifiers
• Valid Identifiers: my_variable, total_sum,
Myclass etc.
• Invalid Identifiers: 123abc, my-variable, if, my
var etc.
13.
Data types ofPython
• Data types in python refer to the different kinds of values that
can be assigned to variables.
• They determine the nature of the data and the operations
that can be performed on them.
• Python provides several build-in data types including numeric,
dictionary, Boolean, set, sequence types.
15.
Numeric Data Types
•Python supports different numerical data types,
including intergers, Floating-point numbers and Complex
numbers.
1. Integers (int): It represent whole numbers.
2. Floating- point number (float): It represent decimal
point numbers.
3. Complex Numbers (complex): Complex numbers have a
real and imaginary part.
16.
Dictionary
• Dictionaries arekey-value pairs enclosed by curly
braces.
• Each value associated with a unique key, allowing
for efficient lookup and retrieval
• Example: person= {“name”: ”John”,
“age”:”25”,
“city”: “Mumbai”
17.
Boolean (bool)
• Booleanrepresents truth values, either True or False.
• They are used for logical operations and conditions.
• Example: is_valid = True
18.
Set
• Sets areunordered collections of unique elements
enclosed in curly braces.
• They are useful for mathematical operations such as
union, intersection and difference.
• Example: fruits = {‘apple’, ‘banana’, ‘orange’}
19.
Sequence Type
• Sequencerepresent a collection of elements and
include data types like strings, lists and tuples.
• String are used to store textual data, while lists and
tuples are used to store ordered collections of items.
20.
• Strings (str):String represent sequences of character
enclosed within single or double quotes
• List (list): Lists are ordered sequences of element
enclosed in square brackets. Each element be of any
data type.
• Tuples (tuple): Tuple are similar to lists but are
immutable, meaning their elements, cannot be
changed once defined. They are enclosed in
paranthesis
21.
Keywords in Python
•Keywords in python are special words that are having specific
meanings and purposed within the python language.
• They are reserved and can’t be used as variable names.
• Keywords are like building block that allow us to create
conditional statements, loops, functions, classes, handle error
and perform other important operations.
22.
List of allkeywords in python
False, await, else, import, pass, none, break, except, in, raise,
True, class, finally, is, return, and, continue, for, lambda, try, as,
def, from, nonlocal, while, assert, del, global, not, with, async,
elif, if, or, yeild,