MAILAM ENGINEERING COLLEGE
Mailam (Po), Villupuram (Dt). Pin: 604 304
(Approved by AICTE, New Delhi, Affiliated to Anna University, Chennai
& Accredited by TATA Consultancy Services)
Academic Year: 2022 – 2023
Bridge Course: Python Programming
Date : 11.08.2022 to 26.08.2022
Version 1.0
DATE: 11.08.2022
TOPIC: INTRODUCTION
DATE: 12.08.2022
TOPIC: MEANING FOR 𝑨 = 𝝅𝒓𝟐, ESPECIALLY 𝝅
DATE: 16.08.2022
TOPIC: BASIC OPERATIONS OF COMPUTER
Basic Operations of Computer System
1. Inputting
2. Processing
3. Outputting
4. Storing
5. Controlling
1. INPUTTING
What is Inputting?
Inputting
nputting is a process by which a user enters any type of data into a computer
system.
Example for Input device:
Keyboard
Mouse
Joy Stick
Light pen
Track Ball
Scanner
Graphic Tablet
2. PROCESSING
Processing is the second basic operations of a computer system. In simple language,
the processing means, when the computer system starts executing the instructions given by
the user, then this process is called processing.
3. OUTPUTTING
Outputting is the third basic operations of computer. In simple language, outputting
means, the result of instruction given by a user is called output. Whatever input is given by
the user computer, then the output result of that input is outputting.
Example for Output device:
Monitor
Printer
Headphones
Computer Speakers
Projector
4. STORING
Storing is the fourth basic operations of computer system. In simple language,
storing means, the output result that comes after executing the instruction given by a user,
and storing that output result is called storing.
The CPU is responsible for storing data in your computer's memory, which is where the data
is stored when you type it into a word document or open an image.
Hard Disk Drive ( HDD )
Floppy Disks
Tapes
Compact Discs (CDs)
DVD and Blu-ray Discs
USB Flash Drives
Secure Digital Cards (SD Card)s
Solid-State
State Drives (SSD)
RAM
ROM
5. CONTROLLING
Controlling is the fifth basic operations of computer. Controlling means the combinations of
all computer operations.
Controlling is a type of process that monitors the instruction given by the user from the time
it is executed to the output result. This process itself is called controlling.
In simple language, monitoring means monitoring, whi
which
ch device is doing its work or not.
DATE: 17.08.2022
TOPIC:
1) OPERATOR RANKING (OR) OPERATOR PRECEDENCE
2) ABOUT PRINT()
3)
1) OPERATOR RANKING (OR) OPERATOR PRECEDENCE
Example 1:
>>> 5+2*3
11
>>> (5+2)*3
21
2) About print() statement
Whatever the character mentioned within quotes is just displayed in screen as output
DATE: 18.08.2022 & 22.08.2022
TOPIC:
1) PRINT() CONTINUATION
2) ERRORS & LANGUAGE TRANSLATOR
1) print() continuation
2) Errors & Language Translator
ERROR
1. Compile time errors: It occur
occurs when you ask Python to run the application. Before the
program can be run, the source code must be compiled into the machine code. If the
conversion cannot perform,, Python will inform you that your application can not be run
before the error is fixed.
Example:
x = int(input('Enter a number: '))
if x%2 == 0
print('You have entered an even number.')
else:
print('You have entered an odd number.')
C:\Python34\Scripts>python
Scripts>python error.py
File "error.py", line 3
if x%2 == 0
^
SyntaxError: invalid syntax
2. Runtime errors: It occurs after the code has been compiled and the program is running.
The error of this type will cause your program to behave unexpe
unexpectedly
ctedly or even crash. An
example of an runtime error is the division by zero. Consider the following example:
x = float(input('Enter a number: '))
y = float(input('Enter a number: '))
z = x/y
print(x,'divided by',y,'equals: ',z)
The program above runs fine until the user enters 0 as the second number:
>>>
Enter a number: 9
Enter a number: 2
9.0 divided by 2.0 equals: 4.5
>>>
Enter a number: 11
Enter a number: 3
11.0 divided by 3.0 equals: 3.6666666666666665
>>>
Enter a number: 5
Enter a number: 0
Traceback (most recent call last):
File "C:/Python34/Scripts/error1.py", line 3, in <module>
z = x/y
ZeroDivisionError: float division by zero
>>>
LANGUAGE TRANSLATOR
Language Translator----> It is the process to convert "high level language"
to "machine level language"
Python into machine level language
Pyhton into Binary form (0's and 1's)
3 types of language Translator
*** Compiler---> C, C++, JAVA
*** Interpreter---> Python (Compiler and Interpreter)
*** Assembler---> Old format
1) COMPILER
It is a process to convert "HIGH LEVEL LANGUAGE" into "MACHINE LEVEL
LANGUAGE".
It converts the "whole program"(Example:100 lines) at a same time.
It is faster than Interpreter.
Example:
o C
o C++
o JAVA and etc.,
2) INTERPRETER
It is a process to convert "HIGH LEVEL LANGUAGE" into "MACHINE LEVEL
LANGUAGE".
It coverts "line by line".
It is slower than Compiler.
Example:
PYTHON
(In depth: Compiler and Interpreter)
DATE: 23.08.2022
TOPIC: VARIABLE, COMMENT, LITERAL
1) VARIABLE
It is the name of the memory location, the value can be change at the time of
program execution.
Example:
a=10
b=20
c=a+b
print('Answer is',c)
Here: a,b,c are variables.
2) COMMENT
Comments can be used to make the code more readable. It can be used to prevent
execution when testing code.
(or) Commented lines are not considered as a programming statement.
Types
o Single line comment
o Multi line comment
SINGLE LINE COMMENT
It is achieved by mentioning the symbol HASH (#)
Example 1:
a=10
b=20
c=a+b
print(c)
#a=10
#b=20
#c=a+b
#print(c)
Note: In the above example, the second segmentation (last 4 statements - # symbol in
prefix of every statements) can’t be treated as programming statement.
Example 2:
#ADDITION OF TWO NUMBERS
a=10
b=20
c=a+b
print(c)
Note:
#ADDITION OF TWO NUMBERS, this is for our reference, so hash symbol (#) is
placed in front of the statement.
MULTILIN COMMENT
It is achieved by using triple single quotes or triple double quotes at the beginning
and ending of every block of statements.
Example:
'''a=10
b=20
c=a+b
print(c)'''
3) LITERAL---> Constant (fixed values)
Example:
a=10 (Integer)
b=12.5 (floating)or (Real)
c='very good' (String)
DATE: 24.08.2022
TOPIC:
1) DATA TYPES
2) STRING
1) DATA TYPES (BASIC ONLY)
It deals about type of data.
Types:
Integer Data type
Keyword: int
Example: 123, 56, -987,13500
Floating Data type
Keyword: float
Example: 0.123, 12.56, -2.987,13500.23
String Data type
Keyword: str
Example: 'hello'
2) STRING
Sequence of character enclosed within quotes
Quotes:
1) SIngle quotes
2) Double quotes
3) Triple single quotes
4) Triple double quotes
Character:
It may be alphabets, digits or special symbols
Example:
Alphabets: a to z, A to Z
Digits: 0 to 9
Special character: !@#$%^&*()_+{}|":><?/.,;'
String Example:
'Hello'
"12398"
'No:123/A, Dr. A.P.J Nagar"
" "
Interview Question:
1) What is the default data type of input in PYTHON.
Answer: String
PROGRAM EXECUTION
Program 1
a=10
b=20
c=a+b
print(c)
Output
30
Program 2
a=input()
b=input()
c=a+b
print(c)
Output
10
20
1020
Program 3
a=input()
b=input()
c=int(a)+int(b)
print(c)
Output
10
20
30
Program 4
print('Enter first number')
a=input()
print('Enter second number')
b=input()
c=int(a)+int(b)
print('Addition = ',c)
Output
Enter first number
20
Enter second number
30
Addition = 50
Program 5
a=input('Enter first number:')
b=input('Enter second number:')
c=int(a)+int(b)
print('Addition = ',c)
Output
Enter first number:20
Enter second number:30
Addition = 50
Program 6
a=int(input('Enter first number:'))
b=int(input('Enter second number:'))
c=a+b
print('Addition = ',c)
Output
Enter first number:20
Enter second number:30
Addition = 50
Program 7
a=int(input('Enter first number:'))
b=int(input('Enter second number:'))
print('Addition = ',a+b)
Output
Enter first number:20
Enter second number:30
Addition = 50
Program 8
c=int(input('Enter first number:'))+int(input('Enter second number:'))
print('Addition = ',c)
Output
Enter first number:20
Enter second number:30
Addition = 50
Program 9
print('Addition = ',int(input('Enter first number:'))+int(input('Enter second
number:')))
Output
Enter first number:20
Enter second number:30
Addition = 50
DATE: 25.08.2022
TOPIC: INPUT() WITH FLOAT DATA TYPE
Program 1:
a=int(input('Enter first number:'))
b=int(input('Enter second number:'))
print('Addition = ',a+b)
Error:
Enter first number:10.2
Traceback (most recent call last):
File "C:\Users\Satff\Desktop\Bridge Course 2022-23\25.08.2022\A Input.py", line 2,
in <module>
a=int(input('Enter first number:'))
ValueError: invalid literal for int() with base 10: '10.2'
Program 2:
a=float(input('Enter first number:'))
b=float(input('Enter second number:'))
print('Addition = ',a+b)
Output:
Enter first number:12.3
Enter second number:12.569
Addition = 24.869
Program 3:
a=float(input('Enter first number:'))
b=float(input('Enter second number:'))
print('Addition = ',a+b,'Subration=',a-b)
Output:
Enter first number:12.56
Enter second number:23.689
Addition = 36.249 Subration= -11.129
Program 4:
a=float(input('Enter first number:'))
b=float(input('Enter second number:'))
print('Addition = ',a+b,'\nSubtracion=',a-b,'\nMultiplication=',a*b)
Output:
Enter first number:12.536
Enter second number:1.2356
Addition = 13.7716
Subtracion= 11.3004
Multiplication= 15.4894816
Program 5:
a=5
b=2.1
c=2
d=a+a*b-(a-c)
print(d)
Output:
12.5
Program 6:
#Area of Circle
r=float(input('Enter Radius='))
area=3.14*r*r
print('Area=',area)
Output:
Enter Radius=23.65
Area= 1756.2726499999999
Program 7:
r=float(input('Enter Radius='))
area1=3.14*r*r
area2=(22/7)*r*r
print('Area1=',area1)
print('Area2=',area2)
Output:
Enter Radius=2.56
Area1= 20.578304000000003
Area2= 20.597028571428574
Program 8:
r=float(input('Enter Radius='))
area1=3.14*r*r
area2=( 3.142857142857143)*r*r
print('Area1=',area1)
print('Area2=',area2)
Output:
Enter Radius=2.56
Area1= 20.578304000000003
Area2= 20.597028571428574
DATE: 26.08.2022
TOPIC:
1) FLOW OF EXECUTION
2) LARGEST OF 2 NUMBERS
1) FLOW OF EXECUTION
3 Types
1) Sequence
2) Selection
3) Iteration
1) Sequence
All the Python statements are should be executed.
Example:
# Addition of Two numbers
a=int(input('Enter first number:'))
b=int(input('Enter second number:'))
c=a+b
print('Addition=',c)
2) Selection
Some of the Python statements are ignore at the time of execution.
Example:
#Largest of Two numbers
a=int(input('Enter first number:'))
b=int(input('Enter second number:'))
if a>b:
print('First number is largest')
else:
print('Second number is largest')
2) LARGEST OF TWO NUMBERS
a=int(input('Enter first number:'))
b=int(input('Enter second number:'))
if a>b:
print('First number is largest')
print('Condition is True')
else:
print('Second number is largest')
print('Condition is False')
print('The End')
Output 1:
Enter first number:52
Enter second number:47
First number is largest
Condition is True
Output 2:
Enter first number:52
Enter second number:147
Second number is largest
Condition is False