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

Ch-Python Class 9

This document provides an introduction to Python, highlighting its features, applications, and basic concepts such as comments, variables, data types, input/output, and operators. It explains the modes of Python usage, including interactive and script modes, and mentions that Python programs are saved with a .py file extension. Additionally, it covers arithmetic operators and the importance of naming conventions for variables.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Ch-Python Class 9

This document provides an introduction to Python, highlighting its features, applications, and basic concepts such as comments, variables, data types, input/output, and operators. It explains the modes of Python usage, including interactive and script modes, and mentions that Python programs are saved with a .py file extension. Additionally, it covers arithmetic operators and the importance of naming conventions for variables.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Class 9 Artificial Intelligence: Introduction to Python Notes

1. What is Python?

Python is a high-level, interpreted, and general-purpose programming language.


It was created by Guido van Rossum in 1991.
2. Write the features of Python

Simple and Easy to Learn: Python has a simple syntax that is easy to understand.

Interpreted: Python code is executed line by line.

High-Level Language: Python allows you to write programs that are closer to human language.

Portable: Python code can run on different platforms (Windows, Mac, Linux).

Open Source: Python is free to use and its source code is available to everyone.
3. Write the applications of Python

Artificial Intelligence (AI) and Machine Learning

Web Development (using frameworks like Django, Flask)

Game Development

Data Science and Data Analysis

Automation (Scripts)

GUI Applications
4. Mention the modes in Python
Python shell can be used in two ways, viz., interactive mode and script mode. Where Interactive Mode, as
the name suggests, allows us to interact with OS; script mode lets us create and edit Python source file.
5. Explain Python Basics.

a) Comments

A comment is text that doesn't affect the outcome of a code; it is just a piece of text to let someone know
what you have done in a program or what is being done in a block of code.
Single-line comment: # This is a comment

Multi-line comment:
'''
This is a
Multi-line comment
'''
b) Variable
A variable is a named placeholder of data that is assigned a value. If the value is modified, the name does
not change. A variable in Python can hold any type of data value.
Follow some rules of naming convention while declaring a variable. These rules are:

1. It must start with an alphabet.


2. It should not have any space, special characters.
3. Keywords cannot be used as variable.

c) Data Types
In Python, each value has a data type. Data types are basically classes, and variables are instances
(objects) of these classes, because everything in Python programming is an object.
a) Integer & Long
Integer & Long Integer Range of an integer in Python can be from -2147483648 to 2147483647, and long
integer has unlimited range subject to available memory.
b) Float / floating point
Numbers with fractions or decimal point are called floating point numbers.
c) String
String is an ordered sequence of letters/characters. They are enclosed in single quotes (‘ ‘) or double (“ “).
d) Lists
List is also a sequence of values of any type. Values in the list are called elements / items. These are
indexed/ordered.
6. Explain Input and Output in Python

Input: Used to take input from the user.


name = input("Enter your name: ")
print("Hello, " + name)

Output: Used to display data.


print("Welcome to Python!")
7. Mention the Operators use in Python
Operators are special symbols which represent computation. They are applied on operand(s), which can be values
or variables.
Value and variables when used with operator are known as operands.
Arithmetic Operators:
a) Addition: (+) Adds two numbers, for example, 5 + 3 = 8
b) Subtraction: (-) Subtracts the second number from the first, for example, 10 - 4 = 6
c) Multiplication: (*) Multiplies two numbers, for example, 7 * 6 = 42
d) Division: (/) Divides the first number by the second, always returning a floating-point result, for
example, 8 / 2 = 4.0
e) Floor Division: (//) Divides the first number by the second, returning the largest integer less than or
equal to the result, for example, 9 // 2 = 4
f) Modulus: (%) Returns the remainder of the division of the first number by the second, for example,
10 % 3 = 1
g) Exponentiation: (**) Raises the first number to the power of the second number, for example, 3 **
5 = 35
8. Mention the file extension of Python
Every Python program is written in .py files.

You might also like