Which of the following is /are correct ways of creating
strings.
a. name= Jiya b. name= 'Jiya'c. name= "Jiya" d.
name =(Jiya)
Answers
no a because it is no need of , " or ( ) we write the name Jiya
name = 'Jiya' and name = "Jiya" is/are correct ways of creating
strings.
b. name = 'Jiya'
c. name = "Jiya"
Explanation
Alphabets, words, or other characters when enclosed between single quotation marks (' ') or double quotation marks (" ") are called strings.
name = 'Jiya'
print(name)
Output
Jiya
name = "Jiya"
print(name)
Output
Jiya
Extra Information
In this print statement
print('10'+'20')
10 and 20 are separately enclosed between single quotation marks which means they are two strings and the plus (+) sign between them is used to concatenate or join both strings.
If you wanted the addition of both numbers i.e. 10 and 20 then the print statement would have been
print(10 + 20)
The output would have been 30.
print() function will print the output to the console.
Examples of print() statement
print("Hello World")
Output
Hello World
print(5/2)
Output
2.5
x = ("apple", "banana", "cherry")
print(x)
Output
('apple', 'banana', 'cherry')
Python is created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.