Class 11 Practical Programs
Display Welcome Message
AIM
To write a Python program that displays a welcome message to the user with proper formatting and decorative elements.
ALGORITHM
- Start
- Take the user's name as input
- Display a decorative border using asterisks
- Display the welcome message with the user's name
- Add additional formatting for better presentation
- Stop
PROGRAM
# Python program to display welcome message
print("Welcome to Python Programming!")OUTPUT
Welcome to Python Programming!
CONCLUSION
Thus, the given program was successfully executed and the output was verified as per the expected result.
VIVA QUESTIONS
What is the purpose of the print() function in Python?
The print() function is used to display output on the screen. It can print strings, numbers, variables, and expressions.
How do you take input from the user in Python?
We use the input() function to take input from the user. It always returns a string, so we need to convert it to other data types if required.
What is string formatting and why is it useful?
String formatting allows us to insert variables into strings. F-strings (f"text {name}") provide a clean and readable way to format strings.
What does the * operator do with strings?
The * operator with strings performs string multiplication, repeating the string a specified number of times. For example, "*" * 5 produces "*****".
What is the purpose of escape sequences like \\n?
Escape sequences represent special characters. \\n represents a newline character, \\t represents a tab, and \\\\ represents a backslash.
How does the center() method work?
The center() method centers a string within a specified width by adding spaces on both sides. For example, "Hello".center(10) produces " Hello ".
What is the difference between single and double quotes in Python?
Both single ('') and double ("") quotes can be used to create strings in Python. They are functionally equivalent, but you can use one inside the other.
How can you calculate the length of a string?
You can use the len() function to calculate the length of a string. For example, len("Hello") returns 5.