0% found this document useful (0 votes)
22 views4 pages

Basic of Python Class VIII

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
22 views4 pages

Basic of Python Class VIII

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

Basic of Python

Languages of Computer:

1) Machine Language: It consist of binary digits in form of 0 and1


2) Assembly Language: it contains mnemonics
3) High level Language (HLL): It is a programming language that is designed to make
it easier for humans to understand and write.

Translator:
1) Assembler: It converts assembly language programs into machine language.
2) Compiler: It convert HLL program into machine language in one go
3) Interpreter: It convert HLL program into machine language line by line

Python: Python is a high level, object oriented, easy to learn language developed by Guido
Van Rossum in 1991.

Features of python:
1. Interpreted language: it converts Source code of high level language into machine code line
by line so it is called interpreted language.
2. Open source software and free
3. Platform independent language: It works on multiple platforms such as Linux, UNIX and
Windows
4. Easy to learn and use
5. Graphical user interface
6. Large Standard Library
Uses of python:
1. Used to web and internet application development
2. Scientific and Numeric calculation
3. Game Development
4. General Purpose software Development

Python works on two different modes:


a) Shell Mode: we can type one command at a time.
b) Script Mode: We can save multiple command with .py extension (F5 is the shortcut
key to run a python file
Tokens: The smallest individual unit in a program is called as Tokens
● Keywords :
● Identifiers(Name)
● Literals
● Operators
● Punctuators
Keywords: Python has some reserved words. These reserved words may not be
used as constant or variable or any other identifier names. Eg : input(), int , float, if, else
Identifier: An identifier is a name used to identify a variable, function, class,
module or other object.
Variable: variable is assigned a value; the variable can be used to access and
manipulate that value throughout a program.

Rules to define Variable :

● An identifier starts with a letter A to Z or a to z or an underscore ( _ )

● Python does not allow punctuation characters such as @, & and % within
identifiers.

● Keyword can never be identifier

● Python is a case sensitive programming language.

Literals/Constants: Literals are data items that have a fixed value.

Python allows several kinds of literals as

● String literals
● Numeric literals
● Boolean literals
● special literal
● None

Operator: Operators are special symbols which perform some computation. Operators and
operands form an expression.

Python operators can be classified as given below:


● Arithmetic operators (+,-,*,/,**,%)
● Relational operators (<,>,<=,>=,==,!=)
● Logical operators(And,or,not)
● Assignment operators
● Bitwise operators Identity operators

Data Types: Data type is a set of values and the allowable operations on those values.

Python has a great set of useful data types. Python’s data types are built in the core of the
language.eg integer, string, float, Boolean.

Punctuator: These are symbols that are used in a programming language to organize
programming sentence structures

Case Sensitive Programming: Case sensitivity describes a programming language's (C, C++,
Java, C#, Verilog, Ruby, Python and Swift) ability to distinguish between upper and lower case
versions of a letter.

Comment in Python:Comments are used to explain code, make it more readable, or to


temporarily disable a piece of code. Comments are ignored by the Python interpreter during
execution. There are two types of comments in Python: single-line comments (#) and multi-
line comments(‘’’.................................................’’’’)

Program Based on Python:

1. WAP to print total marks of 5 subjects

Eng=int(input("Enter the marks of English:"))

Hindi=int(input("Enter the marks of Hindi:"))

Math=int(input("Enter the marks of Maths:"))

Sc=int(input("Enter the marks of Science:"))

sst=int(input("Enter the marks of Social Studies:"))

total=Eng+Hindi+Math+Sc+sst

print("The total is",total)


2. WAP to program to calculate area of triangle

b=int(input("Enter the value of base:"))

h=int(input("Enter the value of Height:"))

area =0.5*b*h

print("The area is ",area)

3. WAP to program to calculate area of rectangle

l=int(input("Enter the value of len:"))

b=int(input("Enter the value of bre:"))

area =0.5*b*l

print("The area is ",area)

You might also like