To watch the YouTube video by
ROHiT SiR, CLICK ON THE IMAGE
Programming Fundamentals 88 00 873 871
Steve Jobs
Everyone should learn to program a computer,
Because it teaches you how to think.
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Character set are the set of valid characters that a language can recognise. It can be any letter, digit or symbol.
Token is the smallest unit of a program, which is identified by the interpreter, also known as a lexical unit.
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
Programming Fundamentals 88 00 873 871
TOKENS IN PYTHON
1 Keywords
2 Identifiers
3 Literals
4 Operators
5 Punctuators/ Delimiters
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Keywords are the reserved words that have a specific meaning to the interpreter. All keywords are
in lowercase except for: True, False, None
The following code will display the keywords available in Python.
is False and await break except global
import keyword lambda None as async del finally if
m=keyword.kwlist
not True assert def elif for import
for i in m:
yield or class continue else from in
print(i)
pass return raise nonlocal try while with
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
Identifiers are the names used to identify elements in a Python program, such as variables, functions,
lists, dictionaries, objects and classes, etc.
Example
name = "Rohit" # 'name' is an identifier for a variable
def greet(): # 'greet' is an identifier for a function
class Student: # 'Student' is an identifier for a class
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Variable is a container that holds the value of data that is used in the program. It can be of any size and may
contain alphabets (lower case or upper case) and digits (0 to 9). They are case sensitive, i.e. Age and age are
different.
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
The following are the rules for giving a name
Name can't begin with numbers. The name can't be a keyword.
No space is allowed in the naming. Underscore is the only valid symbol.
Valid Names Invalid Names Why It's Invalid
name 1name Starts with a number
student_age student age Contains space
_score @score Contains an invalid character
totalMarks123 for for is a reserved keyword (loop)
Age/age — Both are valid, but treated differently
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
Programming Fundamentals 88 00 873 871
The following are the rules for giving a name
Name can't begin with numbers. The name can't be a keyword.
No space is allowed in the naming. Underscore is the only valid symbol.
Circle the invalid variable names from the following given names
Group ENT S.I volume 3dgraph petrol#num Sum
Seven tag$ total first name Global tot_str an$wer
IF S if 99flag #tag C3 S name
m_n unit_day 24Apple #sum for
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Assignments of variable- means to provide the value to the variable
Single Assignment Multiple Assignment
Assigning one value at a time to each variable Assigning multiple values to multiple variables
x=10 #Parallel Assignment
y=9.5 a,b,c=10,20,30
z="Rohit" print(a,b,c)
print(x,y,z) 10 20 30
10 9.5 Rohit
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
ROHiT SiNGH 88 00 873 871
Assignments of variable- means to provide the value to the variable
Multiple Assignment Tuple Unpacking - Unpacks values from a tuple into
Assigning multiple values to multiple variables separate variables
#Chained Assignment info = ("Amit", 16, "Delhi")
a=b=c=d=10 name, age, city = info
print(a,b,c,d) print(name, age, city)
10 10 10 10 Amit 16 Delhi
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
Every Python Variable has 3 Key Properties
Identity of a variable refers to the unique memory address where its value is stored in the RAM. We can
check this using the built-in id() function, which always returns an integer value. Syntax - Id (variable)
Example
x="Rohit"
print(id(x))
64253536
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Every Python Variable has 3 Key Properties
Type means the data type of the variable that the variable holds. This tells what kind of data, like a tag that
says "this is a string" or "this is a float.“ Syntax - type(variable)
Example
a="Rohit"
print(type(a))
<class 'str'>
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Every Python Variable has 3 Key Properties
Value is the actual content of the variable — the value assigned to it.
a="Rohit"
print(a)
Rohit
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
ROHiT SiNGH 88 00 873 871
Predict the Output
x=y=z=2 x,y,z=2,3,5 x,y,z=2,3,5
print(x,y,z) print('x','y',z) print(x,y,z)
fst=2, sec= 3 n1,n2 = 2, 6 x,x=20,30
trd = fst * sec n1,n2 =n2,n1+2 y,y=x+10,x+20
print(fst,sec,trd) print(n1,n2) print(x,y)
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
Literal is the constant value directly assigned to a variable. It's like giving your variable a fixed value
that doesn't change at that moment.
None is a special data type used to indicate the absence of a value.
Float is a data type that contains numbers with decimal points.
Boolean is a subtype of an integer that consists of two constant values:
True(1) and False(0).
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Literal is the constant value directly assigned to a variable. It's like giving your variable a fixed value
that doesn't change at that moment.
Integer is a data type that contains a whole number that can be positive or negative
without any decimal point. Ex- 91, -55
Lists are a sequence of items separated by commas enclosed in square brackets.
list1 = [5, 3.4, "New Delhi"]
Dictionary is a data type that holds data in key-value pairs enclosed in curly brackets
and separated by a colon. Capital={"Apple":10, "Banana":20, "Cheery":30}
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Literal is the constant value directly assigned to a variable. It's like giving your variable a fixed value
that doesn't change at that moment.
Tuples are a sequence of items separated by commas enclosed in round
parentheses. tup1 = (10, 20, "Ape", 3.4)
String is a group of characters that may be alphabets, digits or special
characters, including spaces. Values are enclosed either in single or double
quotation marks. str1= "1-x0-w-25" .
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
Programming Fundamentals 88 00 873 871
Literal Example Description
None x = None No value assigned
Float pi = 3.14 Decimal number
Boolean status = True True (1) or False (0)
Integer count = -25 Whole number without decimal
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Literal Example Description
String name = "Rohit" Sequence of characters
List marks = [90, 85.5, "A+"] Mutable sequence in square brackets
Tuple tup = (1, 2, "Yes") Immutable sequence in round brackets
Dictionary data = {"key": "value"} Key-value pairs inside curly braces
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
TOKENS IN PYTHON
1 Keywords
2 Identifiers
3 Literals
4 Operators
5 Punctuators/ Delimiters
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
To watch the YouTube video by
ROHiT SiR, CLICK ON THE IMAGE
Programming Fundamentals 88 00 873 871
An Expression is a legal combination of operands and operators that represents some computation.
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
The follow ing are the ty pes of expression
1 Mathematical/Arithmetic Operators
2 Relational Operators
3 Logical operator
4 Identity Operator
5 Equality Operator
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Mathematical/Arithmetic Operators
Name Symbol
Addition +
Subtraction -
Multiplication *
Division /
Floor Division //
Modulus (Remainder) %
Exponentiation **
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
Mathematical/Arithmetic Operators
Remainder (Modulo) divides the operand on the Division divides the operand on the left by the
left by the operand on the right and returns the operand on the right and returns the quotient in
remainder. points.
17%5 5%7 17.0/5 15/5
2 5 3.4 3.0
17%7 17/50
3 0.34
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Mathematical/Arithmetic Operators
Exponentiation will raise the base to the power of Floor Division divides the operand on the left by the
the exponent. right and returns the quotient in integer form.
2**3 2**8 17//5 15//5
8 256 3 3
16**0.5 #sqrt 17//50
4.0 0
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
ROHiT SiNGH 88 00 873 871
Mathematical/Arithmetic Operators
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
Programming Fundamentals 88 00 873 871
Relational Operators generally return True or False as per the relation between operands.
Operator Symbol Description Example Output
Less than < Checks if left is less than right 5 < 10 True
Greater than > Checks if left is greater than right 8 > 12 False
Less than or equal to <= True if left is less than or equal to right 7 <= 7 True
Greater than or equal to >= True if left is greater than or equal to right 10 >= 20 False
Equal to == True if both values are equal 6 == 6 True
Not equal to != True if values are not equal 4 != 4 False
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Relational Operators generally return True or False as per the relation between operands.
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Logical operator returns True or False as per the conditions of an operand.
And it gives the preference to False, but if both the operands are true, then the condition becomes true. If
both operands are true, then the condition becomes True.
Or it gives the preference to True, but if any one of the operands is true, then the condition becomes true. If
either of the two operands is True, then the condition becomes True.
Not used to reverse the state of the operand/condition. True -> False
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
Logical operator returns True or False as per the conditions of an operand.
P Q AND (*) OR(+)
True True
True False
False True
False False
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Identity Operator
Identity Operator is used to check if both operands contain the same value or not.
a,b,c=23,24,23
print(a is not c) False
print(a is c) True
print(a is b) False
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Equality Operator (= =)
Equality Operator is used to compare the values and return true if both the values are equal; otherwise
returns False.
a,b=235,235
print(a is b)
True
print(a==b)
True
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
Programming Fundamentals 88 00 873 871
Augmented Assignment Operators
These Operators have combined the effect of arithmetic and assignment operators. If the first character of
both strings is the same, the second character is compared, and so on.
x+=2 x=x+2
x-=2 x=x-2
x*=2 x=x*2
x/=2 x=x/2
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
TOKENS IN PYTHON
1 Keywords
2 Identifiers
3 Literals
Punctuators: These are the symbols that used in
Python to organise the structures, statements, and
4 Operators
expressions. Some of the Punctuators are: [ ] { } ( )
5 Punctuators/ Delimiters @ -= += *= //= **== = , etc.
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Precedence of all operators in Python
Operators Description
() Parenthesis (Bracket) Left-to-Right
** Exponential (raised to the power) Right-to-Left
*,/,%,// Multiply, divide, modulo and floor division Left-to-Right
+,- Addition and subtraction Left-to-Right
<=,<,>,>= Relational operators Left-to-Right
==,!= Equality operators Left-to-Right
=,%=,/=,//=,-=,-=,+=,*=,**= Assignment operators Right-to-Left
is, is not Identity operators Left-to-Right
in, not in Membership operators Left-to-Right
not, or, and Logical operators Right-to-Left
~,+,- Complement, unary plus and unary minus Left-to-Right
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
Precedence of all operators in Python (PEMDAS)
Operators Description
() Parenthesis (Bracket) Left-to-Right
** Exponential (raised to the power) Right-to-Left
*,/,%,// Multiply, divide, modulo and floor division Left-to-Right
+,- Addition and subtraction Left-to-Right
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Evaluate the value Operators
12+(3**4-6)/2 D 12+3*4-6/2 ()
a
**
b 12%5*3+(2*6)//4 e 12*(3%4)//2+6
*,/,%,//
c (2+3)**3-6/2 f 12%3**4//5+6 +,-
49.5
21.0
9
24
122.0
© 2025 Rohit Singh. All rights reserved. 8
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
To watch the YouTube video by
ROHiT SiR, CLICK ON THE IMAGE
ROHiT SiNGH 88 00 873 871
Type Conversion is used to convert one data type to another.
Implicit conversion, also known as coercion,
happens when data type conversion is done
automatically by Python and is not instructed by the
user.
Explicit conversion, also called type casting,
happens when data type conversion takes place
because the programmer forced it into the
program.
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Join us on WhatsApp & Telegram for regular updates
Programming Fundamentals 88 00 873 871
Dynamic Typing vs Static Typing in Programming
Dynamic typing variables pointing to a value of a Static typing data is attached to a variable when it is
certain type can be made to point to a value of a defined first, and it is fixed. The data type of a
different type. Python supports dynamic typing. variable cannot be changed.
© 2025 Rohit Singh. All rights reserved.
Don’t forget to subscribe | Stay updated! www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Mutable variables whose values can be changed after they are created. Mutable are those whose values
can be changed in place. The address remains the same. Example - List, Set, Dictionary
chk=[2,4,6]
print(id(chk))
38215944
chk[1]=40
print(id(chk))
38215944
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
Programming Fundamentals 88 00 873 871
Immutable variables whose values cannot be changed after they are created. Their value can never be
changed in place. Example- int, float, bool, str, tuple
p=5
q=p
r=5
print(id(p))
1757870064
print(id(q))
1757870064
© 2025 Rohit Singh. All rights reserved.
CS IP BCA MCA classes by Rohit Sir www.SinghClassses.in
ROHiT SiNGH 88 00 873 871
Escape characters
Escape characters are used to insert special characters into strings — characters that are non-printable,
control characters, or have special meaning. They always start with a backslash (\) and let you include
© 2025 Rohit Singh. All rights reserved.
www.SinghClassses.in Like | Share | Comment
Programming Fundamentals 88 00 873 871
Escape Sequence Meaning Example Code Output
\n New Line print("Hello\nWorld") HelloWorld
\t Horizontal Tab print("Name:\tRohit") Name: Rohit
\\ Backslash (\) print("C:\\drive\\path") C:\drive\path
\" Double Quote (") print("She said: \"Hi\"") She said: "Hi"
\' Single Quote (') print('It\'s fine') It's fine
\r Carriage Return print("Hello\rHi") Hillo
\b Backspace print("He\bllo") Hllo
\f Form Feed print("Line\fBreak") Line⟶new page⟶Break
\v Vertical Tab print("Line1\vLine2") Line1⟶↓⟶Line2
\a Bell/Alert Sound print("\a") System beep (if supported)
(\s) Not valid in Python
© 2025 Rohit Singh. All rights reserved.
Don't forget to ask your doubts in the comment box! www.SinghClassses.in
To watch the YouTube video by
ROHiT SiR, CLICK ON THE IMAGE
SUBSCRIBE NOW
AND BE A PART OF OUR TEAM
PAUSE THE VIDEO
AND ATTEMPT
THESE QUESTIONS
B E S T O F LU C K , AT T E M P T BY YO U R S E L F