Python Programming Fundamentals

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 67

PYTHON PROGRAMMING

FUNDAMENTALS
CHAPTER -4
PYTHON CHARACTER SET
TOKENS
KEYWORDS
Identifiers
LITERALS
STRING
STRING TYPE IN PYTHON

Multiline String
Sometimes we next text across multiple line. So we can insert it
by using triple quotes (‘ ‘ ‘ and end with’ ’ ’ )
Example of Multiple line
Numeric Literals

While writing large integer value,do not use comma to separate


digits .Also, Integer should not having leading zeros
Special Literal-None
Complex data type
Variable/ Identifier

 Variables are containers for storing data values.


 Unlike other programming languages, Python has no command for
declaring a variable.
 A variable is created the moment you first assign a value to it.
 Variables do not need to be declared with any particular type and can
even change type after they have been set.
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)
Lvalue and Rvalue Of Variable
Lvalue and Rvalue
Multiple Assignments
Example
Just a minute
Variable Definition
Dynamic Typing
Caution with Dynamic Typing
Determining the type of variable
Value Of an Variable
Id Of an Variable
Just a minute
Complex data type
Input
Reading numeric values
To find sum of two numbers
Possible errors
Possible Errors
eval ()

 This Function is used to evaluate the value of string as


number and returns the numeric result.
 If the given argument is not a number ,it returns an error
Just a minute
Operators
Types Of Operators
Types Of Operators- Arithematic
Just a minute
Floor Division
Just a minute
Relational Operators
Logical Operators
Assignment Operator
Punctuators
Expression
Statement
CHAINED EXPRESSION
Comments
Concatenating String
Precedence of Arithmetic and logical
Operators

 () [parenthesis]
 **[Exponentiation]
 -(negation)
 /(division) //(floor division) ,*(multiplication) ,%(modulus)
 +(addition ),-(subtraction)
 Logical operators ( not ,and ,or)
Example

12 * ( 3%4) //2 + 6


12 * 3//2 + 6
36//2 + 6
18 +6
24
Just a minute

12+ ( 3 **4-6 )/2


12%3 ** 4//5 +6
12+3 * (4-6)/2
Multiple ( * * operator)
String Comparison
Math Module in PYTHON
Using pi
Just a minute

You might also like