Unit-1 Introduction To Python Programming
Unit-1 Introduction To Python Programming
Introduction to Python
Programming
Prepared By:-
Prof. Chaitanya Kale
Python Introduction
https://www.python.org/downloads/
How to Run python Program
• Using the .py file extension, and running it in the Command Line:
Python Identifiers
• A Python identifier is a name used to identify a variable, function, class,
module or other object. An identifier starts with a letter A to Z or a to z or
an underscore (_) followed by zero or more letters, underscores and digits (0
to 9).
• Python does not allow punctuation characters such as @, $, and % within
identifiers. Python is a case sensitive programming language.
Thus, Manpower and manpower are two different identifiers in Python.
• Here are naming conventions for Python identifiers −
– Class names start with an uppercase letter. All other identifiers start with
a lowercase letter. Eg- Sanjivani__
– Starting an identifier with a single leading underscore indicates that the
identifier is private.
– Starting an identifier with two leading underscores indicates a strongly
private identifier.
– If the identifier also ends with two trailing underscores, the identifier is
a language-defined special name.
Reserved Words
Python Comments
• Python does not really have a syntax for multi line comments.
• To add a multiline comment you could insert a # for each line.
• But Python will ignore string literals that are not assigned to a
variable, you can add a multiline string (triple quotes) in your code,
and place your comment inside it:
Python Indentation
• Variable Names
• A variable can have a short name (like x and y) or a more descriptive
name (age, carname, total_volume).
• Rules for Python variables:
– A variable name must start with a letter or the underscore
character
– A variable name cannot start with a number
– A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ )
– Variable names are case-sensitive (age, Age and AGE are three
different variables)
Casting
• Get the Type
• You can get the data type of a variable with
the type() function.
• Output
Python Variables - Assign Multiple Values