Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

UNIT 04-Introduction to Python

This document provides an introduction to Python, highlighting its features such as simplicity, readability, and cross-platform compatibility. It covers basic syntax, control structures, input/output operations, and includes example programs for practical application. The document serves as a foundational guide for Class IX students studying Artificial Intelligence at Cambridge Court High School.

Uploaded by

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

UNIT 04-Introduction to Python

This document provides an introduction to Python, highlighting its features such as simplicity, readability, and cross-platform compatibility. It covers basic syntax, control structures, input/output operations, and includes example programs for practical application. The document serves as a foundational guide for Class IX students studying Artificial Intelligence at Cambridge Court High School.

Uploaded by

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

CAMBRIDGE COURT HIGH SCHOOL

Class IX
Subject - Artificial Intelligence
UNIT 4: Introduction To Python

1. What is Python?

● Python is a high-level, interpreted programming language known for its simplicity and readability.
● It is widely used for web development, data analysis, artificial intelligence, and more.

2. Features of Python

● Easy to Learn and Use: Python's syntax is simple and close to human language.
● Interpreted Language: Code is executed line by line, which makes debugging easier.
● Cross-Platform: Python works on various operating systems like Windows, macOS, and Linux.
● Open Source: Python is free to use and distribute, including for commercial purposes.

3. Basic Python Syntax


● Comments: Start with #. They are not executed.
# This is a comment

● Variables: Used to store data.


x=5
name = "Alice"

● Data Types: Common types include int, float, str, bool.


age = 15 # int
height = 5.7 # float
name = "Alice" # str
is_student = True # bool

● Operators: Used for mathematical and logical operations.

sum = 5 + 3 # Addition
product = 5 * 3 # Multiplication
is_equal = (5 == 5) # Comparison (True or False)

4. Control Structures
● Conditional Statements: Used to make decisions.

if age > 18:


print("You are an adult.")
else:
print("You are a minor.")

5. Loops: Used to repeat actions.

● For Loop: Iterates over a sequence.

for i in range(5):
print(i)
● While Loop: Continues until a condition is met.

count = 0
while count < 5:
print(count)
count += 1

6. Input and Output


● Input: Taking user input.

name = input("Enter your name: ")

● Output: Displaying information.

print("Hello, " + name)

7. Basic Programs

1. Hello, World

print("Hello, World!")

2. Simple Calculator
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
sum = num1 + num2
print("Sum:", sum)

Program List

PRINT • To print personal information like Name, Father’s Name, Class, School Name
• To find square of number 7
• To find the sum of two numbers 15 and 20
• To convert length given in kilometers into meters
• To print the table of 5 up to five terms
• To calculate Simple Interest if the principle_amount = 2000, rate_of_interest =
4.5, time = 10

INPUT • To calculate Area and Perimeter of a rectangle


• To calculate Area of a triangle with Base and Height
• To calculate average marks of 3 subjects
• To calculate discounted amount with discount %
• To calculate Surface Area and Volume of a Cuboid

IF, FOR, • Program to check if a person can vote


WHILE • To check the grade of a student
• Input a number and check if the number is positive, negative or zero and
display an appropriate message
• To print first 10 natural numbers
• To print first 10 even numbers
• To print odd numbers from 1 to n
• To print sum of first 10 natural numbers

You might also like