Sunteți pe pagina 1din 6

PRACTICAL NO.

AIM: Installation of Python Idle and Introduction to Interactive Shell with Mathematical
Operations.
THEORY: IDLE is the standard Python development environment. Its name is an acronym of
"Integrated Development Environment". It works well on both Unix and Windows platforms.
It has a Python shell window, which gives you access to the Python interactive mode. It also has
a file editor that lets you create and edit existing Python source files.
INSTALLATION OF PYTHON IDLE

1. Browse to http://www.python.org/download. The following pop-up window titled Opening


python-3.74-amd64.exe will appear.

2. Click on the Download Windows x86-64 executable installer link under the top-left Stable


Releases.

The following pop-up window titled Opening python-3.74-amd64.exe will appear.


Click the Save File button.

The file named python-3.7.4-amd64.exe should start downloading into your standard download


folder.

3. Double-click the icon labeling the file python-3.7.4-amd64.exe.

A Python 3.7.4 (64-bit) Setup pop-up window will appear. The following page will appear in
your browser.

4. Highlight the Install Now (or Upgrade Now) message, and then click it. ...

5. Click the Yes button.

A new Python 3.7.4 (64-bit) Setup pop-up window will appear with a Setup Progress message
and a progress bar.
6. Click the Yes button. ...

7. Click the Close button.

HOW TO OPEN PYTHON IDLE?

To start IDLE on Windows click the Start Menu and search “IDLE” or “idle”. Click IDLE as
shows in the figure and you will see a window which looks something like this: This is
again Python Shell, just type the commands, hit enter and it will display the result.

Interactive Python shell

When you start up IDLE, a window with an interactive Python shell will pop up:
You can type Python code directly into this shell, at the '>>>' prompt. Whenever you enter a
complete code fragment, it will be executed. For instance, typing:

>>> print "hello world"  
and pressing ENTER, will cause the following to be displayed:

hello world
IDLE can also be used as a calculator:

>>> 4+4
8
 
>>> 8**3
512
Addition (+), subtraction (-), multiplication (*), division (/), modulo (%) and power (**)
operators are built into the Python language. This means you can use them right away. If you
want to use a square root in your calculation, you can either raise something to the power of 0.5
or you can import the math module. Below are two examples of square root calculation:

>>> 16**0.5  
4.0
>>> import math
>>>
math.sqrt(16)
4.0
The math module allows you to do a number of useful operations:

>>> math.log(16,
2)
4.0  
>>> math.cos( 0 )
1.0

PROGRAM TO PERFORM BASIC ARITHEMATIC OPERATIONS


num1 = int(input('Enter First number: '))
num2 = int(input('Enter Second number '))
add = num1 + num2
dif = num1 - num2
mul = num1 * num2
div = num1 / num2
floor_div = num1 // num2
power = num1 ** num2
modulus = num1 % num2
print('Sum of ',num1 ,'and' ,num2 ,'is :',add)
print('Difference of ',num1 ,'and' ,num2 ,'is :',dif)
print('Product of' ,num1 ,'and' ,num2 ,'is :',mul)
print('Division of ',num1 ,'and' ,num2 ,'is :',div)
print('Floor Division of ',num1 ,'and' ,num2 ,'is :',floor_div)
print('Exponent of ',num1 ,'and' ,num2 ,'is :',power)
print('Modulus of ',num1 ,'and' ,num2 ,'is :',modulus)

Output:
Enter First number: 10
Enter Second number 3
Sum of 10 and 3 is : 13
Difference of 10 and 3 is : 7
Product of 10 and 3 is : 30
Division of 10 and 3 is : 3.3333333333333335
Floor Division of 10 and 3 is : 3
Exponent of 10 and 3 is : 1000
Modulus of 10 and 3 is : 1

Conclusion: Hence Installation of Python Idle and Introduction to Interactive Shell with
Mathematical Operations has been executed successfully.

S-ar putea să vă placă și