Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Get Variable Name As String In Python
Next article icon

Print Single and Multiple variable in Python

Last Updated : 16 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In Python, printing single and multiple variables refers to displaying the values stored in one or more variables using the print() function.

Let’s look at ways how we can print variables in Python:

Printing a Single Variable in Python

The simplest form of output is displaying the value of a single variable using the print() function.

Example:

Python
x = 42  print(x) 

Output
42 

Explanation: x stores the value 42, and print(x) displays it on the console.

Printing Multiple Variables

Python allows printing multiple variables in various ways. Let’s explore three common techniques:

1. Using Commas (default way)

Python
a = 10 b = 20 c = 30  print(a, b, c) 

Output
10 20 30 

Explanation: When variables are separated by commas, Python prints them with a space between each.

2. Using f-strings (formatted string literals)

Python
name = "Prajjwal" age = 23  print(f"My name is {name} and I am {age} years old.") 

Output
My name is Prajjwal and I am 23 years old. 

Explanation:

  • f-strings are prefixed with the letter f before the opening quote.
  • Inside the string, curly braces {} act as placeholders for variables or expressions.
  • Python automatically replaces each {} with the value of the corresponding variable.

Note: f-strings is compatible with latest Python versions (Python 3.6+).

3. Using .format() Method

Python
lang = "Python" ver = 3  print("You are learning {} version {}.".format(lang, ver)) 

Output
You are learning Python version 3. 

Explanation:

  • In the string, the curly braces {} act as placeholders.
  • .format() method replaces the {} in the string in order with the values passed to it.

Note: .format() is compatible with older Python versions and still widely used in legacy code.

Also read: f-strings, print().



Next Article
Get Variable Name As String In Python

A

Arpit Agarwal
Improve
Article Tags :
  • Python
Practice Tags :
  • python

Similar Reads

  • How To Print A Variable's Name In Python
    In Python, printing a variable's name can be a useful debugging technique or a way to enhance code readability. While the language itself does not provide a built-in method to directly obtain a variable's name, there are several creative ways to achieve this. In this article, we'll explore five simp
    3 min read
  • Python - Solve the Linear Equation of Multiple Variable
    Prerequisite: Sympy.solve() In this article, we will discuss how to solve a linear equation having more than one variable. For example, suppose we have two variables in the equations. Equations are as follows: x+y =1 x-y =1 When we solve this equation we get x=1, y=0 as one of the solutions. In Pyth
    2 min read
  • Get Variable Name As String In Python
    In Python, getting the name of a variable as a string is not as straightforward as it may seem, as Python itself does not provide a built-in function for this purpose. However, several clever techniques and workarounds can be used to achieve this. In this article, we will explore some simple methods
    3 min read
  • Assigning multiple variables in one line in Python
    A variable is a segment of memory with a unique name used to hold data that will later be processed. Although each programming language has a different mechanism for declaring variables, the name and the data that will be assigned to each variable are always the same. They are capable of storing val
    2 min read
  • Returning Multiple Values in Python
    In Python, we can return multiple values from a function. Following are different ways 1) Using Object: This is similar to C/C++ and Java, we can create a class (in C, struct) to hold multiple values and return an object of the class. Python Code # A Python program to return multiple # values from a
    4 min read
  • Variable Length Argument in Python
    In this article, we will cover about Variable Length Arguments in Python. Variable-length arguments refer to a feature that allows a function to accept a variable number of arguments in Python. It is also known as the argument that can also accept an unlimited amount of data as input inside the func
    4 min read
  • Convert String into Variable Name in Python
    There may be situations where you want to convert a string into a variable name dynamically. In this article, we'll explore how to convert a string into a variable name in Python with four simple examples. Convert String into Variable Name in PythonWhile Python does not directly allow you to convert
    3 min read
  • Multiline String in Python
    A sequence of characters is called a string. In Python, a string is a derived immutable data type—once defined, it cannot be altered. To change the strings, we can utilize Python functions like split, join, and replace. Python has multiple methods for defining strings. Single quotations (''), double
    4 min read
  • Print first m multiples of n without using any loop in Python
    While loops are the traditional way to print first m multiples of n, Python provides other efficient methods to perform this task without explicitly using loops. This article will explore different approaches to Printing first m multiples of n without using any loop in Python. Using List Comprehensi
    3 min read
  • Unused variable in for loop in Python
    Prerequisite: Python For loops The for loop has a loop variable that controls the iteration. Not all the loops utilize the loop variable inside the process carried out in the loop. Example: C/C++ Code # i,j - loop variable # loop-1 print("Using the loop variable inside :") # used loop vari
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences