1st pu notes

Getting Started with Python Full & easy notes |1st puc

Venkatesh A August 11, 2026 24 min read
1st PUC Computer Science Chapter 5 – Getting Started with Python Notes | VerakWorld
1st PUC / Class XI Computer Science

Chapter 5: Getting Started with Python

Complete Short Notes & Exam Preparation Guide

Based on the uploaded textbook PDF

πŸ“š Chapter Overview

This chapter introduces Python programming and explains programming languages, Python features, execution modes, keywords, identifiers, variables, comments, objects, data types, operators, expressions, statements, input and output, type conversion and debugging.

Exam Point: Definitions, differences, rules, operator tables, Try in Lab examples, Python programs, expressions, type conversion and types of errors are important areas for examination.

πŸ“‘ Table of Contents

5.1 Introduction to Python

An ordered set of instructions to be executed by a computer to carry out a specific task is called a program.

The language used to specify this set of instructions to the computer is called a programming language.

Computers understand machine language consisting of 0s and 1s. It is difficult for humans to write and understand instructions in machine language.

This led to the development of high-level programming languages such as Python, C++, Visual Basic, PHP and Java.

A program written in a high-level language is called source code.

Python uses an interpreter to convert its instructions into machine language so that they can be understood by the computer.

Interpreter Compiler
Processes program statements one by one, translating and executing them. Translates the entire source code as a whole into object code.
Execution stops when an error is encountered. Scans the complete program and generates error messages, if any.

5.1.1 Features of Python

  • Python is a high-level language and is free and open source.
  • It is an interpreted language.
  • Python programs are easy to understand because they have clearly defined syntax and relatively simple structure.
  • Python is case-sensitive.
  • Python is portable and platform independent.
  • Python has a rich library of predefined functions.
  • Python is helpful in web development.
  • Python uses indentation for blocks and nested blocks.
Remember: NUMBER and number are not the same identifier because Python is case-sensitive.

5.1.2 Working with Python

To write and run a Python program, we need a Python interpreter installed on the computer, or we can use an online Python interpreter.

The interpreter is also called the Python Shell.

The symbol >>> is the Python prompt. It indicates that the interpreter is ready to take instructions.

Python Prompt

>>> print(“Hello World”) Hello World

5.1.3 Execution Modes

There are two ways to use the Python interpreter:

  1. Interactive Mode
  2. Script Mode
Interactive Mode Script Mode
Individual statements are executed instantaneously. More than one instruction can be written in a Python source-code file.
Useful for testing a single line of code. A program can be written, saved and executed later.
Statements cannot be saved for future use in the interactive session. Python scripts are saved with the .py extension.

Program 5-1

#Program 5-1 #To show print statement in script mode print(“Hello World”)

5.2 Python Keywords

Keywords are reserved words. Each keyword has a specific meaning to the Python interpreter.

Keyword Keyword Keyword Keyword Keyword
False class finally is return
None continue for lambda try
True def from nonlocal while
and del global not with
as elif if or yield
assert else import pass
break except in raise

5.3 Identifiers

Identifiers are names used to identify variables, functions or other entities in a program.

Rules for Identifiers

  • An identifier can begin with an alphabet or underscore.
  • It can contain alphabets, digits and underscores.
  • It cannot begin with a digit.
  • It cannot be a Python keyword.
  • Special symbols such as !, @, #, $, % etc. cannot be used.
  • Python identifiers are case-sensitive.
  • Meaningful and readable names are preferred.

Good Examples

avg = (marks1 + marks2 + marks3)/3 area = length * breadth
Exam Tip: Use meaningful names such as marks1, marks2, marks3, avg, area, length instead of unclear single-letter names.

5.4 Variables

A variable in a program is uniquely identified by a name or identifier. A variable in Python refers to an object stored in memory.

The value of a variable can be a string, numeric value or other data.

Python uses an assignment statement to create variables and assign values. Variable declaration is implicit in Python.

Variables must be assigned values before they are used in expressions.

Program 5-2

#Program 5-2 #To display values of variables message = “Keep Smiling” print(message) userNo = 101 print(‘User Number is’, userNo)

Output

Keep Smiling User Number is 101

Program 5-3

#Program 5-3 #To find the area of a rectangle length = 10 breadth = 20 area = length * breadth print(area)

Output

200

5.5 Comments

Comments are used to add a remark or note in source code. Comments are not executed by the interpreter.

Comments make source code easier for humans to understand and help document the meaning, purpose, input and output requirements of code.

Single-line Comment

#This is a comment amount = 3400 #totalMarks stores the sum of marks

Examples

gender = ‘M’ message = “Keep Smiling” price = 987.9

Program 5-4

#Program 5-4 #To find the sum of two numbers num1 = 10 num2 = 20 result = num1 + num2 print(result)

Output

30

5.6 Everything is an Object

Python treats every value or data item as an object.

Every object has a unique identity during its lifetime. The id() function returns the identity of an object.

>>> num1 = 20 >>> id(num1) 1433920576 >>> num2 = 30 – 10 >>> id(num2) 1433920576
Two variables can refer to the same object. The identity of an object can be examined using id().

5.7 Data Types

Every value in Python has a data type. The data type identifies the kind of data and the operations that can be performed on it.

5.7.1 Number

Data Type Description Examples
int Integer numbers -12, -3, 0, 125, 2
float Real or floating-point numbers -2.04, 4.0, 14.23
complex Complex numbers 3 + 4j, 2 – 2j

Boolean

Boolean is a subtype of integer and has the constants True and False.

>>> num1 = 10 >>> type(num1) <class ‘int’> >>> var1 = True >>> type(var1) <class ‘bool’> >>> float1 = -1921.9 >>> type(float1) <class ‘float’> >>> var2 = -3+7.2j >>> print(var2, type(var2)) (-3+7.2j) <class ‘complex’>

5.7.2 Sequence

A sequence is an ordered collection of items where each item is indexed by an integer.

String

A string is a group of characters enclosed in single or double quotation marks.

>>> str1 = ‘Hello Friend’ >>> str2 = “452”

List

A list is a sequence of comma-separated items enclosed in square brackets.

>>> list1 = [5, 3.4, “New Delhi”, “20C”, 45] >>> print(list1) [5, 3.4, ‘New Delhi’, ’20C’, 45]

Tuple

A tuple is a sequence of comma-separated items enclosed in parentheses. Once created, a tuple cannot be changed.

>>> tuple1 = (10, 20, “Apple”, 3.4, ‘a’) >>> print(tuple1) (10, 20, “Apple”, 3.4, ‘a’)

5.7.3 Set

A set is an unordered collection of comma-separated items enclosed in curly brackets. A set cannot contain duplicate entries.

>>> set1 = {10,20,3.14,”New Delhi”} >>> print(type(set1)) <class ‘set’> >>> set2 = {1,2,1,3} >>> print(set2) {1, 2, 3}

5.7.4 None

None is a special data type with a single value. It signifies absence of value.

>>> myVar = None >>> print(type(myVar)) <class ‘NoneType’> >>> print(myVar) None

5.7.5 Mapping β€” Dictionary

A dictionary stores data in key-value pairs inside curly brackets. A colon separates the key and value.

>>> dict1 = {‘Fruit’:’Apple’, ‘Climate’:’Cold’, ‘Price(kg)’:120} >>> print(dict1) {‘Fruit’: ‘Apple’, ‘Climate’: ‘Cold’, ‘Price(kg)’: 120} >>> print(dict1[‘Price(kg)’]) 120

5.7.6 Mutable and Immutable

Mutable Immutable
Values can be changed after creation and assignment. Values cannot be changed after creation and assignment.
Example: List Example: Integer

5.7.7 Deciding Usage of Python Data Types

Data Type When Preferred Example
List When a simple iterable collection needs frequent modification. Names of students in a class.
Tuple When data should not change. Names of months in a year.
Set When uniqueness is required and duplication should be avoided. List of artefacts in a museum.
Dictionary When fast lookup or key:value association is required. Mobile phone book.

5.8 Operators

An operator is used to perform a specific mathematical or logical operation on values. The values on which operators work are called operands.

Example: In 10 + num, 10 and num are operands and + is the operator.

5.8.1 Arithmetic Operators

Python supports arithmetic operators for basic arithmetic operations, modular division, floor division and exponentiation.

Operator Operation Description Example β€” Try in Lab
+ Addition Adds two numeric values. It can also concatenate two strings.
>>> num1 = 5 >>> num2 = 6 >>> num1 + num2 11 >>> str1 = “Hello” >>> str2 = “India” >>> str1 + str2 ‘HelloIndia’
Subtraction Subtracts the right operand from the left operand.
>>> num1 = 5 >>> num2 = 6 >>> num1 – num2 -1
* Multiplication Multiplies two values. It can repeat a string when the first operand is a string and the second is an integer.
>>> num1 = 5 >>> num2 = 6 >>> num1 * num2 30 >>> str1 = ‘India’ >>> str1 * 2 ‘IndiaIndia’
/ Division Divides the left operand by the right operand and returns the quotient.
>>> num1 = 8 >>> num2 = 4 >>> num2 / num1 0.5
% Modulus Divides the left operand by the right operand and returns the remainder.
>>> num1 = 13 >>> num2 = 5 >>> num1 % num2 3
// Floor Division Returns the quotient after removing the decimal part. It is also called integer division.
>>> num1 = 13 >>> num2 = 4 >>> num1 // num2 3 >>> num2 // num1 0
** Exponent Raises the operand on the left to the power of the operand on the right.
>>> num1 = 3 >>> num2 = 4 >>> num1 ** num2 81

5.8.2 Relational Operators

Relational operators compare values of operands and determine the relationship between them.

For the following examples, assume:
num1 = 10 num2 = 0 num3 = 10 str1 = “Good” str2 = “Afternoon”
Operator Operation Description Example β€” Try in Lab
== Equals to True if the values are equal; otherwise False.
>>> num1 == num2 False >>> str1 == str2 False
!= Not equal to True if values are not equal.
>>> num1 != num2 True >>> str1 != str2 True >>> num1 != num3 False
> Greater than True if the left operand is greater than the right operand.
>>> num1 > num2 True >>> str1 > str2 True
< Less than True if the left operand is less than the right operand.
>>> num1 < num3 False >>> str2 < str1 True
>= Greater than or equal to True if the left operand is greater than or equal to the right operand.
>>> num1 >= num2 True >>> num2 >= num3 False >>> str1 >= str2 True
<= Less than or equal to True if the left operand is less than or equal to the right operand.
>>> num1 <= num2 False >>> num2 <= num3 True >>> str1 <= str2 False
String comparison: Python compares strings lexicographically using the ASCII value of characters. If the first characters are the same, the next characters are compared.

5.8.3 Assignment Operators

An assignment operator assigns or changes the value of the variable on its left.

Operator Description Example β€” Try in Lab
= Assigns the value from the right-side operand to the left-side operand.
>>> num1 = 2 >>> num2 = num1 >>> num2 2 >>> country = ‘India’ >>> country ‘India’
+= Adds the right operand to the left operand and assigns the result.
x += y is same as x = x + y
>>> num1 = 10 >>> num2 = 2 >>> num1 += num2 >>> num1 12 >>> num2 2 >>> str1 = ‘Hello’ >>> str2 = ‘India’ >>> str1 += str2 >>> str1 ‘HelloIndia’
-= Subtracts the right operand from the left operand and assigns the result.
x -= y is same as x = x – y
>>> num1 = 10 >>> num2 = 2 >>> num1 -= num2 >>> num1 8
*= Multiplies the left operand by the right operand and assigns the result.
x *= y is same as x = x * y
>>> num1 = 2 >>> num2 = 3 >>> num1 *= 3 >>> num1 6 >>> a = ‘India’ >>> a *= 3 >>> a ‘IndiaIndiaIndia’
/= Divides the left operand by the right operand and assigns the result.
x /= y is same as x = x / y
>>> num1 = 6 >>> num2 = 3 >>> num1 /= num2 >>> num1 2.0
%= Performs modulus operation and assigns the result.
x %= y is same as x = x % y
>>> num1 = 7 >>> num2 = 3 >>> num1 %= num2 >>> num1 1
//= Performs floor division and assigns the result.
x //= y is same as x = x // y
>>> num1 = 7 >>> num2 = 3 >>> num1 //= num2 >>> num1 2
**= Performs exponential calculation and assigns the value.
x **= y is same as x = x ** y
>>> num1 = 2 >>> num2 = 3 >>> num1 **= num2 >>> num1 8

5.8.4 Logical Operators

Python supports three logical operators: and, or, not. They must be written in lower case.

Operator Operation Description Example β€” Try in Lab
and Logical AND If both operands are True, the condition becomes True.
>>> True and True True >>> num1 = 10 >>> num2 = -20 >>> bool(num1 and num2) True >>> True and False False >>> num3 = 0 >>> bool(num1 and num3) False >>> False and False False
or Logical OR If any one of the two operands is True, the condition becomes True.
>>> True or True True >>> True or False True >>> bool(num1 or num3) True >>> False or False False
not Logical NOT Reverses the logical state of its operand.
>>> num1 = 10 >>> bool(num1) True >>> not num1 >>> bool(num1) False
By default, values are logically True except values such as None, False, 0, empty strings, empty tuples, empty lists and empty dictionaries.

5.8.5 Identity Operators

Identity operators are used to determine whether two variables are referring to the same object.

Operator Description Example β€” Try in Lab
is Evaluates True if the variables on either side point towards the same memory location and False otherwise.
>>> num1 = 5 >>> type(num1) is int True >>> num2 = num1 >>> id(num1) 1433920576 >>> id(num2) 1433920576 >>> num1 is num2 True
is not Evaluates False when variables point to the same object and True otherwise.
>>> num1 is not num2 False

5.8.6 Membership Operators

Membership operators check whether a value is a member of a given sequence or not.

Operator Description Example β€” Try in Lab
in Returns True if the value is found in the specified sequence and False otherwise.
>>> a = [1,2,3] >>> 2 in a True >>> ‘1’ in a False
not in Returns True if the value is not found in the specified sequence and False otherwise.
>>> a = [1,2,3] >>> 10 not in a True >>> 1 not in a False

5.9 Expressions

An expression is a combination of constants, variables and operators. An expression always evaluates to a value.

A value or standalone variable is also considered an expression, but a standalone operator is not an expression.

Examples of Valid Expressions

100 num num – 20.4 3.0 + 3.14 23/3 – 5 * 7(14 – 2) “Global” + “Citizen”

5.9.1 Precedence of Operators

When an expression contains different types of operators, precedence determines which operator is applied first.

Higher-precedence operators are evaluated before lower-precedence operators.

Order Operators Description
1 ** Exponentiation
2 ~, +, – Complement, unary plus and unary minus
3 *, /, %, // Multiplication, division, modulo and floor division
4 +, – Addition and subtraction
5 <=, <, >, >=, ==, != Relational and comparison operators
6 =, %=, /=, //=, -=, +=, *=, **= Assignment operators
7 is, is not Identity operators
8 in, not in Membership operators
9 not Logical NOT
10 and Logical AND
11 or Logical OR
Important Rules:

1. Parentheses can override operator precedence. The expression inside parentheses is evaluated first.

2. Operators having equal precedence are evaluated from left to right.

Example 5.9

20 + 30 * 40 = 20 + (30 * 40) = 20 + 1200 = 1220

Example 5.10

20 – 30 + 40 = (20 – 30) + 40 = -10 + 40 = 30

Example 5.11

(20 + 30) * 40 = 50 * 40 = 2000

Example 5.12

15.0 / 4 + (8 + 3.0) = 15.0 / 4.0 + 11.0 = 3.75 + 11.0 = 14.75

5.10 Statement

In Python, a statement is a unit of code that the Python interpreter can execute.

Example 5.13

>>> x = 4 # assignment statement >>> cube = x ** 3 # assignment statement >>> print(x, cube) # print statement 4 64

5.11 Input and Output

input()

The input() function prompts the user to enter data. It accepts user input as a string.

Syntax

input([Prompt])

The prompt is optional. When specified, it is displayed before the user enters data.

Example 5.14

>>> fname = input(“Enter your first name: “) Enter your first name: Arnab >>> age = input(“Enter your age: “) Enter your age: 19 >>> type(age) <class ‘str’>

Example 5.15

#function int() to convert string to integer >>> age = int(input(“Enter your age:”)) Enter your age: 19 >>> type(age) <class ‘int’>

print()

Python uses the print() function to output data to the standard output device β€” the screen.

Syntax

print(value [, …, sep = ‘ ‘, end = ‘\n’])
Parameter Purpose Default
sep Separator between output values. Space
end String appended after the last value. New line

Example 5.16

Statement Output
print(“Hello”)
Hello
print(10*2.5)
25.0
print(“I” + “love” + “my” + “country”)
Ilovemycountry
print(“I’m”, 16, “years old”)
I’m 16 years old
Remember: The + operator concatenates strings without inserting a space. A comma between print arguments separates the values using the separator.

5.12 Type Conversion

Type conversion means changing the data type of a variable from one type to another.

Type conversion can happen in two ways:

  • Explicit conversion
  • Implicit conversion

Input Example

num1 = input(“Enter a number and I’ll double it: “) num1 = num1 * 2 print(num1)

If the user enters 2, the output is:

Enter a number and I’ll double it: 2 22

This happens because input() returns a string by default, so * acts as a repetition operator.

Corrected Version

num1 = input(“Enter a number and I’ll double it: “) num1 = int(num1) num1 = num1 * 2 print(num1)

Output

Enter a number and I’ll double it: 2 4

5.12.1 Explicit Conversion

Explicit conversion, also called type casting, happens when the programmer forces data type conversion.

Syntax

(new_data_type)(expression)
Function Description
int(x) Converts x to integer.
float(x) Converts x to floating-point number.
str(x) Converts x to string representation.
chr(x) Converts ASCII value of x to character.
ord(x) Returns the character associated with the ASCII code x.

Program 5-5

#Program 5-5 #Explicit type conversion from int to float num1 = 10 num2 = 20 num3 = num1 + num2 print(num3) print(type(num3)) num4 = float(num1 + num2) print(num4) print(type(num4))

Program 5-6

#Program 5-6 #Explicit type conversion from float to int num1 = 10.2 num2 = 20.6 num3 = (num1 + num2) print(num3) print(type(num3)) num4 = int(num1 + num2) print(num4) print(type(num4))

Program 5-7 β€” Type Conversion between Numbers and Strings

#Program 5-7 #Type Conversion between Numbers and Strings priceIcecream = 25 priceBrownie = 45 totalPrice = priceIcecream + priceBrownie print(“The total is Rs.” + totalPrice)
The above program produces an error because Python does not implicitly convert the integer value to a string for this concatenation.

Program 5-8 β€” Explicit Type Casting

#Program 5-8 #Explicit type casting priceIcecream = 25 priceBrownie = 45 totalPrice = priceIcecream + priceBrownie print(“The total in Rs.” + str(totalPrice))

Output

The total in Rs.70

Program 5-9 β€” Explicit Type Conversion

#Program 5-9 #Explicit type conversion icecream = ’25’ brownie = ’45’ #String concatenation price = icecream + brownie print(“Total Price Rs.” + price) #Explicit type conversion – string to integer price = int(icecream)+int(brownie) print(“Total Price Rs.” + str(price))

Output

Total Price Rs.2545 Total Price Rs.70

5.12.2 Implicit Conversion

Implicit conversion, also known as coercion, happens automatically by Python without being instructed by the programmer.

Program 5-10

#Program 5-10 #Implicit type conversion from int to float num1 = 10 num2 = 20.0 sum1 = num1 + num2 print(sum1) print(type(sum1))

Output

30.0 <class ‘float’>
Python performs type promotion when possible by converting data into a wider-sized data type without loss of information.

5.13 Debugging

A programmer can make mistakes while writing a program. The program may not execute or may generate incorrect output.

Debugging is the process of identifying and removing mistakes, bugs or errors from a program.

5.13.1 Syntax Errors

A syntax error occurs when the program does not follow Python syntax rules.

(10 + 12) (7 + 11

5.13.2 Logical Errors

A logical error occurs when a program executes but produces an undesired or incorrect output.

10 + 12/2 Correct average: (10 + 12)/2

5.13.3 Runtime Error

A runtime error occurs while the program is executing.

Division by zero is an example of a runtime error.

Program 5-11

#Program 5-11 #Runtime Errors Example num1 = 10.0 num2 = int(input(“num2 = “)) # if user inputs a string or a zero, # it leads to runtime error print(num1/num2)

πŸ“ Important Questions & Answers

1. What is a program?

An ordered set of instructions executed by a computer to carry out a specific task.

2. What is a programming language?

A language used to specify instructions to a computer.

3. What is source code?

A program written in a high-level programming language.

4. What is an interpreter?

An interpreter processes program statements one by one, translating and executing them.

5. What are keywords?

Keywords are reserved words having specific meanings to the Python interpreter.

6. What are identifiers?

Identifiers are names used to identify variables, functions and other entities in a program.

7. What is a variable?

A variable is a name that refers to an object stored in memory.

8. What is a comment?

A comment is a remark or note in source code that is not executed by the interpreter.

9. Name the three number data types.

int, float and complex.

10. What is a list?

A list is a sequence of comma-separated items enclosed in square brackets.

11. What is a tuple?

A tuple is a sequence of comma-separated items enclosed in parentheses. It cannot be changed after creation.

12. What is a set?

A set is an unordered collection of items that cannot contain duplicate entries.

13. What is a dictionary?

A dictionary stores data in key-value pairs.

14. What is type conversion?

Type conversion is the process of changing a value from one data type to another.

15. What is explicit conversion?

Explicit conversion is type conversion forced by the programmer.

16. What is implicit conversion?

Implicit conversion is type conversion performed automatically by Python.

17. What is debugging?

Debugging is the process of identifying and removing errors from a program.

18. Name the three major types of errors.

Syntax errors, logical errors and runtime errors.

19. What is an expression?

An expression is a combination of constants, variables and operators that evaluates to a value.

20. What is the Python prompt?

The symbol >>> is called the Python prompt.

21. What is the default data type returned by input()?

String.

22. What is the purpose of print()?

It displays data on the standard output device, the screen.

23. What are mutable and immutable data types?

Mutable data can be changed after creation, whereas immutable data cannot be changed after creation.

24. What are identity operators?

Identity operators determine whether variables refer to the same object.

25. What are membership operators?

Membership operators check whether a value belongs to a given sequence.

πŸ“– Textbook Exercise β€” Questions 1 to 21

Exam Preparation: The following are the chapter-end textbook exercise tasks. Prepare the required Python logic/programs from the textbook.
1.

Identify the valid and invalid identifier names and give reasons based on Python identifier rules.

2.

Write corresponding Python assignment statements for the given values and variables.

3.

Write and evaluate logical expressions for the given conditions.

4.

Add parentheses to the expressions so that they evaluate to True.

5.

Find the output of the given Python variable-assignment programs.

6.

Choose appropriate Python data types for the given data and explain the choice.

7.

For the given values of variables, evaluate the specified expressions.

8.

Identify whether the given situations represent syntax, logical or runtime errors.

9.

Write an expression to test whether a dart lies within the specified dartboard radius.

10.

Write a Python program to convert Celsius temperature to Fahrenheit.

11.

Write a program to calculate the amount payable using simple interest.

12.

Write a program to calculate in how many days a work will be completed by three persons A, B and C working together.

If A, B and C take x, y and z days respectively to complete the work alone, the textbook gives the formula:

xyz / (xy + yz + xz)
13.

Write a program to enter two integers and perform all arithmetic operations on them.

14.

Write a program to swap two numbers using a third variable.

15.

Write a program to swap two numbers without using a third variable.

16.

Write a program to repeat the string GOOD MORNING n times, where n is an integer entered by the user.

17.

Write a program to find the average of three numbers.

18.

The volume of a sphere with radius r is 4/3 Ο€rΒ³. Write a Python program to find the volume of spheres with radii 7 cm, 12 cm and 16 cm respectively.

19.

Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the year in which the user will turn 100 years old.

20.

Using the formula E = mcΒ², where the speed of light is approximately 3 Γ— 10⁸ m/s, write a program that accepts the mass of an object and determines its energy.

21.

A ladder is placed upright against a wall. Let length and angle store the length of the ladder and the angle it makes with the ground. Write a Python program to calculate the height reached by the ladder on the wall for:

  • 16 feet and 75 degrees
  • 20 feet and 0 degrees
  • 24 feet and 45 degrees
  • 24 feet and 80 degrees

⚑ Quick Revision

Important Definitions

  • Program: Ordered set of instructions executed to perform a specific task.
  • Programming Language: Language used to specify instructions to a computer.
  • Source Code: Program written in a high-level language.
  • Interpreter: Translates and executes statements one by one.
  • Keyword: Reserved word with a predefined meaning.
  • Identifier: Name used to identify a program entity.
  • Variable: Name referring to an object stored in memory.
  • Comment: Non-executable remark in source code.
  • Expression: Combination of constants, variables and operators that evaluates to a value.
  • Statement: Unit of code executable by the Python interpreter.
  • Debugging: Process of identifying and removing errors.

Important Data Types

Category Types
Number int, float, complex
Boolean True, False
Sequence String, List, Tuple
Set Set
Special None
Mapping Dictionary

Important Operators

Category Operators
Arithmetic +, -, *, /, %, //, **
Relational ==, !=, >, <, >=, <=
Assignment =, +=, -=, *=, /=, %=, //=, **=
Logical and, or, not
Identity is, is not
Membership in, not in

Operator Precedence

Priority Operators
1**
2~, +, –
3*, /, %, //
4+, –
5<=, <, >, >=, ==, !=
6=, %=, /=, //=, -=, +=, *=, **=
7is, is not
8in, not in
9not
10and
11or

Input / Output

input([Prompt]) print(value [, …, sep = ‘ ‘, end = ‘\n’])

Type Conversion

  • Explicit: Programmer forces the conversion.
  • Implicit: Python performs the conversion automatically.

Three Major Errors

Error Meaning
Syntax Error Program does not follow Python syntax rules.
Logical Error Program executes but produces incorrect or undesired output.
Runtime Error Error occurs while the program is executing.
πŸ”₯ Last-Minute Exam Checklist
  • Learn Python features.
  • Learn identifier rules.
  • Learn all data types.
  • Learn mutable vs immutable.
  • Learn all operator categories.
  • Practise every Try in Lab example.
  • Learn operator precedence.
  • Learn input() and print() syntax.
  • Learn explicit and implicit conversion.
  • Learn syntax, logical and runtime errors.
  • Practise textbook programs.
  • Practise Exercise 1–21.
  • Read the SMIS case study and documentation checklist.

🎯 Final Revision

This chapter provides the basic foundation required to start programming with Python. For examination preparation, students should give special attention to definitions, identifier rules, data types, operator tables, Try in Lab examples, expressions, precedence, input-output functions, type conversion, debugging, textbook programs and exercise questions.

Study Strategy: First learn the definitions β†’ then understand the tables β†’ run the Try in Lab examples β†’ practise the textbook programs β†’ finally revise Exercise 1–21.
verakworld.com
Β© VerakWorld | Educational Notes
1st PUC Computer Science – Chapter 5: Getting Started with Python

Leave a Comment