Printing Multiple Values - 18.4 | 18. PRINT | CBSE Class 9 AI (Artificial Intelligence)
K12 Students

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skills—perfect for learners of all ages.

Introduction & Overview

Read a summary of the section's main ideas. Choose from Basic, Medium, or Detailed.

Quick Overview

The print() function in Python can accept multiple values, allowing for streamlined output formatting.

Standard

This section covers how to use the print() function to display multiple values simultaneously. It highlights the use of commas to separate outputs and illustrates how to format those outputs using the 'sep' parameter for custom separators.

Detailed

Detailed Summary

The print() function in Python allows developers to output multiple values in a single command, which helps keep the code concise and more readable. By separating the items with commas within the print() function, programmers can easily display complex outputs. For instance, writing `print(

Audio Book

Dive deep into the subject with an immersive audiobook experience.

Introduction to Multiple Values

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

The print() function can take multiple arguments, separated by commas.

Detailed Explanation

In Python, the print() function is versatile and allows you to display more than one value at a time. When you use the print() function, you can pass in various arguments separated by commas. This means you can show multiple pieces of information in a single output line, which is quite useful for combining text and variable values together.

Examples & Analogies

Imagine you're a teacher giving feedback to a student about their grades. Instead of saying individual statements like 'Your math score is 90' and 'Your science score is 85', you could say 'Your scores are: 90 in math and 85 in science.' This is similar to how you can print multiple values at once in Python.

Example of Printing Multiple Values

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Example:

a = 5
b = 10
print("The values are", a, "and", b)

Output:
The values are 5 and 10

Detailed Explanation

In this example, we have two variables, 'a' and 'b', assigned the values 5 and 10, respectively. When we use the print() function with these variables along with some text, Python combines them into one cohesive output. The text 'The values are' is printed first, followed by the value of 'a', then the text 'and', and finally the value of 'b'. This demonstrates how easily you can display multiple values in a single line.

Examples & Analogies

Think of it as introducing a pair of friends at a party. Instead of saying just one name at a time, you could say 'This is Sarah who is 22 years old and this is Jack who is 24 years old.' You're using one statement to convey information about both friends.