Hi, I’m Ausaf Abdullah! I’m a passionate 16-year-old developer with a keen interest in creating innovative software solutions. I love exploring new technologies and continuously improving my coding skills. Whether it's web development, mobile apps, or just diving into the latest programming languages(Python), I am always eager to learn and take on new challenges!
Introduction
(3)
The print() function displays the values given to it. Values enclosed in double quotes are treated as text (called strings). When you use the + operator with strings, it joins them together (concatenates them) instead of performing mathematical addition.
Numbers without quotes are treated as numerical values. You can perform mathematical operations like addition, subtraction, etc., on them.
For example:
print (100+ 200) # Output: 300 (addition) print("A" + "B") # Output: AB (concatenation)
(4)
In Python, the print() function can display both strings and integers. When you want to add or concatenate objects together, it's crucial to
ensure they are of the same type.
For example, adding two numbers:
print (200+ 300)
This will simply sum the two numbers and display:
500
When you concatenate two strings:
print("200" + "300")
Python combines the two strings into a single string, displaying:
200300
However, if you try to mix a string and an integer directly, like this:
print("200" + 300)
Python will raise a TypeError because it cannot concatenate a string and an integer directly without explicit conversion.
This is the app link to Download
Comments
Post a Comment