0% found this document useful (0 votes)
12 views

python-program-file-CLASS-9TH

This document is a practical file for Grade IX students at BCM Aray School, covering fundamental concepts of Python programming. It includes topics such as variables, data types, operators, control structures, functions, lists, tuples, dictionaries, and sets, along with examples and outputs for each concept. Additionally, it features simple programs for calculating the area of a circle, checking even or odd numbers, and finding the largest among three numbers.

Uploaded by

preetikaushalbcm
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

python-program-file-CLASS-9TH

This document is a practical file for Grade IX students at BCM Aray School, covering fundamental concepts of Python programming. It includes topics such as variables, data types, operators, control structures, functions, lists, tuples, dictionaries, and sets, along with examples and outputs for each concept. Additionally, it features simple programs for calculating the area of a circle, checking even or odd numbers, and finding the largest among three numbers.

Uploaded by

preetikaushalbcm
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

PRACTICAL FILE

PYTHON

Student Name :

Grade : IX- PYTHON

Roll No. :

BCM ARAY SCHOOL (Sr. Sec.)


Singla-Enclave, Lalton-Dolon Khurd, Ludhiana

Contact: 01615206600, 62845-56494


Email- [email protected], www.bcmaryaschool.com
1.Variables and Data Types

 Variable declaration
 Data types: integers, floats, strings, and booleans
 Example:

name = "John"
age = 15
height = 5.8
is_student = True
print(name, age, height, is_student)

Output:

2.Operators

 Arithmetic operators (+, -, *, /, //, %)


 Comparison operators (==, !=, >, <, >=, <=)
 Logical operators (and, or, not)
 Example:

a = 10
b = 20
print("Sum:", a + b)
print("Is a greater than b?", a > b)

Output:
3.Input and Output

 Using input() for taking user input


 Using print() for displaying output
 Example:

name = input("Enter your name: ")


print("Hello,", name)

Output

4.Control Structures

 Conditional Statements: if, if-else, if-elif-else


o Example:

age = int(input("Enter your age: "))


if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")

Output

5.Loops: for and while loops

for loop example:

Copy code
for i in range(1, 6):
print("Number:", i)
Output:

while loop example:

Copy code
n=5
while n > 0:
print(n)
n -= 1

Output:

6. Functions

 Defining and calling functions


 Using return to get output from functions
 Example:

def greet(name):
return "Hello, " + name

print(greet("Alice"))

Output:

7. Lists and Tuples

 Lists: Creating, accessing, and modifying lists


 Tuples: Creating and accessing tuples (immutable lists)
 Example:

fruits = ["apple", "banana", "cherry"]


print(fruits[1]) # Output: banana

fruits[1] = "orange"
print(fruits) # Output: ["apple", "orange", "cherry"]
Output:

8. Dictionaries and Sets

 Dictionaries: Key-value pairs

Example:

Copy code
student = {"name": "Alice", "age": 14, "class": "9th"}
print(student["name"]) # Output: Alice

Output:

Sets: Unique collection of items

 Example:

Copy code
unique_numbers = {1, 2, 3, 4, 4, 5}
print(unique_numbers) # Output: {1, 2, 3, 4, 5}

Output:

9.Calculate Area of a Circle

radius = float(input("Enter radius: "))


area = 3.14159 * radius * radius
print("Area of the circle:", area)
Output:

10.Check Even or Odd

num = int(input("Enter a number: "))


if num % 2 == 0:
print("Even")
else:
print("Odd")

Output:

10.Find the Largest Number Among Three Numbers

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a > b and a > c:
print("Largest:", a)
elif b > c:
print("Largest:", b)
else:
print("Largest:", c)

Output:

You might also like