Print() Function | Python Language | Tutorial

 Learn | Practice|

Python Language

 

print() Function :

Print Function is use to print on the screen. It can be integer, string, Float, character etc 

Using quotes :

To print characters we use quotes.

 # double quotes
print("Hello World ") 
 # single quotes
print('Hello world')

 

We can use single quotes in double quotes or double quotes on single quotes but we cannot use single quotes in single quotes or double quotes in double quotes.


print("Hello 'Happy' World")

>>
Hello 'Happy' World
 print('Hello "Happy" World')

>>
Hello "Happy" World
 # syntax error 
 print("I am "coming" soon")

>>
syntax error 
# syntax error 
 print(' I'm Logicalprog')  

>>
syntax error 

Using variable :

First we have to declare variable and assign the value then print the value.

a=10
print(a)

>>a=10

Using User Input :

Taking input from the user , storing it into a variable and then printing it.

# as a string
a=input()
print(a)

>>logicalprog
a=logicalprog
# as a integer
a=int(input())
print(a)

>>123
a=123


---------------------------------------------------

Relate Links :

Download: Python

Install : python

---------------------------------------------------


Comments

Popular posts from this blog

Print name in a pattern | name as abbreviation | C-Program

Print Fibonacci Series using Recursion | C program :