0% found this document useful (0 votes)
42 views17 pages

BCC-302 Unit1 Lecture 1

introduction to Python Programming

Uploaded by

solankibeerbal
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)
42 views17 pages

BCC-302 Unit1 Lecture 1

introduction to Python Programming

Uploaded by

solankibeerbal
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/ 17

Subject Name:-Python Programming

Subject Code:- BCC302


Unit No.:- 1
Lecture No.:- 1
PPT No.:- 2
Topic Name :- Introduction to python, Elements of
Python

BEERBAL SOLANKI
Department of CSE
BCC-302/ Unit-I 1
Content
1. INTRODUCTION OF PYTHON
2. Elements of Python
a. Python Variables
b. Literals
c. Python Keywords
d. Python Identifiers
e. String
f. List
g. Tuple
BCC-302/ Unit-I 2
What is Python?
Python is a popular programming language. It was created by Guido van Rossum, and
released in 1991.

It is used for:
1. web development (server-side),
2. software development,
3. mathematics,
4. system scripting
5. Game development
6. Data analysis application
7. Machine learning
8. For developing artificial intelligent application
BCC-302/ Unit-I 3
Why Python language is so uses?
1. Python works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc).
2. Python has a simple syntax similar to the English language.
3. Python has syntax that allows developers to write programs
with fewer lines than some other programming languages.
4. Python runs on an interpreter system, meaning that code
can be executed as soon as it is written.
5. Python can be treated in a procedural way, an object-
oriented way or a functional way.

BCC-302/ Unit-I 4
Elements of Python
Some of the basic elements of python that a python
program consist are:
1. Python Variables:
2. Literals:
3. Python Keywords:
4. Python Identifiers:
5. String:
6. List:
7. Tuple:
BCC-302/ Unit-I 5
Python Variables
1. A variable is a named location used to store data in the
memory. It is helpful to think of variables as a container that
holds data which can be changed later throughout
programming.
2. For example,
number = 10
Here, we have created a named number. We have assigned
value 10 to the variable.

BCC-302/ Unit-I 6
Literals
Literal is a raw data given in a variable or constant. In Python, there are
various types of literals they are as follows:
a. Numeric Literals: Numeric Literals are immutable (unchangeable). Numeric
literals can belong to 3 different numerical types Integer, Float, and Complex.
1. a = 0b1010 #Binary Literals
2. b = 100 #Decimal Literal
3. c = 0o310 #Octal Literal
4. d = 0x12c #Hexadecimal Literal
5. #Float Literal
6. float_1 = 10.5
7. float_2 = 1.5e2
8. #Complex Literal
9. x = 3.14j

BCC-302/ Unit-I 7
b. String literals: A string literal is a sequence of characters
surrounded by quotes. We can use both single, double or
triple quotes for a string. And, a character literal is a single
character surrounded by single or double quotes.
ex:
strings = "This is Python"

BCC-302/ Unit-I 8
c. Boolean literals: A Boolean literal can have
any of the two values: True or False
• x = (1 == True)
• y = (1 == False)
• print("x is", x)
• print("y is", y)
• output: X is True
• Y is False

BCC-302/ Unit-I 9
Python Keywords
• Keywords are the reserved words in Python.
• We cannot use a keyword as a variable name, function name or
any other identifier. They are used to define the syntax and
structure of the Python language. In Python, keywords are case
sensitive. Ex:
• If, elif, else
• import
• pass
• None
• break
• except
• in
• raise
• True, False
• class

BCC-302/ Unit-I 10
Python Identifiers
An identifier is a name given to entities like class, functions, variables,
etc. It helps to differentiate one entity from another.

Rules for writing identifiers


1. Identifiers can be a combination of letters in lowercase (a to z) or
uppercase (A to Z) or digits (0 to 9) or an underscore _.
2. Names like myClass, var_1 and print_this_to_screen, all are valid
example.
3. An identifier cannot start with a digit. 1variable is invalid, but
variable1 is perfectly fine.
4. Keywords cannot be used as identifiers.
5. We cannot use special symbols like !, @, #, $, % etc. in our identifier.
6. Identifier can be of any length
BCC-302/ Unit-I 11
String
• String is sequence of characters. We can use
single quotes or double quotes to represent
strings. Multi-line strings can be denoted using
triple quotes, ''' or """.
• >>> s = "This is a string"
• >>> s = ‘’’a multiline
strings’’’

BCC-302/ Unit-I 12
List
• List is collection of an ordered sequence of
items. It is one of the most used data type in
Python and is very flexible. All the items in a
list do not need to be of the same type.
• Ex.
• list1 = ["abc", 34, True, 40, "male"]

BCC-302/ Unit-I 13
Tuple
• A tuple is a collection which is ordered and unchangeable.
• Tuple is an ordered sequence of items same as list. The
only difference is that tuples are immutable. Tuples once
created cannot be modified. Tuples are used to write-
protect data and are usually faster than list as it cannot
change dynamically.
thistuple = ("apple", "banana", "cherry")
print(thistuple)
Output:
('apple', 'banana', 'cherry')

BCC-302/ Unit-I 14
Important Questions
Q1. What are the elements of pyhon.
Q2. Differentiate list with tuple.
Q3. How can you define an identifier in python.
Q4. What are the significance of keywords in python.
Q5. Define literals.

BCC-302/ Unit-I 15
References
1. https://www.programiz.com/python-
programming
2. https://www.w3schools.com/python
3. https://www.python.org/doc/
4. Guido van Rossum and Fred L. Drake Jr, ―An
Introduction to Python – Revised and updated
for Python 3.2, Network Theory Ltd., 2011.
5. Timothy A. Budd, ―Exploring Python‖, Mc-
Graw Hill Education (India) Private Ltd.,, 2015.
BCC-302/ Unit-I 16
Thank You

BCC-302/ Unit-I 17

You might also like