The following Python program demonstrates the simplicity and readability of the language:
In this example, the print function is utilized to output the message enclosed in double quotation marks. This illustrates Python's straightforward syntax, where functions like print are used to perform actions such as displaying text.
Python Comments
Comments are the lines that are not executed by the Python interpreter. They are used to provide explanations or notes for the Programmer. Single- line comments start with the # symbol.
# This is a single - line comment print ("K2 is the second- highest mountain in the world " ) # This is a comment. print ("Edhi Foundation operates the world's largest volunteer ambulance network." )
Output:
K2 is the second- highest mountain in the world Edhi Foundation operates the world's largest volunteer ambulance network.
Interesting Information
We can use ".." (Triple Quotes) in python for multiline comments but actually they are multiline string literals which are ignored at runtime.
3.2.1 Variables in Python
A variable in programming functions as a storage container within a computer's memory. It allows the storage of data that can be retrieved later in the code. In the example below, the variable age is utilized to hold numerical data. The value of a variable can change throughout the execution of a program, which is why it is referred to as a "variable":
age = 71 print ( "Azam lived for", age, "years") age = 60 print ( " Iqbal lived for", age, "years")
# Output
# Azam lived for 71 years
# Iqbal lived for 60 years
This example illustrates how the variable "age" is assigned different values to represent the ages of Azam and Iqbal, which are then printed as part of the output.