Professional Documents
Culture Documents
PYTHON For Class9
PYTHON For Class9
PYTHON For Class9
PYTHON
PROGRAMMING LANG.
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.
THONNY.ORG
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 – 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.
x = y = z = 100 100 is assigned to all the three var. x,y,z using single command.
X=100
Y=100
Z=100
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
# 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)