Home | | Problem Solving and Python Programming | Python Output Using print() function

Chapter: Problem Solving and Python Programming : Data, Expressions, Statements

Python Output Using print() function

The actual syntax of the print() function is print (“Statement”,variable name)

Python Output Using print() function

The actual syntax of the print() function is

 

print (“Statement”,variable name)

print (‘Statement’,variable name)

print (“Statement %formatting function”%variable_name)

 

After all values are printed, end is printed. It efaults into new line.

The file is the object where the v lues re printed and its default value is sys.stdout (screen)

Eg:

print ('This sentence is out ut to the screen')

# Output: This sentence is out ut to the screen

a = 5

print ('The value of a is', a)

# Output: The value of a is 5

 

Python Input

The syntax for input() is

 

input([prompt])

raw_input([prompt])

 

where prompt is the string we wish to display on the screen. It is optional.

Eg:

>>> num = input('Enter a number: ')

Enter a number: 10

>>>        num

'10'

>>>a=raw_input(‘Enter a number’)

10

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Problem Solving and Python Programming : Data, Expressions, Statements : Python Output Using print() function |

Related Topics

Problem Solving and Python Programming : Data, Expressions, Statements


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.