Python program to print single and multiple variable

In Python 3.X, the print statement is written as print() function. Below code in Python 3.X that shows the process of printing values in Python.

Printing variables is a basic operation in Python programming that allows developers to display values and information in the console or terminal. Here's a simple Python program that demonstrates how to print single and multiple variables: 

 

# declare and initialize single variables
name = "John"
age = 25
salary = 45000.50

# print single variables
print("Name:", name)
print("Age:", age)
print("Salary:", salary)

# declare and initialize multiple variables
city, state, country = "New York", "New York", "USA"
zipcode, population = 10001, 8398748

# print multiple variables
print("City:", city, "State:", state, "Country:", country)
print("Zipcode:", zipcode, "Population:", population)

In this program, we first declare and initialize three single variables with different data types: a string, an integer, and a float. We then print each variable separately using the print() function, which concatenates the variable values with the specified text strings.

Next, we declare and initialize three multiple variables with string data types, separated by commas. We then print each variable separately using the print() function, again concatenating the variable values with the specified text strings.

Note that we can use the print() function to print both single and multiple variables, separating each variable with a comma. This allows us to display multiple values on a single line in the console.

Submit Your Programming Assignment Details