Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
🐍 PYTHON –Language part 01
Hssc Guide Search @Guidehssc Hssc Guide App from play store
Introduction to Python Python Modes of Programming
Python is a high-level programming language
that is:
Easy to learn, Easy to write, Easy to
🔹 (A) Interactive Mode
➤ Code is written directly in the Python
understand prompt
Output appears immediately
➤ Developer
Guido van Rossum
❌
➤ Features:
Developed in 1990
✔️
Program cannot be saved
Best for learning and testing small
➤ Name of Python statements
Named after the famous BBC comedy show Example:
❌
“Monty Python’s Flying Circus” >>> 2 + 3
It is NOT named after the snake 5
Features of Python 🔹 (B) Script Mode (IDLE)
➤ Full Form of IDLE:
Python is simpler than C, C++, and Java
Integrated Development and Learning
No need to use:
Environment
Semicolon (;)
Curly braces { }
➤Program is written in a file
Example:
File can be saved and reused
print("Hello World")
Executed using Python interpreter
>Python is free to use
➤ Important Point:
>Source code is available to everyone
Indentation is very important in script mode
Example:
Object-Oriented Programming (OOPS)
if 5 > 2:
Python supports:
print("Five is greater")
Class, Object, Inheritance, Polymorphism
Interpreted Language
📌 Exam Fact:
Indentation replaces { } in Python.
Python executes code line by line
Errors are shown immediately
Keywords in Python
📌 Exam Point: ➤ Definition:
Keywords are reserved words that have a
Python is an interpreted, not compiled
language. special meaning in Python.
Examples:
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
🔹 (C) Sequence / Ordered Data Types
Hssc Guide Search @Guidehssc Hssc Guide App from play store
📌
if, else, while, for, True, False, None
Keywords cannot be used as variable
names. List
Written in square brackets [ ]
Case Sensitivity Mutable (can be changed)
Python is a case-sensitive language. Ordered
Example: Can store different data types
name = "Ankit" Example:
👉
Name = "Grewal" Copy code
name and Name are different variables Python
my_list = [1, 2, 3, "Ankit", 5.5]
Identifiers
➤ Identifiers are names given to: Tuple
Variables Written in round brackets ( )
Functions Immutable (cannot be changed)
Classes Ordered
➤ Rules: Example:
✔️ Can contain:
Copy code
Python
📌
Alphabets (a–z, A–Z) a = (1, 2, 3, 4, 5)
Digits (0–9) Difference:
Underscore (_) List → Mutable
❌ Cannot contain:
Tuple → Immutable
Special characters (@, #, %, $) String
Spaces Collection of characters
📌 Length of identifier: Immutable
Written using:
Unlimited in Python Single quotes ' '
Double quotes " "
Data Types in Python Example:
🔹 (A) Numeric Data Types
name = "Ankit Grewal"
Used to store numbers. ➤ Types of Strings:
Integer (int) → 10, -5 Single-line string
Float → 3.14, 2.5 Multi-line string
Complex → 3 + 4j Example:
📌
Boolean (bool) → True or False text = """Hello
Boolean represents logical values Welcome to Python"""
🔹 (B) None Data Type
➤ Represents absence of value
🔹 (D) Mapping Data Type
Example: Dictionary
📌
a = None Written using curly braces { }
Used to check whether a value exists or Stores data in key : value pairs
not. Mutable
Unordered
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
❌ No two keys can be same
Hssc Guide Search @Guidehssc Hssc Guide App from play store
Example:
Example: 5 // 2
Output: 2
📌 🔁 Difference Between Division / and Floor
d = {1: "One", 5: "Five"}
Dictionary comes under mapping data type
🔹 (E) Set Data Type
Division //
Written using curly braces { } Expression. Result Explanation
❌
Stores unique values only 5/2 2.5 Normal division
No duplicate values (returns float)
Unordered 5 // 2 2 Floor division
Mutable (but elements must be immutable) (removes decimal)
Example:
Copy code 📌 Exam Fact:
Python // always returns the nearest lower integer.
📌
s = {1, 2, 3, 4}
Set does not support indexing. Membership Operators
Membership operators are used to check
🐍 PYTHON OPERATORS & whether a value exists in a sequence like:
list, tuple, string ,set
RANGE
🔹 (A) in Operator
Returns True if value is present.
Additional Arithmetic Operators in
Example:
Python (Other than used in C language)
👉
3 in [1, 2, 3, 4]
Output: True
Python has two important arithmetic operators
apart from
+ - * / %. 🔹 (B) not in Operator
🔹 (A) Exponent Operator ** (Double Returns True if value is NOT present.
Example:
Star)
👉
5 not in [1, 2, 3, 4]
Used to calculate power (exponentiation). Output: True
Syntax: a ** b
Example:
📌 Exam Point:
in → checks presence
2 ** 3 not in → checks absence
Output: 8
(2 raised to the power 3 → 2 × 2 × 2) Identity Operators
📌 Exam Point: Identity operators check whether two variables
refer to the same object in memory, not just
** is used instead of pow(). equal values.
🔹 (B) Floor Division Operator // 🔹 (A) is Operator
(Double Slash) Returns True if both variables point to the
Used to perform division and return only the same object.
integer part (no decimal).
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
🔹 (B) is not Operator
Hssc Guide Search @Guidehssc
Returns True if they point to different objects.
🐍 PYTHON – Language
Hssc Guide App from play store
Part-01
🔍 Example:
x = [1, 2] 60 Most Important MCQs (Exam
y = [1, 2] Oriented)
👉
x == y
Output: True (values are same)
Q1. Python is which type of programming
👉
x is y
language?
Output: False (memory location is
(a) Low-level
different)
(b) Assembly language
📌 Important Difference: (c) High-level
🔵
(d) Machine language
Operator. Checks
(c)
==. Value equality
is. Memory identity
Range Function in Python Q2. Python is known for being:
The range() function generates a sequence of (a) Difficult to write
numbers. (b) Complex to understand
➤ Syntax: range(start, stop, step) (c) Easy to learn and understand
🔵
(d) Only for experts
start → starting value (inclusive) (c)
stop → ending value (exclusive)
step → gap between numbers
🔹 Example 1: Even Numbers Q3. Who developed Python language?
(a) Dennis Ritchie
👉 Output: [0, 2, 4, 6, 8]
list(range(0, 10, 2))
(b) James Gosling
📌 Explanation: (c) Guido van Rossum
🔵
Start = 0 (d) Bjarne Stroustrup
Stop = 10 (not included) (c)
Step = 2
🔹 Example 2: Reverse Range Q4. Python was developed in which year?
(a) 1985
👉
list(range(5, 0, -1)) (b) 1990
Output: [5, 4, 3, 2, 1] (c) 1995
📌 Explanation: 🔵
(d) 2000
(b)
Start from 5
Move backward
Stop before 0
Step = -1 Q5. Python is named after:
(a) A snake
(b) A book
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
Hssc Guide Search @Guidehssc Hssc Guide App from play store
🔵
(c) A movie (d) cout << "Hello"
🔵
(d) A BBC comedy show (b)
(d)
Q11. Python is free to use means:
Q6. “Monty Python’s Flying Circus” is a: (a) Paid license required
(a) Programming book (b) Source code hidden
(b) Snake species (c) Open source
🔵
(c) BBC comedy show (d) Only for students
🔵
(d) Python module (c)
(c)
Q12. Python supports which programming
Q7. Python is simpler than which concept?
languages? (a) Only procedural
(a) Only C (b) Only functional
(b) Only Java (c) Object-Oriented Programming
🔵
(c) C, C++, and Java (d) Machine level
🔵
(d) Assembly only (c)
(c)
Q13. Which OOPS concepts are supported
Q8. Which symbol is NOT required in by Python?
Python? (a) Class and Object only
(a) ; (b) Inheritance only
(b) : (c) Polymorphism only
🔵
(c) () (d) Class, Object, Inheritance, Polymorphism
🔵
(d) "" (d)
(a)
Q14. Python is an ______ language.
Q9. Which brackets are NOT used for code (a) Compiled
blocks in Python? (b) Interpreted
(a) ( ) (c) Assembly
🔵
(b) [ ] (d) Machine
(c) { } (b)
🔵
(d) :
(c)
Q15. Python executes code:
(a) Line by line
Q10. Which is a correct Python statement? (b) All at once
(a) print "Hello" (c) After compilation
🔵
(b) print("Hello") (d) Only after linking
(c) printf("Hello") (a)
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
Hssc Guide Search @Guidehssc Hssc Guide App from play store
Q21. Indentation in Python replaces:
(a) Semicolon
Q16. Errors in Python are shown: (b) Comments
(a) After execution (c) Curly braces { }
(b) After compilation
🔵
(d) Parentheses
(c) Immediately (c)
🔵
(d) Never
(c)
Q22. Keywords in Python are:
(a) User-defined words
Q17. Which mode allows direct execution at (b) Reserved words
prompt? (c) Variable names
(a) Script mode
🔵
(d) Function names
(b) Debug mode (b)
(c) Interactive mode
🔵
(d) Silent mode
(c)
Q23. Which of the following is a Python
keyword?
(a) Ankit
Q18. Which mode is best for learning (b) value
Python? (c) if
(a) Script mode
🔵
(d) print
(b) Interactive mode (c)
(c) Compiler mode
🔵
(d) Binary mode
(b)
Q24. Keywords can be used as variable
names.
(a) True
Q19. In Interactive mode, program: (b) False
(a) Can be saved (c) Sometimes
(b) Cannot be saved
🔵
(d) Only in functions
(c) Is compiled (b)
🔵
(d) Uses indentation
(b)
Q25. Python is a case-sensitive language
means:
Q20. Full form of IDLE is: (a) name and NAME are same
(a) Integrated Data Learning Environment (b) Name and name are different
(b) Internal Development Language Editor (c) Case does not matter
(c) Integrated Development and Learning
🔵
(d) Only uppercase allowed
Environment (b)
🔵
(d) Internet Development Learning Editor
(c)
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
Hssc Guide Search @Guidehssc Hssc Guide App from play store
Q26. Identifiers are names given to: (b) False
(a) Keywords only (c) None
🔵
(b) Variables, functions, classes (d) Empty string
(c) Numbers (c)
🔵
(d) Operators
(b)
Q32. Which data type is mutable and
ordered?
Q27. Which character is allowed in (a) Tuple
identifiers? (b) String
(a) @ (c) List
🔵
(b) # (d) Set
(c) _ (c)
🔵
(d) %
(c)
Q33. Tuple is:
(a) Mutable
Q28. Length of identifier in Python is: (b) Immutable
(a) 31 characters (c) Unordered
🔵
(b) 64 characters (d) Changeable
(c) Fixed (b)
🔵
(d) Unlimited
(d)
Q34. String in Python is:
(a) Mutable
Q29. Which is NOT a numeric data type? (b) Immutable
(a) int (c) Unordered
🔵
(b) float (d) Numeric
(c) complex (b)
🔵
(d) list
(d)
Q35. Dictionary stores data in:
(a) Values only
Q30. Boolean data type represents: (b) Index form
(a) Numbers (c) Key : value pairs
🔵
(b) Text (d) Sequence form
(c) Logical values (c)
🔵
(d) Objects
(c)
Q36. Duplicate keys in dictionary are:
(a) Allowed
Q31. Which data type represents absence of (b) Allowed once
value? (c) Not allowed
(a) 0
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
Hssc Guide Search @Guidehssc Hssc Guide App from play store
🔵
(d) Mandatory
(c)
Q42. Which of the following is a
membership operator?
(a) ==
Q37. Which data type stores unique values (b) is
only? (c) in
(a) List
🔵
(d) =
(b) Tuple (c)
(c) Dictionary
🔵
(d) Set
(d)
Q43. The in operator returns True when:
(a) Value is absent
(b) Value is present
Q38. Which operator is used for (c) Memory is same
exponentiation in Python?
🔵
(d) Types are same
(a) ^ (b)
(b) pow
(c) **
🔵
(d) //
(c) Q44. Output of 3 in [1, 2, 3, 4] is:
(a) False
(b) Error
(c) True
Q39. Floor division operator is:
🔵
(d) None
(a) /
(c)
(b) %
(c) **
🔵
(d) //
(d) Q45. The not in operator returns True
when:
(a) Value exists
(b) Value does not exist
Q40. Which operator checks memory
(c) Values are equal
identity?
🔵
(d) Objects are same
(a) ==
(b)
(b) in
(c) is
🔵
(d) not in
(c) Q46. Output of 5 not in [1, 2, 3,
Q41. Membership operators are used to 4] is:
check: (a) False
(a) Memory location (b) Error
(b) Value comparison (c) None
🔵
(c) Presence or absence in a sequence (d) True
(d)
🔵
(d) Data type
(c)
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
Hssc Guide Search @Guidehssc Hssc Guide App from play store
Q47. Identity operators check: Q52. If x = [1,2] and y = [1,2], then
(a) Data type x is y gives:
(b) Value equality (a) True
(c) Memory identity (b) False
🔵
(d) Sequence length (c) Error
(c)
🔵
(d) None
(b)
Q48. Which operator checks whether two
variables refer to the same object? Q53. Which function generates a sequence
(a) == of numbers?
(b) in (a) list()
(c) is (b) seq()
🔵
(d) not in (c) range()
(c)
🔵
(d) tuple()
(c)
Q49. Which operator checks value equality?
(a) is Q54. Syntax of range function is:
(b) is not (a) range(start, end)
(c) == (b) range(stop)
🔵
(d) in (c) range(start, stop, step)
(c)
🔵
(d) range(all)
(c)
Q50. In the expression x == y, Python
checks: Q55. In range(start, stop, step),
(a) Memory address the stop value is:
(b) Object type (a) Included
(c) Value equality (b) Excluded
🔵
(d) Reference count (c) Repeated
(c)
🔵
(d) Optional always
(b)
Q51. In the expression x is y, Python
checks: Q56. Output of list(range(0, 10,
(a) Values only
2)) is:
(b) Memory location
(a) [1,3,5,7,9]
(c) Data type
(b) [0,2,4,6,8]
🔵
(d) Output type
(c) [2,4,6,8,10]
(b)
🔵
(d) [0,1,2,3]
(b)
Hssc Guide Ankit Grewal ( Cet 2024 Rank 01)
Hssc Guide Search @Guidehssc Hssc Guide App from play store
Q57. Which parameter decides the gap
between numbers in range()?
(a) start
(b) stop
(c) step
🔵
(d) limit
(c)
Q58. Output of list(range(5, 0,
-1)) is:
(a) [0,1,2,3,4,5]
(b) [5,4,3,2,1]
(c) [5,3,1]
🔵
(d) Error
(b)
Q59. A negative step value in range()
means:
(a) Forward movement
(b) Random movement
(c) Reverse movement
🔵
(d) No movement
(c)
Q60. Which statement is TRUE?
(a) == checks memory identity
(b) is checks value equality
(c) in checks presence
(d) range() returns a list directly
🔵 (c)