Friday 10 February 2023

Input and Output in Python

 Input and Output in Python

Input

Input is supplied to the program to do certain operations. Every program may or may not take input from the user.

Taking input from the user

#Takes the input from the user through input function
user_input=input('Please enter input ')
#Printing the input to the console
print(user_input)




Taking integer input from user

#For taking integer input we need to cast string to integer
user_ip=int(input('Enter an integer '))
print('The integer entered is:',user_ip)


By default the input is taken in the form of a string. If we need to convert it we can convert from string to integer we can do it by using the type casting function int().

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top