Python – Strings,Assign String to a Variable,Multiline Strings

Python – Strings,Assign String to a Variable,Multiline Strings

To Enter a string in python Print function is used . Strings can be created by entering text between single quotation mark or double quotation mark.

string is a sequence of characters that are not numeric.

String using Single or double quote

For Example

class="auth">#Author : Paras Guglani
#Website : Passionategeekz.com
#created : 27/06/2019 13:42pm

print ("hello world")
print ('hello world')

hello world
hello world
[Finished in 0.3s]

Note : Both the Result would be same either in single quote or double quote

 

Assign Variable  To String

You can also Assign a Variable to string . Enter name of variable followed by equal sign and the single or double quote string

class="auth">
#Author : Paras Guglani
#Website : Passionategeekz.com
#created : 27/06/2019 13:42pm

a= 'hello\n'
b= "world"
print (a+b)

hello
world
[Finished in 0.3s]

MultiLine Strings

In Python we can also use a multi line string using three double quotes “””your string”””

#Author : Paras Guglani
#Website : Passionategeekz.com
#created : 27/06/2019 13:42pm

a= """hello this is
my first python program using a
multi line strings"""
print (a)

hello this is
my first python program using a
multi line strings
[Finished in 0.3s]

Hits: 56

CATEGORIES
TAGS
Share This

COMMENTS

Wordpress (0)
Disqus ( )
%d bloggers like this: