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.

Find Us On Facebook

Computer Basics

More

C Programming

More

Java Tutorial

More

Data Structures

More

MS Office

More

Database Management

More
Top