Python is a high-level, interpreted and general-purpose dynamic programming language that focuses on code readability. The syntax in Python helps programmers write code in fewer steps as compared to languages like Java or C++. Character set in Python includes letters, digits, special symbols, and whitespace. Tokens or lexical units are the basic elements identified in a programming language like keywords, identifiers, literals, operators, and punctuators.
This document provides an introduction to Python fundamentals. It discusses Python's character set, tokens or lexical units including keywords, identifiers, literals, operators, and punctuators. It also covers Python programming concepts such as variables and assignments, functions, comments, statements, and programming conventions regarding whitespace, maximum line length, and case sensitivity. The document aims to explain the basic building blocks of the Python language to learn Python programming.
Kosmik is the best institute for Python training in Hyderabad Kukatpally/KPHB. kosmik provides lab facilities with complete real-time training with live sessions
call now: +91-8712186898, +91-8179496603, +91-6309565721
After the end of lesson you will be able to learn Python basics-What Python is? Its releases. Where we can use Python? Python Features. Tokens, comments variables etc... In out next PPT you will learn how to input and get output in Python
This document provides an introduction to Python fundamentals, including:
1. The Python character set includes letters, digits, symbols, and whitespace. Individual elements are called tokens or lexical units.
2. Keywords, identifiers, literals, operators, and punctuators are the main types of tokens. Identifiers follow specific naming conventions. Literals include strings, numbers, Booleans, None, and collections.
3. Strings can be single or multi-line with escape sequences. Numbers can be integers, floats, or complex. True, False, and None are Boolean and special literals.
The document provides an introduction to the Python programming language. It discusses that Python is an interpreted, high-level and general-purpose programming language. It describes Python's history and mentions some of its key features like being easy to learn and use, having extensive libraries, and being free and open source. The document also covers Python data types like integers, floats, strings; variables and expressions; and input/output functions. It provides examples of Python code for basic operations like arithmetic, strings, and input from the user.
Python Course In Ghaziabad. Scode network is best training institute for Python which provides Online Python course with complete certificates at an affordable price.
Introduction to Python for Data Science and Machine Learning ParrotAI
油
This document provides an introduction and overview of Python for data science and machine learning. It covers basics of Python including what Python is, its features, why it is useful for data science. It also discusses installing Python, using the IDLE and Jupyter Notebook environments. The document then covers Python basics like variables, data types, operators, decision making and loops. Finally, it discusses collection data types like lists, tuples and dictionaries and functions in Python.
ZENUS INFOTECH is best Python Training institute in Roorkee and an ISO 9001:2008 Certified Engineers Training Company in Roorkee & provides training to the B.E./B.TECH/DIPLOMA/MCA/BCA and related field students in 35+ cutting-edge technologies like AutoCAD, Solid-Works, CATIA, REVIT, Pro-E, UG-NX .NET, JAVA, PHP, GST Tally and Wireless & Telecommunication and many more.
This document provides an agenda and overview for a Python training course. The agenda covers key Python topics like dictionaries, conditional statements, loops, functions, modules, input/output, error handling, object-oriented programming and more. The introduction section explains that Python is an interpreted, interactive and object-oriented language well-suited for beginners. It also outlines features like rapid development, automatic memory management and support for procedural and object-oriented programming. The document concludes by explaining Python's core data types including numbers, strings, lists, tuples and dictionaries.
This document discusses data representation in Python programming. It begins by noting the vast amount of data being created and analyzed today. The chapter will look at how data is represented using Python, including numeric and string literals. Numeric literals represent integer and floating-point values, while string literals represent text enclosed in single or double quotes. Various encoding schemes are used to represent character values numerically. Formatted strings can be used to control display formatting. Variables are also introduced which allow operating on different values each time a program is run.
Guido van Rossum emphasized the importance of code readability in Python. He introduced significant whitespace as a core feature of the language, aiming to enforce a clean and readable code structure. This emphasis on readability is evident in the presentation's mention of Python's design philosophy that highlights code readability.Van Rossum emphasized the importance of Python in enabling developers to write clear and logical code, which is scalable for both small and large-scale projects. The presentation mentions Python's language constructs and object-oriented approach designed to assist programmers in achieving this goal.
Though not explicitly attributed to van Rossum, Python's dynamically typed nature and built-in garbage collection contribute to its ease of use and simplification of memory management, reflecting the language's user-centric design principles.
Overall, Guido van Rossum's vision and design choices for Python resonate with the attributes and philosophies outlined in the presentation. His influence is seen in Python's core principles, which prioritize readability, versatility, and ease of use for programmers.
Python and Perl are both high-level programming languages. Python is an interpreted language with clear, readable syntax and intuitive object orientation. Perl is also an interpreted and dynamic language that supports both procedural and object-oriented programming and is best known for powerful text processing. Both languages have a long history and are widely used for web development, scientific computing, and other tasks.
python programming language Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. INTRODUCTION
HISTORY
USES OF PYTHON
FEATURES OF PYTHON
PYTHON PROJECT FOR BEGINNERS
PYTHON PROGRAM
KEY CHANGES IN PYTHON
BASIC SYNTAX
VARIABLE
NUMBERS
STANDARD TYPE HIERARCHY
STRING
CONDITIONALS
FOR LOOP
FUNCTION
KEYWORDS
WHY PYTHON ?
DIFFERENTIATE
EXAMPLES
This document provides an introduction to Python programming concepts such as keywords, identifiers, comments, variables, data types, and literals. It defines keywords as reserved words in Python that have special meanings. Identifiers are names given to variables and other objects. Comments are notes for making code more readable. Variables are containers that hold data values. Literals represent fixed values like numbers and strings. The document also discusses Python data types like integers, floats, booleans, lists, tuples, dictionaries and sets.
This document provides an overview of the C programming language. It discusses that C was developed in 1972 at Bell Labs and is a popular systems and applications programming language. The document then covers various C language concepts like data types, variables, operators, input/output functions, and provides examples of basic C programs and code snippets.
This document provides an introduction to Python fundamentals, including character sets, tokens, identifiers, literals, operators, punctuators, whitespace, comments, statements, and functions. It defines each concept and provides examples. The character set in Python includes letters, digits, special symbols, and whitespace. Tokens include keywords, identifiers, literals, operators, and punctuators. Identifiers are names given to objects in a program. Literals represent fixed values through strings, integers, floats, Booleans, and collections. Operators trigger computations on variables. Punctuators separate language elements while whitespace ensures readability. Comments are non-executable notes. Statements are program instructions and functions define reusable blocks of code.
This document provides an introduction to Python fundamentals, including character sets, tokens, identifiers, literals, operators, punctuators, whitespace, comments, statements, and functions. It defines keywords, strings, integers, floats, Booleans, and collections as types of literals. It also covers Python naming conventions and escape sequences for strings.
This document provides information about programming in Python, including:
- Python was created in the late 1980s and supports object-oriented and structured programming.
- Key characteristics of Python include indentation-based syntax, lowercase keywords, everything is an object, extensive use of slicing, and programs are interpreted.
- The document discusses Python syntax for variables, constants, arithmetic operators, Boolean expressions, if/else statements, nested if statements, comments, input/output, and data types.
- Pseudocode is provided for common programming structures, with Python code examples to demonstrate the equivalent syntax.
Python Course In Ghaziabad. Scode network is best training institute for Python which provides Online Python course with complete certificates at an affordable price.
Introduction to Python for Data Science and Machine Learning ParrotAI
油
This document provides an introduction and overview of Python for data science and machine learning. It covers basics of Python including what Python is, its features, why it is useful for data science. It also discusses installing Python, using the IDLE and Jupyter Notebook environments. The document then covers Python basics like variables, data types, operators, decision making and loops. Finally, it discusses collection data types like lists, tuples and dictionaries and functions in Python.
ZENUS INFOTECH is best Python Training institute in Roorkee and an ISO 9001:2008 Certified Engineers Training Company in Roorkee & provides training to the B.E./B.TECH/DIPLOMA/MCA/BCA and related field students in 35+ cutting-edge technologies like AutoCAD, Solid-Works, CATIA, REVIT, Pro-E, UG-NX .NET, JAVA, PHP, GST Tally and Wireless & Telecommunication and many more.
This document provides an agenda and overview for a Python training course. The agenda covers key Python topics like dictionaries, conditional statements, loops, functions, modules, input/output, error handling, object-oriented programming and more. The introduction section explains that Python is an interpreted, interactive and object-oriented language well-suited for beginners. It also outlines features like rapid development, automatic memory management and support for procedural and object-oriented programming. The document concludes by explaining Python's core data types including numbers, strings, lists, tuples and dictionaries.
This document discusses data representation in Python programming. It begins by noting the vast amount of data being created and analyzed today. The chapter will look at how data is represented using Python, including numeric and string literals. Numeric literals represent integer and floating-point values, while string literals represent text enclosed in single or double quotes. Various encoding schemes are used to represent character values numerically. Formatted strings can be used to control display formatting. Variables are also introduced which allow operating on different values each time a program is run.
Guido van Rossum emphasized the importance of code readability in Python. He introduced significant whitespace as a core feature of the language, aiming to enforce a clean and readable code structure. This emphasis on readability is evident in the presentation's mention of Python's design philosophy that highlights code readability.Van Rossum emphasized the importance of Python in enabling developers to write clear and logical code, which is scalable for both small and large-scale projects. The presentation mentions Python's language constructs and object-oriented approach designed to assist programmers in achieving this goal.
Though not explicitly attributed to van Rossum, Python's dynamically typed nature and built-in garbage collection contribute to its ease of use and simplification of memory management, reflecting the language's user-centric design principles.
Overall, Guido van Rossum's vision and design choices for Python resonate with the attributes and philosophies outlined in the presentation. His influence is seen in Python's core principles, which prioritize readability, versatility, and ease of use for programmers.
Python and Perl are both high-level programming languages. Python is an interpreted language with clear, readable syntax and intuitive object orientation. Perl is also an interpreted and dynamic language that supports both procedural and object-oriented programming and is best known for powerful text processing. Both languages have a long history and are widely used for web development, scientific computing, and other tasks.
python programming language Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. INTRODUCTION
HISTORY
USES OF PYTHON
FEATURES OF PYTHON
PYTHON PROJECT FOR BEGINNERS
PYTHON PROGRAM
KEY CHANGES IN PYTHON
BASIC SYNTAX
VARIABLE
NUMBERS
STANDARD TYPE HIERARCHY
STRING
CONDITIONALS
FOR LOOP
FUNCTION
KEYWORDS
WHY PYTHON ?
DIFFERENTIATE
EXAMPLES
This document provides an introduction to Python programming concepts such as keywords, identifiers, comments, variables, data types, and literals. It defines keywords as reserved words in Python that have special meanings. Identifiers are names given to variables and other objects. Comments are notes for making code more readable. Variables are containers that hold data values. Literals represent fixed values like numbers and strings. The document also discusses Python data types like integers, floats, booleans, lists, tuples, dictionaries and sets.
This document provides an overview of the C programming language. It discusses that C was developed in 1972 at Bell Labs and is a popular systems and applications programming language. The document then covers various C language concepts like data types, variables, operators, input/output functions, and provides examples of basic C programs and code snippets.
This document provides an introduction to Python fundamentals, including character sets, tokens, identifiers, literals, operators, punctuators, whitespace, comments, statements, and functions. It defines each concept and provides examples. The character set in Python includes letters, digits, special symbols, and whitespace. Tokens include keywords, identifiers, literals, operators, and punctuators. Identifiers are names given to objects in a program. Literals represent fixed values through strings, integers, floats, Booleans, and collections. Operators trigger computations on variables. Punctuators separate language elements while whitespace ensures readability. Comments are non-executable notes. Statements are program instructions and functions define reusable blocks of code.
This document provides an introduction to Python fundamentals, including character sets, tokens, identifiers, literals, operators, punctuators, whitespace, comments, statements, and functions. It defines keywords, strings, integers, floats, Booleans, and collections as types of literals. It also covers Python naming conventions and escape sequences for strings.
This document provides information about programming in Python, including:
- Python was created in the late 1980s and supports object-oriented and structured programming.
- Key characteristics of Python include indentation-based syntax, lowercase keywords, everything is an object, extensive use of slicing, and programs are interpreted.
- The document discusses Python syntax for variables, constants, arithmetic operators, Boolean expressions, if/else statements, nested if statements, comments, input/output, and data types.
- Pseudocode is provided for common programming structures, with Python code examples to demonstrate the equivalent syntax.
APM event hosted by the South Wales and West of England Network (SWWE Network)
Speaker: Aalok Sonawala
The SWWE Regional Network were very pleased to welcome Aalok Sonawala, Head of PMO, National Programmes, Rider Levett Bucknall on 26 February, to BAWA for our first face to face event of 2025. Aalok is a member of APMs Thames Valley Regional Network and also speaks to members of APMs PMO Interest Network, which aims to facilitate collaboration and learning, offer unbiased advice and guidance.
Tonight, Aalok planned to discuss the importance of a PMO within project-based organisations, the different types of PMO and their key elements, PMO governance and centres of excellence.
PMOs within an organisation can be centralised, hub and spoke with a central PMO with satellite PMOs globally, or embedded within projects. The appropriate structure will be determined by the specific business needs of the organisation. The PMO sits above PM delivery and the supply chain delivery teams.
For further information about the event please click here.
How to use Init Hooks in Odoo 18 - Odoo 際際滷sCeline George
油
In this slide, well discuss on how to use Init Hooks in Odoo 18. In Odoo, Init Hooks are essential functions specified as strings in the __init__ file of a module.
Chapter 3. Social Responsibility and Ethics in Strategic Management.pptxRommel Regala
油
This course provides students with a comprehensive understanding of strategic management principles, frameworks, and applications in business. It explores strategic planning, environmental analysis, corporate governance, business ethics, and sustainability. The course integrates Sustainable Development Goals (SDGs) to enhance global and ethical perspectives in decision-making.
How to attach file using upload button Odoo 18Celine George
油
In this slide, well discuss on how to attach file using upload button Odoo 18. Odoo features a dedicated model, 'ir.attachments,' designed for storing attachments submitted by end users. We can see the process of utilizing the 'ir.attachments' model to enable file uploads through web forms in this slide.
How to Configure Restaurants in Odoo 17 Point of SaleCeline George
油
Odoo, a versatile and integrated business management software, excels with its robust Point of Sale (POS) module. This guide delves into the intricacies of configuring restaurants in Odoo 17 POS, unlocking numerous possibilities for streamlined operations and enhanced customer experiences.
Finals of Kaun TALHA : a Travel, Architecture, Lifestyle, Heritage and Activism quiz, organized by Conquiztadors, the Quiz society of Sri Venkateswara College under their annual quizzing fest El Dorado 2025.
QuickBooks Desktop to QuickBooks Online How to Make the MoveTechSoup
油
If you use QuickBooks Desktop and are stressing about moving to QuickBooks Online, in this webinar, get your questions answered and learn tips and tricks to make the process easier for you.
Key Questions:
* When is the best time to make the shift to QuickBooks Online?
* Will my current version of QuickBooks Desktop stop working?
* I have a really old version of QuickBooks. What should I do?
* I run my payroll in QuickBooks Desktop now. How is that affected?
*Does it bring over all my historical data? Are there things that don't come over?
* What are the main differences between QuickBooks Desktop and QuickBooks Online?
* And more
Useful environment methods in Odoo 18 - Odoo 際際滷sCeline George
油
In this slide well discuss on the useful environment methods in Odoo 18. In Odoo 18, environment methods play a crucial role in simplifying model interactions and enhancing data processing within the ORM framework.
Mate, a short story by Kate Grenvile.pptxLiny Jenifer
油
A powerpoint presentation on the short story Mate by Kate Greenville. This presentation provides information on Kate Greenville, a character list, plot summary and critical analysis of the short story.
Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...Ajaz Hussain
油
This presentation delves into the systemic blind spots within pharmaceutical science and regulatory systems, emphasizing the significance of "inactive ingredients" and their influence on therapeutic equivalence. These blind spots, indicative of normalized systemic failures, go beyond mere chance occurrences and are ingrained deeply enough to compromise decision-making processes and erode trust.
Historical instances like the 1938 FD&C Act and the Generic Drug Scandals underscore how crisis-triggered reforms often fail to address the fundamental issues, perpetuating inefficiencies and hazards.
The narrative advocates a shift from reactive crisis management to proactive, adaptable systems prioritizing continuous enhancement. Key hurdles involve challenging outdated assumptions regarding bioavailability, inadequately funded research ventures, and the impact of vague language in regulatory frameworks.
The rise of large language models (LLMs) presents promising solutions, albeit with accompanying risks necessitating thorough validation and seamless integration.
Tackling these blind spots demands a holistic approach, embracing adaptive learning and a steadfast commitment to self-improvement. By nurturing curiosity, refining regulatory terminology, and judiciously harnessing new technologies, the pharmaceutical sector can progress towards better public health service delivery and ensure the safety, efficacy, and real-world impact of drug products.
2. Previous Knowledge
Testing
1. Who developed Python?
Guido Van Rossum
2. Name the Pythons two working mode.
Interactive & Script
3. Python programs are stored in files with _________
extension.
.py extension
4. Python is the fastest language. True / false
False
5. Which statement is used to display
output on the screen?
4. Print statement
Arguments inside print statement:
sep & end
Sep is used to separate word
eg. x,y=10,20
print(x , y)
Output :
10 20
5. Print statement
Arguments inside print statement:
sep & end
end is used to separate word
eg. x,y=10,20
print(x)
print(y)
Output :
10 20
print(x, end = )
7. Python is a high-level, interpreted and general-
purpose dynamic programming language that
focuses on code readability. The syntax in Python
helps the programmers to do coding in fewer steps
as compared to Java or C++.
Let us learn the basic elements of python
programming
11. PYTHON CHARACTER SET
PYTHON
CHARACTER
SET
Letters:- A-Z, a-z
Digits:- 0 to 9
Special Symbols:- space + - / ( ) [ ] = ! = < > , $ # ; : ? &
White Spaces:- Blank Space , Horizontal Tab, Vertical tab,
Carriage Return.
Other Characters:- Python can process all 256 ASCII and
Unicode Characters.
18. What is Keyword?
Keywords are also called as reserved
words these are having special meaning
in python language. The words are
defined in the python interpreter hence
these cant be used as programming
identifiers.
1. Keyword/Reserved Word
23. 2. IDENTIFIERS
What is an identifier?
A Python Identifier is a name given
to a function, class, variable, module, or
other objects that youll be using in
your Python program.
In short, its a name appeared in the
program.
For example: a, b, c
a b and c are the identifiers
and a b & c and , are the
25. PYTHON NAMING CONVENTIONS
the python
naming
What are
conventions?
1. An identifier can be a combination
of uppercase letters, lowercase letters,
underscores, and digits (0-9). Hence,
the following are valid identifiers:
myClass, my_variable, var_1, and
print_hello_world.
26. PYTHON NAMING CONVENTIONS
What are the python
naming conventions?
2. The first character must be letter.
3. Special characters such as %,
@, and
$ are not allowed within identifiers.
4. An identifier should not begin
with a
number. Hence, 2variable is
not valid, but variable2 is acceptable.
27. the python
naming
What are
conventions?
5. Python is a case-sensitive
language and this behaviour extends to
identifiers. Thus, Labour and labour are
two distinct identifiers in Python.
6. You cannot use Python keywords
as identifiers.
PYTHON NAMING CONVENTIONS
28. the python
naming
What are
conventions?
7. You cannot use Python keywords as
identifiers.
8. You can use underscores to separate
multiple words in your identifier.
PYTHON NAMING CONVENTIONS
30. Competency Based
Question
1. Write Instructions in python to get the following
result: (Do it in both interactive mode and script
mode)
I am a student of KV Barabanki
I live in Barabanki
And I love Barabanki.
Barabanki is 20 KM away from Lucknow
This Place is famous for Dewa Sharif
31. HOME WORK
1. What are tokens in python? How many
tokens are allowed in Python?
2. How keyword are different from
identifiers?
3. Application based Question:
a,b,c = 2,8,9
print(a,b,c)
print(b,c,a)
33. 3. LITERALS / CONSTANT VALUES
What is literals?
Literals are also called as constants
or constant values these are the values
which never change during the
execution of program.
35. TYPES OF LITERALS / CONSTANT VALUES
What are the types of literals?
1) String Literals or Constants.
2) Numeric Literals or Constants.
3) Boolean Literals or Constants.
4) Special Literal None.
5) Literal Collections.
37. 1. STRING LITERALS OR CONSTANTS
What is string?
Sequence of letters enclosed in
quotes is called string or string literal or
constant.
both form of
Pythonsupports
quotes i.e.
Hel
lo
Hello
40. REPRESENTATION OF STRING
To access the first character on the string
you just created, type and enter the variable
name s and the index 0 within square brackets
like this:
>>>s[0]
Youll get this
output: H
41. REPRESENTATION OF STRING
To access the last character, you can use this
expression:
>>>s[len(s)-1]
Youll get the output:
n
Len() function
is used to
find the
length of the
string.
42. REPRESENTATION OF STRING
The expression introduces you to the
len function. There is actually an easier way to
access the last item on the string:
>>>s[-1]
n
To access the penultimate character:
>>>s[-2]
o
43. TYPES OF STRINGS
What are the types of strings supported
in python?
Python supports two ways
of representation of strings:
1) Single Line Strings.
2) Multi Line Strings.
45. SINGLE LINE STRINGS
Strings created using single quote or
double quote must end in one line are
called single line strings
For Example:
Item=Compu
ter Or
Item=
Computer
46. MULTI LINE STRINGS
Strings created using single quote or
double quote and spread across
multiple lines are called Multi Line
Strings.
by adding backslash
one can continue to type on next line.
For instance: Item = Key
board
50. STRINGS WITH TRIPLE QUOTES
For multi line strings created by triple
quotes, while calculating size, the
EOL(End of Line) character at the end of
line is also counted.
For instance:
Str2=x
y
Z
Enter keys are
considered
as EOL so size
of str2 is 5
68. 2. NUMERICAL LITERALS
Numerical Literals have the
following types:
int or integers
float
Complex
- Whole numbers
- real values
- Complex numbers
69. 2. NUMERICAL LITERALS
Numerical Literals have the
following types:
int or integers
float
Complex
- Whole numbers
- real values
- Complex numbers
70. INTEGER LITERALS OR CONSTANTS
Decimal Integer Literals: Any whole
number (+ve) or (-ve).
71. INTEGER LITERALS OR CONSTANTS
Octal Integer Literals(base 8): A Sequence of
digits starting with 0O (digit zero followed by
letter o) is taken to be an Octal Integer
Literals.
72. INTEGER LITERALS OR CONSTANTS
Hexadecimal Integer Literals (base 16):
Sequence of digits preceded by ox or OX is
hexadecimal integer literals
73. INTEGER LITERALS OR CONSTANTS
Binary literals (base 2): To signify binary
literals, youll use the prefix 0B or 0b (zero
and uppercase or lowercase b).
75. To convert an integer into its
string
representation, you can use the functions hex(),
bin(), and oct().
To convert the integer 7 to its octal literal, type
and enter oct(7) on the command prompt. Youll
get the output 0o7:
oct ( )
76. Here is what happens when you convert
the integer 2572 to a hexadecimal literal:
hex ( )
77. see what happens when you use the bin()
function to convert the integer 12 to its binary
string:
bin ( )
79. FLOATING POINT LITERALS OR CONSTANTS
Floating point literals are
also called as real literals having fractional
part.
These may be written in one of the
two forms:
1. Fractional Form: for example 15.75
2. Exponent Form: It consists of two parts
Mantissa and Exponent. for example 5.8 can
be represented as 0.58 x 10-1 = 0.58E01.
86. 5) LITERAL COLLECTIONS
Python supports literal
collections also such as tuple and lists ..etc
It will be to complex to discuss as we are
in the beginning, subsequent chapters we will
cover literal collections.
88. OPERATORS
What is an operator?
Operators are tokens
that
trigger some
computation when applied to a variable.
that
What is Unary Operator?
Unary operators are those
operators require one operand to
operate upon.
Unary Operators:
+
-
~
not
Unary Plus
Unary Minus
Bitwise Compliment
Logical Negation
89. OPERATORS
What is Binary Operator?
Binary operators are those operators
that require two operands to
operate upon.
Binary Operators:
+
-
*
/
%
**
//
Addition
Subtraction
Multiplication
Division
Remainder or Modulus
Exponent.
Floor Division
90. OPERATORS
What is Binary Operator?
Binary operators are those operators
that require two operands to
operate upon.
Binary Operators:
+
-
*
/
%
**
//
Addition
Subtraction
Multiplication
Division
Remainder or Modulus
Exponent.
Floor Division
117. PUNCTUATORS
Punctuators are also called as separators
The Followings are used as punctuators:
Brackets [ ]
Parentheses ( )
Braces { }
Comma ,
Semicolon ;
Colon :
Asterisk *
Ellipsis
=
Equal Sign
Pound Sign
#
121. GENERAL STRUCTURE OF PYTHON PROGRAM
# Write a program to find
square of given number.
def sqr( num ):
result= num *num
print ("Square = " ,
result)
def main():
x=int(input("Enter the number : "))
sqr(x)
main()
Programmer
defined
FUNCTION
main() function
Comment
122. WHITE SPACE
Whitespace Whitespace is meaningful
in Python, especially indentation and
placement of newlines.
Use a newline to end a line of code.
Use when must go to next line
prematurely.
No braces { } to mark blocks of code in
Python
124. WHITE SPACE
Use consistent indentation instead.
The first line with less indentation is
outside of the block.
The first line with more indentation
starts a nested block.
Often a colon appears at the start of a
new block. (E.g. for function and class
definitions.).
126. COMMENTS
Comments are non executable
statements in a program.
Single line comment always starts
with #
Multiline comment will be in triple
quotes. For example write a program
to find the simple interest .
Note: Triple apostrophe is called
docstrings.
128. STATEMENTS
In computer terminology statement
refers to an instruction.
Program contains several
statements. A collection of statements
makes program
Another name for a program is
code.
130. FUNCTIONS
What is function?
Function is a self contained program
segment which carries out some specific
well defined task.
For Example:
def sqr( num ):
result= num *num
print ("Square = " , result)
sqr()
132. PYTHON PROGRAMMING CONVENTIONS
Statement Termination: python does
not use any symbol to terminate the
statement.
Maximum Line Length: Line Length be
maximum 79 characters.
Whitespaces: you should always have
whitespace around operators but not
with parenthesis.
133. PYTHON PROGRAMMING CONVENTIONS
Block or Code Block: A group of
statements which are part of another
statement or function is called Block or
Code Block.
Case Sensitive: Python is case sensitive.
135. VARIABLES AND ASSIGNMENTS
Named labels are called variables.
For example: marks =86
78 79 80 81 82 83 84 85 86 87
2000 2016 2018 2026 2032 2044 2048 2050 2054 2068
marks refers to
location 2054
136. VARIABLES AND ASSIGNMENTS
Now marks = 81
78 79 80 81 82 83 84 85 86 87
2000 2016 2018 2026 2032 2044 2048 2050 2054 2068
marks
refers to
location
2026
137. VARIABLES AND ASSIGNMENTS
lvalues & rvalues:
Lvalue:Expressions that is on
LHS (Left Hand Side) is called Lvalue.
Rvalue: Expressions that is on RHS (Right
Hand Side) is called Rvalue.
138. VARIABLES AND ASSIGNMENTS
Multiple Assignments
Python is very versatile
with assignment statements.
to multiple
1. Assigning same
value variables:
a=b=c=d=e=10
139. VARIABLES AND ASSIGNMENTS
Multiple Assignments
2. Assigning Multiple values to multiple
variables:
p,q,r =5,10,15
print(q, r) will print 10
15
p,q=q,p
print (p,q) will print 10 5
140. VARIABLES AND ASSIGNMENTS
Multiple Assignments
2. Assigning Multiple values to multiple
variables:
a,b,c = 5,10,7
b,c,a = a+1, b+2, c-1
print(a,b,c) will print 6 6 12
Now,
X=10
141. VARIABLES AND ASSIGNMENTS
Multiple Assignments
Expressions separated by
commas are evaluated from left to
right.
Now,
x = 10
y,y = x+2,x+5
y,y = 12,15
First It will assign y = 12 then y = 15
So print(y) will print 15
142. VARIABLES AND ASSIGNMENTS
Dynamic Typing:
A variable pointing to a
value of certain type can be made to
point to a value/object
this is called Dynamic
of different
type Typing.
x=10
print(x)
x= Hello World
print(x)
145. VARIABLES AND ASSIGNMENTS
type() function:
To know the data type of a value which is
pointing use type ( )
>>>a=10
>>>type(a)
<class int>
>>>a=20.4
>>>type(a)
<class float>
Type returned as integer
Type returned as float
146. VARIABLES AND ASSIGNMENTS
type() function:
To know the data type of a value which is
pointing use type ( )
>>>a=Hello
>>>type(a)
<class str> Type returned as string
148. INPUT ( ) FUNCTION
Input( ) Function is a built in function
of python used to read values from the user
The general format or syntax of the input() is:
Variable_to_hold_the_value=input(mess
age) For Example:
Where,
variable
location
variable_to_Hold_the_Value is a
which is the label for a memory
where the value is stored.
149. INPUT ( ) FUNCTION
For Example:
p = input(Enter the value)
x = int(input(Enter x value))
reads the value and converts it in to integer
type data or value.
y=float(input(Enter y value))
reads the value and converts it in to float type
data or value.
150. INPUT ( ) FUNCTION
int ( ) and float ( ) Functions:
Python offerstwo functions to be
used with input( ) to convert the
received values:
Example 1: >>age =
int(input(Enter age)) Example 2:
>>sal=float(input(Enter salary))
152. PRINT ( ) FUNCTION
print( ) Function is a built in function of
python used to display the values on the
screen
The general format or syntax of the input() is:
print(*objects, sep=' ', end='n',
file=sys.stdout,
flush=False)
The print function can print an arbitrary
number of values ("value1, value2, ..."), which are
separated by commas. These values are separated
by blanks. In the following example we can see
two print calls. We are printing two values in both
cases, i.e. a string and a float number:
153. PRINT ( ) FUNCTION
print() Parameters:
objects - object to the printed. * indicates that
there may be more than one object
sep - objects are separated by sep. Default
value: ' end - end is printed at last
file - must be an object with write(string)
method. If omitted it, sys.stdout will be used
which prints objects on the screen.
flush - If True, the stream is forcibly
flushed. Default value: False
154. PRINT ( ) FUNCTION
Example 1: How print() works in Python?
print("Python is fun.")
a = 5
#Two objects are passed: print("a
=", a)
b = a
# Three objects are passed:
print('a =', a, '= b)
Output
Python is fun.
a = 5
a = 5 = b
155. PRINT ( ) FUNCTION
Example 2: How print() works in Python?
>>> print("a = ", a)
a = 3.564
>>> print("a = n", a)
a =
3.564
>>>