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

Python-11 March 25

This document provides an introduction to Python programming for Grade 7, covering its history, features, and applications. It includes basic concepts such as data types, conditional statements, and problem-solving examples in Python. Additionally, it offers exercises and practice work to reinforce learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python-11 March 25

This document provides an introduction to Python programming for Grade 7, covering its history, features, and applications. It includes basic concepts such as data types, conditional statements, and problem-solving examples in Python. Additionally, it offers exercises and practice work to reinforce learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Python Basics

Grade 7
INTRODUCTION
What is Python? History
▪ Invented by Guido Van
Python is interpreted, object-
Rossum in 1989
oriented, high level programming
▪ First Released at 20
language with dynamic semantics.
February,1991

Feature: Application:
▪ Easy ▪ Build a website & develop game
▪ Portable ▪ Implement machine learning
▪ GUI Supports ▪ Robotics & AI
▪ Free & Open Source ▪ Real Example: Intel, IBM,NASA,
▪ Large Python Library Netflix, Facebook
BACKGROUND
Step
1 Varia
Step ble 101111
2 If 101100
Step For .
Problem 3 Print .
Solve
. . .
. .
.

Algorithm Flowchart Code to machine language


Environment
Data Types

Pseudo Code Python


STRING, CHAR str
INTEGER int
REAL float
Conditional Statement
Example: Take a input number & find out the number is even or odd.

INPUT Taking from user Input taking from user in


Python
DECLARE num: INTEGER num =int(input("Enter your
INPUT num number: "))

Condition Condition in Python


IF MOD(num,2)=0 THEN if num%2==0:
OUTPUT "even" print ("even")
ELSE Else:
OUTPUT "odd" print ("odd")
ENDIF
Exercises:
Q1. Print “Hello world!”
Ans: print (“Hello World”)

Q2. Take two input from user & do addition.

Q3. Find out the largest number among 3 numbers.


Problem Solving (Q3)
Pseudo Code Python
DECLARE num1, num2, num3: REAL
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
INPUT num1,num2,num3
num3 = float(input("Enter third number: "))
IF num1> num2 AND num1>num3
if (num1 >= num2) and (num1 >= num3):
THEN
largest = num1
OUTPUT " num1 is largest"
elif (num2 >= num1) and (num2 >= num3):
ELSE
largest = num2
IF num2> num1 AND num2>num3
else:
THEN
largest = num3
OUTPUT "num2 is largest"
ELSE
print("The largest number is", largest)
OUTPUT "num3 is largest"
END IF
ENDIF
Practice Work:
4. Write a Python code that input amount in ATM Machine & print ‘accept’ if
amount is multiple of 500. Otherwise print ‘not accepted’.

5. Write a python code that input a character & print input character is vowel or not vowel.
Q5 Solution

ch = input("Enter a character: ")

if(ch=='A' or ch=='a' or ch=='E' or ch =='e' or ch=='I' or


ch=='i' or ch=='O' or ch=='o' or ch=='U' or ch=='u’):
hhprint(ch, "is a Vowel")
else:
hh print(ch, "is a Consonant")
THANK YOU

You might also like