0% found this document useful (0 votes)
53 views22 pages

Introduction to Python Programming

Here are the outputs of the exercises: 1) 12.5 2) <class 'int'> 3) <class 'float'> 4) addition of 10 and 5 = 15 5) Manisha Khare 6) <class 'str'> 7) M 8) h

Uploaded by

raunak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views22 pages

Introduction to Python Programming

Here are the outputs of the exercises: 1) 12.5 2) <class 'int'> 3) <class 'float'> 4) addition of 10 and 5 = 15 5) Manisha Khare 6) <class 'str'> 7) M 8) h

Uploaded by

raunak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

INTRODUCTION

TO
PYTHON
The most popular (fastest-growing) programming
language.

Introduced in 1989 and was introduced before Java (1995)

What is Recently it has become too popular.

Python? Used by Tech giants like Youtube, Quora, Google,


Instagram

Used by Researchers, Scientists, Game developers, data


analysts, Software developers and even students
Main application is Machine Learning.

Applications Machine learning implies the identification of relevant


data searched by the users and then displaying the same

of Python
advertisements to the user later when they are surfing.

Software Development, Web Development, Game


Development, Software Testing, Data Science, Artificial
Intelligence, Hacking
Why it became so popular?

Recently, machine learning and


data science have
Wide range of application in
Very easy to use Easy to understand. gained popularity and being
almost every area.
associated with both of them
Python came into the picture.

You can get the work done in


the least number of lines of High level language Multipurpose
code.
It was named as "Python" because
Guido was a big fan of a famous
TV series called Monty Python's
Flying Circus”, a BBC comedy
series.
Why Python?
Van Rossum thought he needed a
name that was short, unique, and
slightly mysterious, so he decided
to call the language Python
Developer: Guido Van Rossum

Started working on the project during 1989 during his winter


vacations as a hobby project. He had worked on ABC
History of programming language. Also, he was working on C language.

Python: Python is a successor of ABC programming language &


MODULA language from which he took some of the features.

He designed Python within 3 months.


Easy to Learn and Use.

Dynamically typed language: need not declare the data type of


variables

Interpreted Language

Features of
Free and Open Source

Python:
Object-Oriented Language.

Large Standard Library.

Expressive language (can get the work done via the least code)
Timeline
1994: PYTHON 1.0

2000: PYTHON 2.0 (UPTO 2.7)

1ST JAN'20: END OF SUPPORT FOR 2.0

2008: PYTHON 3.0 (UPTO 3.10 RELEASED IN 2021)

PYTHON 3.12 (RELEASED ON 2ND OCTOBER 2023)


WHY YOU SHOULD LEARN PYTHON:

• Python is a programming language that has relatively simple syntax. This makes it an
ideal choice for beginners who are just starting out in the field of programming.

• Python is also a very versatile language, which means that you can use I for a wide
variety of tasks and in different industries.
INTERACTIVE V/S SCRIPT MODE IN PYTHON:
DATA TYPE & VARIABLES
IN PYTHON
VARIABLES
• These are like containers for data.
• Eg: a container containing chocolate.
• For eg: We need to print “Hello” on the screen so we may print it directly n number of times but
suppose in case we need to print a whole article of Wikipedia it gets inconvenient to so the same
process multiple times. A better approach to overcome the issue would be to store the content in a
variable.
• Eg: var1 = “hello world”
• Print var1
• Variables need not be declared beforehand in Python. They are declared at the time of usage.
• Variables are something whose value may change during the program execution.
• These are the names of the memory locations.
RULES FOR DECLARING A VARIABLE

• It should start with a letter or an underscore.


• It cannot start with a number.
• It can contain only alphanumeric characters and underscore (A-Z,
0-9, _)
• They are case–sensitive (age, Age, and AGE are different)
• There can’t be space in between a variable name.
• EXAMPLES:

• Assigning a value to the variable

• s = 15

• print (s)

• We can change the value of an existing variable by again assigning a new value to it.

• s=“Artificial Intelligence”

• Assigning multiples values to multiple variables:

• x,y,z=“Apple”,”Mango”,”Orange”

• Single Value to Multiple Variables:

• x=y=z=“Mango”
Comments in Python:
• Comments in Python are used to explain the code. They make the code more readable. They are ignored by the interpreter
and has no effect on the code.

• Comments in python can be written in single line or multi line.

• Single Line Comments: They are marked with # (hash sign).

• Eg: # this is a single line comment

• Multi line Comments: These are indicated by adding hash sign before every line or enclosed in triple single quotes or
triple double quotes.

• Eg: ‘’’ This is

• a

• multi line comment ‘’’


Python keywords & Identifiers:

• Keywords in Python are the special / reserved words which have already been defined and cannot
be used as a variable name, function name etc.

• Examples: break, if, for, while

• There are around 35 keywords in Python.

• IDENTIFIERS: These are the names given to a variable, class or function. An identifier name is
case sensitive. It should not be a keyword. It can be a combination of letters, numbers or
underscores. It can not start from a number. It should not contain spaces. It should be meaningful.

• Invalid identifiers: !name, 2score, Roll no, Max%, Dollar$, low&high


DATA
TYPES
• These are the different kinds of values that we can store in the variable.
• We do not need to specify the data type explicitly. Python automatically allocates the
data type to the variable during run time. That is why Python is called DYNAMICALLY
TYPED LANGUAGE..

• Eg: a = 10
• During run-time it will be identified as a number and will be treated as
• an ‘int’ datatype.
BASIC DATA TYPES
BASIC DATA TYPES
• Int: It will contain whole numbers from positive to negative. There is no range for
this data type. Only the memory of the system is the constraint in Python.
• Eg: int a = 5
• Float: It will contain a number with decimal points. Eg: float a = 2.5
• String: It is a sequence of characters. Eg: String s=“Python”
• Boolean: It can contain only 2 values either ‘T’ or ‘F’.
EXERCISE
• var1 = 10
• var2 = 2.5
• print(var1 + var2)
• print(type(var1))
• print(type(var2)

• A=10
• B=5
• C=A+B
• Print (“addition of ”,a,” and ”, b , “ = “ , c)
EXERCISE

• Name = “Manisha
Khare”
• print(Name)
• print(type(Name))
• print(Name[0]) //
M
• print(Name[5]) // h

You might also like