Hello,
In any programing language like python, c to write a string we should keep the string inside the double quotes and to perform mathematical operation we do not using double quotes
if we write the mathematical operation in double quotes the system will consider it as a string
This is very genuine question and here is the answer of that question.
In python whenever we are printing the strings then it is mandatory to use double quotes inside the brackets.
But Whenever there are some mathemtical calculations then the python upto some extend can understand and can perform the calculations directly.
This is because, in Python anything written inside double quotes (" ") represent a string and printed as it is at the output .As (âHello Worldâ) is a string , it must be enclosed inside quotes for printing.
While, in order to add two numbers, no need to add quotes, because we are performing a mathematical operation on numeric values rather than a stringâŚ
HEY, The use of quotes inside parentheses depends on the context of the operation being performed. In programming, quotes are used to denote string literals. When displaying text (like âHello, World!â) or working with textual data, quotes are used to indicate strings. However, when performing mathematical operations, quotes are not used, as the numbers are treated as numeric values, not strings.
For example:
-
âHello, World!â Example:
- Quotes are used inside parentheses to indicate a string literal.
print("Hello, World!")
-
Adding Two Numbers Example:
- Quotes are not used inside parentheses when adding two numeric values.
result = 2 + 3
In the first example, quotes indicate a string, and in the second example, the operation involves numeric values, so quotes are not used inside parentheses. The choice of using quotes or not depends on the data type and the specific operation being performed in the code.
The syntax is the set of rules that defines how a Python program will be written and interpreted.
For example
If 5>2
print(âfive is greater than twoâ)
Here it will print syntax error, why because we have to use colon after conditional statements.so we have to write
If 5>2:
print(âfive is greater than twoâ)