Python Practical Assignment 1.1

Write a Python Program to Print a Value Using Variable

Introduction

In Python, a variable is used to store data that can be used later in a program. This simple program shows how to assign a value to a variable and print it.


Logic to Write the Code

  1. Start the program.
  2. Create a variable and assign a value to it.
  3. Use the print() function to display the value.
  4. End the program.

Source Code (Beginner Friendly)

# Python program to print a value using a variable

# Assigning value to a variable
message = "Hello, World!"

# Printing the value of the variable
print(message)

Sample Output

Hello, World!

Viva Questions with Answers

1. What is a variable in Python?

A variable is a name used to store data or a value in a program.

2. How do you assign a value to a variable in Python?

You use the assignment operator =.
Example: x = 10

3. Which function is used to print output in Python?

The print() function is used to display output.

4. Do we need to declare the data type of a variable in Python?

No, Python automatically detects the data type.

5. Can a variable value be changed in Python?

Yes, the value of a variable can be changed anytime in the program.


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top