AI PAPER WILL BE OF 50 MARKS IN TERM EXAM
ITS ON MS FORMS ONLY.
26 MARKS FORM MCQ OR ONE MARKS
24 MARKS SUBJECTIVES
PYTHON
PROGRAMMING LANG.
SET OF COMMAND USED TO ACHIEVE SPECIFIC TASKS-
SOFTWARE/APP/GAME/WEBSITE/VIRUS
EG OF PROGRAMMING LANGUAGES –
VISUAL BASIC
C
C++
JAVA
PYTHON
WHY PYTHON –
1. IT IS OSS – OPEN SOURSE SOFTWARE – FREELY AVIALABLE ON NET
2. EASY TO LEARN – IT IS LIKE ENGLISH
3. EASY TO FIND ERRORS AND MAINTAIN.
[Link]
Extension of python file - .py
Print()- print function / method to display the output/message
Steps to writing a program:
1. Open thonny editor
2. Click on file menu and select new option.
3. Write the python code:
print(“HELLO student of 9b”)
4. Save the file with .py extension
5. Run / execute the program using f5.
Comments – used in programs for explain the code. (to increase
readability of the program)
no effect on output
2 type-
Single line – use #
Multiple line –
‘’’
-----
----
‘’’
Ques – write a program to display your details – name , address , mobile ,
email , dob in python.
# wap to display your details – name , address , mobile , email , dob in python.
Print ("NAME - NITIN GUPTA")
Print ("ADDRESS - Delhi")
Print ("MOBILE - 9212461461")
Print ("EMAIL - nitinguptamaps@[Link]")
Print ("DOB - 20.05.1980")
Ques – wap to add 20 and 40 in python.
a=20
b=40
c=a+b
print("sum is ",c)
here:
a, b, c - variables.
- to store values and this value can be changed during the program.
- Python does not have any command to declare a variable.
- It automatically created as soon as value is assigned.
Ques – wap to display a message RAM is a good boy. Store RAM in a variable r.
r = "RAM"
Print (r," is a good boy.")
we have store RAM in a variable r and it has to enclosed in " " because it is string.
Eg Var name value type
k1 = 3 k1 3 integer :numbers without decimal
m2k = 12.4 m2k 12.4 float : numbers with decimal
d = ”india” d india string : group of alphabets
ASSINING multiple value to different variable-
a,b=20,40 here a is 20 and b is 40
a=20
b=40
x = y = z = 100 100 is assigned to all the three var. x,y,z using single command.
X=100
Y=100
Z=100
Naming rule for naming the variable-
1. Must start with alphabet or underscore
A1 _s - valid
1a – invalid
2. Symbols and spaces are not allowed [Link] a#b cc@
3. Keywords not allowed.
(keyword – words having predefine meaning eg – print)
Print =3 --- invalid
#QUES – WAP TO OBTAIN 2 NUMBERS AND FIND THEIR SUM.
a=int(input("enter NUmber1 "))
b=int(input("enter Number2 "))
c=a+b
print("sum is ",c)
input()- to obtain values from the user.
# write a program to find out area(l*b) and perimeter(2*(l+b)) of rectanlge
l=int(input("enter length "))
b=int(input("enter breadth "))
ar=l*b
pr=2*(l+b)
print("area ",ar)
print("perimeter ",pr)
IPO cycle
I – INPUT
P – PROCESS
O – OUTPUT
# write a program to obtain marks of a student in his five subjects and then
display total marks and percentage.
m1=int(input("enter marks for subject1 "))
m2=int(input("enter marks for subject2 "))
m3 = int(input("enter marks for subject3 ")) input
m4=int(input("enter marks for subject4 "))
m5=int(input("enter marks for subject5 "))
s=m1+m2+m3+m4+m5 processs
pr= s/500*100
print("sum of marks ",s)
print("percentage is ",pr) output
base upon the above program answer the following questions :
1. How many variable are used in the program ?
7 (m1,m2,m3,m4,m5,a,pr)
2. Name the datatype used for obtaining marks.
Int type (for integers without decimal numbers)
3. Name the operators used in the program.
+ (addition) , / (division) , * (multiplication)
4. Name 2 inbuilt functions used in the program.
Print() , input()
# write a program to obtain radius of a circle and display its area and
circumference.
# write a program to calculate area of a triangle.
write a program to obtain a number from the user and then display its next 4
consecutive numbers
n=int(input("enter number 1 "))
c1=n+1
c2=n+2
c3=n+3
c4=n+4
print("next 4 consecutive number ",c1,c2,c3,c4)