Page 127 - TP_Plus_v4_Class6
P. 127
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. Hintbot
Shortcut to run a
Python program:
Press F5 key
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 value entered 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 value entered is converted into floating-point value.
#Python 125

