Printing Statements

Printing statements


Syntax:

print expression/constant/variable

Print evaluates the expression before printing it on the monitor. Print statement outputs an entire (complete) line and then goes to next line for subsequent output (s). To print more than one item on a single line, comma (,) may be used.

Example

>>> print “Hello”
Hello
>>> print 5.5
5.5
>>> print 4+6
10
Try this on the computer and evaluate the output generated
>>>print 3.14159* 7**2
>>>print “I”, “am” + “class XI”, “student”
>>>print “I‟m”,
>>>print “class XI student”
>>>print “I‟m “, 16, “years old”

Example

print (“string to be displayed as output ” )
print (variable )
print (“String to be displayed as output ”, variable)
print (“String1 ”, variable, “String 2”, variable, “String 3” ……)

Example

>>> print (“Welcome to Python Programming”)
Welcome to Python Programming
>>> x = 5
>>> y = 6
>>> z = x + y
>>> print (z)
11
>>> print (“The sum = ”, z)
The sum = 11
>>> print (“The sum of ”, x, “ and ”, y, “ is ”, z)
The sum of 5 and 6 is 11

The print ( ) evaluates the expression before printing it on the monitor. The print () displays an entire statement which is specified within print ( ). Comma ( , ) is used as a separator in print ( ) to print more than one item.

Qus. 1 : <p></p><p>What will be the output of the following Python code</p> <pre><span style="font-size: 12.6px;">def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(13, 17) func(a=2, c=4) func(5,7,9)</span></pre> <p><span style="font-size: 14px;">(A) a is 13 and b is 15 and c is 10</span></p><p><span style="font-size: 14px;">&nbsp; &nbsp; &nbsp;a is 2 and b is 5 and c is 4</span></p><p><span style="font-size: 14px;">&nbsp; &nbsp; &nbsp;a is 5 and b is 7 and c is 9</span></p><p><span style="font-size: 14px;">(B) a is 13 and b is 17 and cis 10</span></p><p><span style="font-size: 14px;">&nbsp; &nbsp; &nbsp;a is 2 and b is 4 and c is 4</span></p><p><span style="font-size: 14px;">&nbsp; &nbsp; &nbsp;a is 5 and b is 9 and c is 7</span></p><p><span style="font-size: 14px;">(C) a is 13 and b is 17 and c is 10</span></p><p><span style="font-size: 14px;">&nbsp; &nbsp; &nbsp; a is 2 and b is 5 and cis 4</span></p><p><span style="font-size: 14px;">&nbsp; &nbsp; &nbsp; a is 5 and b is 7 and c is 9</span></p><p><span style="font-size: 14px;">(D) None of the above</span></p>

  1. option A
  2. option B
  3. option C
  4. option D
Qus. 2 : function returns the current position of file pointer.

  1. get()
  2. seek()
  3. tell()
  4. cur()

Programs

python program to input a welcome message and print it

View Solution


python program to print number of seconds in year

View Solution


Python program to calculate GST Goods and Service Tax

View Solution


python program to find the ASCII Value of entered character

View Solution


python program that display a joke but display the punch line only when the user presses enter key

View Solution


python program to generate the following output 5 10 9

View Solution


python program to print 5@10@9

View Solution


CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad