Notes Important
Notes Important
Data Science
Computer Vision
Natural Language Processing (NLP)
Problem Scoping
Data Acquisition
Data Exploration
Modeling
Evaluation
a=5
b = 10
print("Sum:", a + b)
NumPy
Pandas
Matplotlib
import numpy as np
data = [10, 20, 30, 40]
mean = np.mean(data)
print("Mean:", mean)
20. What are the common types of graphs used in data visualization?
Line chart
Bar graph
Scatter plot
24. Write a Python program to read and display an image using OpenCV.
import cv2
image = cv2.imread('image.jpg')
cv2.imshow('Image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Chatbots
Sentiment analysis
Translation tools
Chapter 7: Evaluation
Problem-Solving in AI
Real-Life Applications
37. What is the difference between validation and testing in model evaluation?
Validation: Used during model training to tune parameters.
Testing: Used after training to measure the model’s final performance.
import pandas as pd
Structured Data: Organized in a fixed format, like rows and columns (e.g.,
databases).
Unstructured Data: Does not follow a specific format (e.g., images, videos).
import numpy as np
data = [10, 20, 30, 40]
std_dev = np.std(data)
print("Standard Deviation:", std_dev)
Cleaning
Normalization
Transformation
Feature selection
Image classification
Object detection
Image segmentation
import cv2
image = cv2.imread('image.jpg')
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow('Grayscale Image', gray_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Real-Life Applications of AI
Siri
Alexa
Google Assistant
78. What is the difference between a for loop and a while loop in Python?
import pandas as pd
data = pd.read_csv('data.csv')
print(data.head())
Mean
Median
Mode
Standard Deviation
87. Write a Python program to apply Gaussian blur to an image using OpenCV.
import cv2
image = cv2.imread('image.jpg')
blurred_image = cv2.GaussianBlur(image, (5, 5), 0)
cv2.imshow('Blurred Image', blurred_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
88. What is the difference between edge detection and segmentation in CV?
Ambiguity in language.
Understanding context.
Handling unstructured data.
92. Write a Python program to count the frequency of words in a text.
Question 1.
What is Jupyter Notebook?
Answer:
Jupyter Notebook is an open-source web application that allows users to create and share interactive documents containing live
code, equations, visualizations, and text. It’s particularly popular in AI-related projects and primarily uses Python, although it
supports other programming languages too.
Question 2.
How to access Jupyter Notebook?
Answer:
To access Jupyter Notebook:
1. Install Anaconda.
2. Open Anaconda Navigator.
3. Launch Jupyter Notebook from the Navigator interface or by using the Anaconda Prompt with the command jupyter notebook.
Question 3.
What is Virtual Environment?
Answer:
A virtual environment in Python is a self-contained directory that houses a Python interpreter and its own set of libraries and
dependencies. It allows developers to work on multiple projects with different dependencies without conflicts.
Question 4.
What are the key features of Python? Mention various applications along with it.
Answer:
Refer to text on page 102 (Features of Python, Python Applications).
Question 5.
What is a Jupyter Notebook ?
Answer:
Refer to text on page 100 (Jupyter Notebook).
Question 6.
How can install jupyter notebook in anaconda prompt?
Answer:
Refer to text on page 100 (Installing Jupyter Using Anaconda)
Question 7.
Why do we need to install a kernel before running jupyter notebook?
Answer:
We need to install a kernel before running Jupyter Notebook because:
Question 1.
What is the output of print(type(25))?
Answer:
The output is <class ‘int’>.
Question 2.
Give one example of variable.
Answer:
age = 25, where age is the variable storing the value 25 .
Question 3.
Define Pandas libraries.
Answer:
Pandas is an open-source data manipulation and analysis library for Python. It provides data structures like DataFrame for efficient
data handling.
Question 4.
Define operator precedence.
Answer:
Operator precedence determines the order in which operators are evaluated in an expression. It ensures that certain operators are
evaluated before others.
Question 5.
Give one example of each of the following:
(a) Unary operator
(b) Comparison operator
Question 6.
Mention any one feature of List in Python.
Answer:
Lists in Python are versatile and can store elements of different data types in an ordered and mutable sequence.
Question 7.
What do you understand by iteration in programming?
Answer:
Iteration is the process of repeatedly executing a set of statements or a block of code.
Question 8.
Give any two features of OpenCV.
Answer:
Two features include image recognition and object detection.
Question 9.
Name the operator used for the following:
(a) To assign a value to a variable
(b) That returns True or False.
Answer:
(a) =
(b) Comparison operators, such as == or ! =
Question 10.
What is the minimum number of iterations that while loop could make?
Answer:
while loop could make minimum 0 iteration.
Question 1.
Identify and correct the error(s) from the given below variables.
(i) STD
(ii) 5STD
(iii) D
(iv) (Marks)
Answer:
(i) Error STD – – is not allowed. The correct form is STD
(ii) Error 5STD First character must be alphabet. The correct form is STD5.
(iii) Error D$$ is not allowed. The correct form is D.
(iv) Error (Marks) Brackets are not allowed. The correct form is Marks.
Question 2.
Differentiate between identifier and keyword.
Answer:
Differences between identifier and keyword are as follows
Identifier Keyword
Question 3.
What is the difference between statement and expression?
Answer:
Differences between statement and expression are as follows
Statement Expression
A statement is a complete line of code that An expression is any section of the code that evaluates
Statements can only be combined vertically by Expressions can be combined horizontally into larger
writing one after another or with block constructs. expressions using operators.
Question 4.
Shreya is programming in Python and writing a following code. But she found an error, what is the reason?
a = 10
b = 20
c=a+b
print (“The output is : ” , c)
Answer:
The above code is identation error and correct code is
a = 10
b = 20
c=a+b
print (“The output is : “, c)
Question 5.
Find the syntax error in the following program and underline after correct them.
w = 90 ;
while (w>60)
pringt (w)
w = w-50
Answer:
Correct code is
Question 6.
Construct logical expressions to represent the following conditions.
(i) Weight is greater than or equal to 115 but less than 125.
(ii) Donation is in the range of 4000-5000 or Guest is 1.
Answer:
(i) (weight >=115 and weight <125 )
(ii) ((Donation >=4000 and Donation <=5000 ) or Guest ==1 )
Question 7.
Write a Python program to calculate simple interest and display it.
Answer:
Output
Enter the principal : 5000
Enter rate of interest : 10
Enter time: 2
The simple interest is 1000.0
Question 8
What is a Python package?
Answer:
A Python package is a way of organising related modules into a single directory hierarchy. It helps in structuring Python’s module
namespace and avoids naming conflicts. Packages are directories containing module files and an __init__py file. They provide a
means of creating a hierarchical structure to organise and distribute Python code.
Question 1.
What do you understand by string literals? Explain.
Answer:
The literal which is stored in a variable within single quotation mark or double quotation marks is called string literal. These
represent a sequence of zero or more characters enclosed by double quotes. It can also include blank spaces.
Some valid string constants are
Some Invalid string constants are
Question 2.
Write a Python program with output to convert the centimeter value into meter and kilometer.
Answer:
Output
Enter value in centimeters: 5000
Length in meter = 50.0 m
Length in Kilometer = 0.05 km
Question 3.
An electricity board charges according to the following rules.
For the first 100 units – 40 P per unit
For the next 200 units – 50 P per unit
Beyond 300 units -60 P per unit
All users have to pay meter charge also, which is ₹ 50. Write a program to read the number of units consumed and print out the
charges.
Answer:
Output
Enter the number of units consumed: 125
The charges is : 102.5
Question 4.
Write a program to check whether a number is prime or not.
Answer:
Output
Enter the number : 67
n = 67
67 is a prime number
Question 5.
Write a program in Python to accept monthly salary from the user, find and display income tax with the help of following rules.
Answer:
Output
Enter monthly salary: 15000
Income tax is 6000.0
Question 6.
Write a Python program which enter the cost price and selling price of an item and find profit or loss.
Answer:
Output
Please Enter the Cost Price of an Item: 15000
Please Enter the Selling Price of an Item: 17500
Total Profit = 2500.0
Class 10 AI Advanced Python Notes
Jupyter Notebook Class 10 Notes
A Jupyter Notebook is a powerful tool widely used in the field of data science, research, and education. It provides an interactive
computing environment that allows you to create and share documents containing live code, equations, visualisations, and narrative
text.
Jupyter Notebooks support various programming languages, but it is most commonly associated with Python. Working with Jupyter
Notebook, virtual environment is one of the most important tools that used by Python developers.
A virtual environment is a self-contained directory that encapsulates a specific Python interpreter and its associated libraries. It
allows you to create an isolated environment for your Python projects, preventing conflicts between dependencies and ensuring that
each project has its own set of libraries and packages.
1. To install Python virtual environment – JUPYTER Notebook using ANACONDA, type the link:
https://www.anaconda.com/products/individual
2. Click on Download
3. Begin the installation process.
4. Getting through the License-Agreement
5. Select Installation Type: Select Just Me if you want the software to be used by a single user
6. Choose Installation Location.
7. Click on ‘Install’ button.
8. Getting through the Installation Process.
9. Finishing the installation.
Open Anaconda from the Start menu or by double click on the Anaconda icon on your desktop (if you have the icon). Anaconda
Navigator will open.
From the Anaconda Navigator – click on Launch button JUPYTER Notebook.
The Jupyter notebook will open in the default browser.
II. Notebook Kernel: The programs that we save on the notebook gets run with the help of an in-built interpreter. Kernel executes the
code and shows the result.
The window of the Jupyter notebook has the following parts:
Python is a versatile and high-level programming language known for its readability and simplicity. It is created by Guido van
Rossum.
Python supports multiple programming paradigms, including Procedural, Object-Oriented, and Functional Programming. It has
a comprehensive standard library and a vast ecosystem of third-party packages.
Its syntax promotes clean and concise code, contributing to increased productivity.
Features of Python
Easy to Learn and Use: Python’s simplicity and readability make it an ideal choice for beginners. It has a shallow learning curve,
allowing developers to quickly grasp the basics and start coding.
Expressive Language: Python allows developers to express concepts in fewer lines of code than other languages like C++ or Java.
Interpreted Language: Python is an interpreted language, which means that code can be executed directly without the need for
compilation.
Dynamic Typing: Python uses dynamic typing, allowing developers to create flexible and adaptable code.
Large Standard Library: Python comes with a comprehensive standard library that includes modules and packages for various
purposes, such as web development, data manipulation, networking, and more.
Community Support: Python has a large and active community of developers. This results in a wealth of resources, tutorials, and
third-party libraries that can be easily accessed, contributing to problem-solving and collaborative development.
Cross-Platform Compatibility: Python is platform-independent, meaning that Python code can run on various operating systems
without modification.
Object-Oriented Programming Python supports Object-Oriented programming, allowing developers to create and use classes and
objects, promoting modularity and code reuse.
Integration Capabilities: Python can be easily integrated with other languages like C and C++, enabling developers to use existing
code and libraries.
Databases: Python provides interfaces to many commercial and open-source databases, making it a suitable choice for database
applications.
Scalability: Python is scalable, making it applicable for small scripts as well as large projects.
Python Applications
Web applications We can use Python to develop web applications. It provides libraries to handle internet protocols such as
HTML and XML, JSON, Email processing, request, beautifulSoup, Feedparser, etc.
Desktop GUI Applications The GUI stands for Graphical User Interface, which provides a smooth interaction to any
application. Python provides a Tk GUI library to develop a user interface.
Software Development Python is useful for the software development process. It works as a support language and can be
used to build control and management, testing, etc.
Audio or Video-based Applications Python is flexible to perform multiple tasks and can be used to create multimedia
applications. Some multimedia applications which are made by using Python are TimPlayer, Cplay, etc.
Enterprise Applications Python can be used to create applications that can be used within an Enterprise or an Organization.
Some real-time applications are OpenERP, Tryton, etc.
Image Processing Application Python contains many libraries that are used to work with the image. The image can be
manipulated according to our requirements.
Character set is a set of valid characters that a language can recognise. A character represents any digit, alphabet and special
symbol. The character used in a Python source program belongs to unicode standard.
Python supports the following character set.
Alphabets – A to Z (uppercase), a to z (lowercase)
Digits – 0 to 9
Other Characters Python can process any of the ASCII and unicode characters as data or as literals
Identifiers
Keywords
Keywords are predefined reserved words by the programming language that have some special or predefined meanings. These are
reserved for special purpose and must not be used as identifier names. Some commonly used keywords in Python, which are listed
below:
Operators
Operators perform a specific task/computation when applied on variable or some other objects in an expression (known as
operands). Operators are used in programs to operate on data and variables.
There are two types of operators as follows:
Those operators that work on single operand to form an expression are known as unary operators.
Following are some unary operators:
(ii) Binary Operators
Operators that work upon two operands are known as binary operators.
There are various types of binary operators in Python as follows.
(a) Arithmetic operators These operators are used to do arithmetic operations. These operators are
(b) Logical operators These operators are used to make a decision on two conditions. Logical operators are typically used with
boolean values and what they return is also a boolean value. These operators are
(c) Relational operators Relational operators compare two operands to one another. These operators are
(d) Assignment operators Assignment operators are used to assign the value of an expression to a variable. These operators are
(e) Bitwise operators Bitwise operators work on bits and perform bit by bit operation. These operators are
(f) Shift operators These operators are used to shift value left or right. These operators are
Expressions
An expression is a combination of operators, constants and variables as per rule of the language. Any part in a program which can
have a value, is an expression. It will have operands and operators together to produce a value.
Statements
A statement is a logical instruction, which Python interpreter can read and execute. In Python, it could be an expression or
assignment statement. The assignment statement is fundamental to Python.
Comments
Comments are non-executable statements that are ignored by the interpreter or compiler and are not executed by the computer.
Comments are written to explain what each block of the program is doing.
There are two types of comments used in programs as follows
(a) Single line comment A single line comment starts with symbol.
e.g. Here is define the function of addition
(b) Multi-line comment A multi-line comment starts with a “‘symbol and ends with”.
e.g. x = 20 “Here we initialise the value of variable x as 20 “‘
Indentation
Indentation indicates the relationship between various statements and thus allow us to get a better picture of the overall organisation
and structure of the solution given in the program. It improves the readability of the program.
>>> a = 10
But to find the type of this variable, use the type () module Syntax
type (variable_name)
To find the type of above variable, we use
Input and Output in Python Class 10 Notes
Input/Output or I/O is the communication between information processing system (such as a computer) and the outside world,
possibly a human or another information processing system.
Inputs are the data received by the user, and outputs are the data sent to user. In almost every computer program, the user has to
input some data that will be stored in computer’s memory and then subsequently processed. And finally, there is need to output the
results of the computations. The output can be displayed on the computer screen.
Input Statement
Python has an input() function which lets you ask a user for some text input.
input( ) function first takes the input from the user and then evaluates the expression, which means Python automatically identifies
wifether user entered a string or number or list.
If the input provided is not correct, then either syntax error or exception is raised by Python.
Output Statement
To output your data to the screen, use the print () function. print() function gives output an entire (complete) line and then goes to
next line for subsequent output. To print more than one item on a single line, comma (.) may be used.
The numeric data type in Python represents the data that has a numeric value. A numeric value can be an integer, a floating
number, or even a complex number. Numeric data type is further classified into three categories.
Integers This value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals).
Float This value is represented by the float class. It is a real number with a floating-point representation. It is specified by a
decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific
notation.
Complex Numbers A complex number is represented by a complex class. It is specified as (real part) + (imaginary part)j. For
example -2+3 j
Dictionary
A dictionary is a key-value pair set arranged in any order. It stores a specific value for each key, like an associative array or a hash
table. Value is any Python object, while the key can hold any primitive data type.
The comma ( , ) and the curly braces are used to separate the items in the dictionary.
Boolean
Data type with one of the two built-in values, True or False is known as booléan data type. Boolean objects (True or False) are
denoted by the class bool.
Set
It is iterable, mutable(can change after creation), and has remarkable components. The elements of a set have no set order.
Sequence
The sequence data type is the ordered collection of similar or different Python data types. Sequences allow storing of multiple
values in an organised and efficient manner.
There are several sequence types in Python –
String : The sequence of characters in the quotation marks can be used to describe the string. A string can be defined using
single, double, or triple quotes.
List : Lists in Python can contain data of different types. Elements of lists are separated with comma (.) and enclosed inside
square bracket [].
Tuple : Tuples, like lists, also contain a collection of items from various data types. A parenthetical space () separates the
tuple’s components from one another.
Control Structure Class 10 Notes
A control structure is a programming language construct which affects the flow of the execution of program.
Various types of control structure are described below
Sequence Statements
Sequence statement refer to the instructions that are executed in the sequence in which they are written in the program. When a
program is run, the CPU begins execution, executes some number of statements and then terminates at the end.
For example
Output
A program which adds two integers
Enter first integer : 5
Enter second integer: 11
Sum is : 16
Selection Statements
These statements allow a program to execute a statement or a set of statements depending upon a given condition. These
statements are also called conditional statements or decision statements.
Python provides three types of selection statements are described below:
1. If statement
The if statement is the most simple decision-making statement. It is used to decide whether a certain statement or block of
statements will be executed or not.
Output
x is greater
2. if-else statement
This statement also tests a conditional expression. If the condition is true, the entire block of statements following the if block and it
will be executed.
Otherwise, the entire block of statements following the else block and it will be executed.
Output
we are in else part because x is not greater
3. if-elif-else statement
Sometimes, we need to execute different statement to perform in different conditions. It requires the evaluation of several
conditions.
First of all, the first condition is evaluated, if it is true then respective statements are processed. Otherwise, the next condition is
evaluated to process another say of statements. This process is continued for several times.
Expression is tested from the top towards the downside. As soon as the true condition is found, the associated set of statement is
executed.
x=55
Output
Divisible by 5
4. Nested if statement
Nested means if statement or if-else statements are placed in the statement block of if statement or else statement.
Output
result =15
The range( ) function is used to generate a sequence of numbers overtime. At its simplest, it accepts an integer and returns a range
object (a type of iterable).
Iterative Statements
Iterative statements or loops enable a program with a cyclic flow of logic. Each statement which is written under the scope of a
looping statement gets executed the number of times the iteration/looping continues for. There are two basic types of looping
statements available in Python, they are as follows.
1. while loop
A while loop tests for its ending condition before executing the statements enclosed in the loop body even the first time.
So, if the ending condition is met when the while loop beings, the lines of instructions its contains will never be carried out. This loop
is also known as Entry control loop.
A while loop continues iteration cycle till its loop condition is evaluated as true. If the loop-condition is false for the first time iteration,
then loop will not execute even once.
Output
Enter a natural number : 10
Sum is : 55
2. for loop
The for statement encloses one or more statements that form the body of the loop, the statements in the loop repeat continuously a
certain number of times.
This loop is also an entry control loop, as condition is checked before entering into the scope of the loop.
Output
A
B
A
B
A
B
A
B
NumPy It provides support for large, multi-dimensional arrays and matrices, along with mathematical functions to operate on
these arrays. Usage Data science, machine learning, scientific computing.
Pandas It offers data structures like DataFrame for efficient data cleaning, exploration, and analysis. Usage Data analysis,
data cleaning, data manipulation.
Matplotlib Comprehensive 2D plotting library. It allows the creation of static, animated, and interactive visualizations in Python.
Beautiful Soup Library for pulling data out of HTML and XML files. It provides Pythonic idioms for iterating, searching, and
modifying the parse tree. Usage Web scraping.
Django High-level web framework for building web applications quickly. It follows the model-view-controller (MVC) architectural
pattern. Usage Web development.
Flask Lightweight web framework. It simplifies web application development by providing tools and libraries needed.
NLTK (Natural Language ToolKit) Library for working with human language data. It provides easy-to-use interfaces for tasks
such as classification, tokenization, stemming, tagging, parsing, and more.
Usage Natural Language Processing (NLP), text mining.
OpenCV (Open Source Computer Vision) Library for computer vision and machine learning. It provides tools for image and
video analysis.
Usage Computer vision, image and video processing.
Glossary :
Jupyter Notebook It is a powerful tool widely used in the field of data science, research, and education Jupyter Notebooks
support various programming languages, but it is most commonly associated with Python.
Virtual Environment It is a self-contained directory that encapsulates a specific Python interpreter and its associated libraries.
Package It is a collection of Python modules organised in a directory hierarchy.
Keywords They are reserved words that have special meanings and cannot be used as identifiers.
Identifiers They are names used to identify variables, functions, classes, modules, or other objects in the code.
Conditional statement it allows you to control the flow of program based on certain conditions.
Loops They are used to repeatedly execute a block of code until a specified condition is met.