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

Introduction of Python - 080915

Python is a high-level, easy-to-learn programming language developed by Guido Van Rossum in 1991. It features platform independence, extensive library support, and is free and open-source. The document covers Python's modes, keywords, variable declaration rules, data types, input/output functions, and various operators, along with example programs demonstrating basic operations.

Uploaded by

capileaks123
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)
7 views4 pages

Introduction of Python - 080915

Python is a high-level, easy-to-learn programming language developed by Guido Van Rossum in 1991. It features platform independence, extensive library support, and is free and open-source. The document covers Python's modes, keywords, variable declaration rules, data types, input/output functions, and various operators, along with example programs demonstrating basic operations.

Uploaded by

capileaks123
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/ 4

Python Notes(Class 7)

Python is one of the most popular programming languages used by people world over.It is a high-level computer
programming language .This programming language enables you to create interesting programs that can be used to do
things faster and better.This is similar to English language.

Guido Van Rossum developed python in 1991 at the national Research Institute for mathematics and
computer science in Netherlands.
Python 3.0 was released on 3rd December 2008.
FEATURES OF PYTHON
1.EASY TO LEARN: It is easy to learn programming language,since it has fewer keywords and uses simple
English words.
2.Plateform Independent:The programs written in python can run on different hardware and software
plateforms.Program written in LINUX operating System can be executed in on a machine with different
operating System.
3.FREE AND OPEN SOURCE: Which means it can download without paying.
4.HIGH LEVEL LANGUAGE:An English like language.
5.INTERPRETED LANGUAGE:Programs written in python are executed by an interpreter(lne by line).
6.EXTENSIVE LIBRARY SUPPORT:Python has an extensive inbuilt library which is openlyavailable for every
user.It helps saving your time and efforts.
USES:It can be used to built website,program a robot,develop Artifificial intelligence Application,create virtual
games,perform scientific computation etc.s
Modes in python
IDLE stands for integrated Development Environment. Python interpreter offers the two basic modes to enter
command. Interactive mode & script mode.
1.Interactive mode: In this mode, commands are executed line by line. In this mode codes are typed directly
in the shell window and ouput is also displayed in this window.
2.Script mode: It is used for long program that contain multiple python statements.In this mode , you can
store statements in file in order to use them later.
Keywords:It refers to the reserved words that have specific/predefined meaning to the python interpreter.
Variables:It is a place to store values in computer memories . A variable can hold a single value.
Rules to declare a variable Name
* A variable name must be begin with a letter(uppercase or lowercase) or an underscore.
* Apart from underscore,a variable name can not contain any other symbols,such as comma(,),equal
to(=).hyphen(-),question mark(?), and so on.
*A variable can not have any space.
* A variable name can be arbitrarily long.
* Keyword can not be used as variable names.
* Python is a case-sensetive programming language.
Data Types: integer,string,float,list,Boolean,tuple,dictionary and none. We will study only about integer and
string.
Number:This data type store numeric values.
int: int or integer stores positive or negative numeric values.Integer represents integral numbers,which are
the numbers without decimal point.e.g. x=89,y=-25
float: float or floating point number could be a positive or a negative numeric values with a decimal point
e.g x=6.6,y=8.6
String:String data type refers to set of characters,which are enclosed within single code(‘ ‘) or a double
quotes(“ “)
INPUT () FUNCTION: In a python program, the input () function is used to take a value(input) from the user
And assign it to a variable.
To accept numeric values:
To input integer and float values, you can use int() and float() along with input() function,respectively.
age=int(input(“enter age”))------------------used to take integer value from the user
percentage=float(input(“enter percentage”))---------------used to take float value from the user
To accept text values:
a=input(“enter your hobby”)
PRINT () FUNCTION
EXAM.print(“PYTHON IS AN INTRESTING PROGRAMMING LANGUAGE”)
Print(A,B,C)
Print(A,”\t”,B,”\t”,c)------t used for tab space
Using new line character(\n):print(A,”\n”,B,”\n”,C)
OPERATORS: Are special symbols that are used to perform arithmetic and logical operations on variables and
values, and provide a meaningful result.
Types Of Operators:
Arithmetic Operators: Are used to perform basic mathematical calculations.
Exam: + addition
- Subtraction
* Multiplication
/ division exam 5/2 result 2.5
// division exam 5//2 result 2
% modulas exam 5%2 result 1
** exponential exam 5**2 result 25
Binary operators
Exam 5+2
Unary operators exam +2
String Operators: Only two types of operators used in string such as ‘+’ (addition) and ‘*’(multiplication).
‘+’ operator is used for concatenation(combining) two string
‘*’ is used to reprint or replicate the string values a number of times.so, it is known as replication operator.
Relational Operators: ==(equal to),!=(Not equal to),>(greater than),<(less than),>=(greater than equal to)
<=(less than or equal to)
PROGRAMS
1.Addition of 2 numbers By initialisation
x = 5
y = 10
print(x + y)

2.Addition of 2 numbers By input() function


x = input("Type a number: ")
y = input("Type another number: ")
sum = int(x) + int(y)
print("The sum is: ", sum)
3.To print the average of 5 values
a = int(input ('Enter a'))
b = int(input ('Enter b'))
c = int(input ('Enter c'))
d = int(input ('Enter d'))
e = int(input ('Enter e'))
avg = (a+b+c+d+e)/5
print ('average =', avg)
4.Example: Check If number is even or odd
This program takes the input from user and checks whether the entered number is even or odd. We are receiving the value into
a variable num and then we are dividing the num by 2 to see whether it is an even number or odd number.

num = int(input("Enter any number: "))


flag = num%2
if flag == 0:
print(num, "is an even number")
elif flag == 1:
print(num, "is an odd number")
else:
print("Error, Invalid input")
5. This Python program checks if the number(entered by user) is positive, negative or zero.

# User enters the number


number = int(input("Enter number: "))

# checking the number


if number < 0: print("The entered number is negative.") elif number > 0:
print("The entered number is positive.")
elif number == 0:
print("Number is zero.")
else:
print("The input is not a number")
6. # Python program to perform Addition Subtraction Multiplication
# and Division of two numbers
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
print("Enter which operation would you like to perform?")
ch = input("Enter any of these char for specific operation +,-,*,/: ")
result = 0
if ch == '+':
result = num1 + num2
elif ch == '-':
result = num1 - num2
elif ch == '*':
result = num1 * num2
elif ch == '/':
result = num1 / num2
else:
print("Input character is not recognized!")

print(num1, ch , num2, ":", result)

You might also like