لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Lesson 7: Strings in Python Coding

Strings in python are surrounded by either single quotation marks, or double quotation marks.

You can display a string literal with the print() function.

Strings are sequences of characters. Your name can be considered a string.

Or, say you live in Uk, then your country name is "Uk", which is a string.

Python Code For Strings

Code

a = "Hello"

print(a)

About This Code

Assigning a string to a variable is done with the variable name followed by an equal sign in the string.

Example.

a = "Hello"

print(a)

the output will be

Hello

You can type/copy paste the above code in any online compiler or editor or you can even practice to write the code by hand.

.

A string is considered to be true in Python if it is not an empty string. So, we get the following.

Code to Test truth value of empty string.

Code

print(bool(""))

the output will be

False

Explanation

In the line above we are getting an output as False because the string is empty.

Code to Test truth value of non-empty string "x"

Code

print(bool("x"))

the output will be

True

Explanation.

In the line above we are getting an output as True because the string is non-empty.