Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

Python Print Function, Input and Output In Python 1

 

In this lecture we will see that,

How print() function works ?

How to read data from keyword ?

 

Printing on screen

 

"print()" is use to print on screen.

 

print(value, ..., sep=' ', end='\n', file=sys.stdout)

Prints the values to a stream, or to sys.stdout by default.

 

Optional keyword arguments :

sep : string inserted between values, default a space.

end : string append after the last, default a newline.

file : a file-like object (stream); defaults to the current sys.stdout.

 

For this we will create a new file and name project as 'file.py' and then we will make a source folder in which we will save all our modules.

 

Example :

print("In print function","second value")

O/P :

In print function second value

 

Example :

from macpath import sep

import sys

print("In print function","second value",sep=' ', end=' ',file=sys.stdout)

print('third value')

O/P :

In print function second value third value

 

Reading from keyboard

 

To read data from keyboard "input()" is use.

 

The input of the user will be returned as a string without any changes.

 

If this raw input has to be transformed into another data type needed by the algorithm, we can use either a casting function or the eval function.

 

Example :

intValue=input('Enter Value')

intValue=int(intValue)

print(type(intValue))

finalValue=eval('intValue+10')

print(finalValue)

 

 

FAQs

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere