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

Python Notes Class VI Rev

Uploaded by

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

Python Notes Class VI Rev

Uploaded by

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

Class – VI

Subject – Artificial Intelligence (2024-25)


Chapter- Introduction to Python
Character Set:

 Python supports Unicode, which means it can handle characters from different
languages and scripts.
 You can use a wide range of characters in your Python code, including letters,
numbers, symbols, and even emojis.
Variables:
 Variables are used to store data in Python.
 You can assign a value to a variable using the assignment operator (=).
 Variable names must start with a letter or an underscore (_), followed by letters,
numbers, or underscores.
 Example:
x = 10
name = "John"

Data Types:-
Data types in Python are classifications for data objects that are based on their
characteristics and behavior. They determine the type of values that variables
can hold and the operations that can be performed on those values.
 Python has several built-in data types:
o Numeric: int (integer), float (floating-point number), complex (complex
number)
o String: str (sequence of characters)
Input function:
 The input() function is used to take input from the user.
 It takes an optional prompt string as an argument, which is displayed to the user.
 The input function always returns a string.
name = input("What is your name? ")
print("Hello,", name)
Print function:
 The print() function is used to display output on the console.
 It can take multiple arguments, which are printed separated by spaces.
 The end parameter can be used to specify a different ending character (default is
a newline).
 The sep parameter can be used to specify a different separator between
arguments (default is a space).
print("Hello", "World")
OPERATORS –
In Python, operators are special symbols that perform operations on values and
variables. They allow you to manipulate data, perform calculations, make
comparisons, and more.

 Arithmetic operators: Perform basic mathematical operations like addition


(+), subtraction (-), multiplication (*), division (/), modulus (%), exponentiation
(**), and floor division (//).
 Assignment operators: Assign values to variables, such as = (simple
assignment), += (add and assign), -= (subtract and assign), and so on.
 Comparison/Relational operators: Compare values and return a Boolean
result (True or False), such as == (equal to), != (not equal to), > (greater
than), < (less than), >= (greater than or equal to), and <= (less than or equal to).
 Logical operators: Combine Boolean values using and, or, and not.
1. Program to find sum of two numbers.

num1 = int(input("Enter First Number: "))


num2 = int(input("Enter Second Number: "))
product=num1+num2
print(product)

2. Program to find product of two numbers.

num1 = int(input("Enter First Number: "))


num2 = int(input("Enter Second Number: "))
sum=num1*num2
print(sum)

3. Program to find area of a rectangle.

L = int(input("Enter Length: "))


B = int(input("Enter Breadth: "))
area=L*B
print(area)

4. Program to find perimeter of a rectangle.

L = int(input("Enter Length: "))


B = int(input("Enter Breadth: "))
peri=2*(L+B)
print(peri)
5. Program to find area of a square.

side = int(input("Enter side: "))


area=side*side
print(area)

6. Program to find perimeter of a square.

side = int(input("Enter side: "))


peri=4*side
print(peri)

Exercise
1.Which of the following is true for variable names in Python?
a) underscore and ampersand are the only two special characters allowed
b) unlimited length
c) all private members must have leading and trailing underscores
d) none of the mentioned
2.Who developed Python Programming Language?
a) Wick van Rossum
b) RasmusLerdorf
c) Guido van Rossum
d) NieneStom
3.In which year was the Python language developed?
a) 1995
b) 1972
c) 1981
d) 1989
4.Which one of the following is the correct extension of the Python file?
a) .py
b) .python
c) .p
d) None of these
5.In which year was the Python 3.0 version developed?
a) 2008
b) 2000
c) 2010
d) 2005
1. The print function can only print literal values. (False)
2. Variables change their value over time according to the instruction in a
program.(True)
3. Variables in Python are used to solve for unknown values, like in Algebra.
(False)
4. Normally, statements are executed from top to bottom. (True)
5. Expressions are always evaluated from left to right.(False)
1. What is python ?

Answer - Python is a programming language that is widely used in web


applications, software development, data science, and machine learning (ML).
Developers use Python because it is efficient and easy to learn and can run on
many different platforms.

2. Write some Python Features and Advantages.


Answer –
Easy to Code.
Easy to Read.
Free and Open-Source.
Robust Standard Library
Interpreted
Portable
Object-Oriented and Procedure-Oriented.
Extensible.
3. What are the major application of Python.
Answer - Build a website, Develop games, Program games, Perform scientific
computation, Develop artificial intelligence application

You might also like