Page 122 - Plus V4 with Adobe class 6
P. 122
Running a Python Program
Follow these steps to run a Python program:
1 Click on Run in 2
the Menu bar. Click on Run Module option.
The program will execute and the output will be shown in the Shell window.
Factbot
Interactive Mode is very useful for testing a code as it displays the errors one by one.
INPUT AND OUTPUT
Python provides two commonly used functions input() and print() for input and output.
The input() Function
The input() function takes the user’s input while a program executes. The general syntax of the input()
function is as follows:
input([<prompt>])
Here, prompt is the string or message we wish to display on the screen. Example:
name = input("Enter your name: ")
>>> Enter your name: "Mohan"
By default, Python considers the input as string even if you entered a number as input. You cannot
perform calculations on string. To perform calculations, you need to convert the string into integer or
floating-point value. To do so, Python provides following functions:
int(): It is used to change the input data value into integer. For example,
a = int(input("Enter a number "))
Now, the valid entered value is converted into integer value.
float(): It is used to change the input value into floating-point value. For example,
a = float(input("Enter a number "))
Now, the valid entered value is converted into floating-point value.
120 Plus (Ver. 4.0)-VI

