Table of Contents

Print Messages and User Numbers | Pictoblox

Example Description
Discover how to print messages like 'Keep Smiling' and user numbers in Python with this beginner-friendly code snippet

Introduction:

Discover Python’s simplicity and versatility in this code excerpt. Learn to print messages, like “Keep Smiling,” and display user numbers. Perfect for beginners, this foundational skill opens doors to more complex coding tasks. Engage users with Python’s readability and unlock its potential to convey meaningful messages and data. Start your journey today!

Code:

message = "Keep Smiling"
print(message)
userNo = 101
print('User Number is', userNo)

Logic:

  1. Declare a variable ‘message’ and assign the string value “Keep Smiling” to it.
  2. Use the ‘print’ function to display the value of the ‘message’ variable, which will output “Keep Smiling” to the console.
  3. Declare a variable ‘userNo’ and assign the integer value 101 to it.
  4. Use the ‘print’ function again to display the message “User Number is” followed by the value of the ‘userNo’ variable. This will output “User Number is 101” to the console.

Output:

In summary, this Python code sets a message as “Keep Smiling” and prints it, then sets a user number as 101 and prints it along with a custom message. The output will be:

>> Keep Smiling

>> User Number is 101