Sample Program
Before learning about python program, let's see a sample python program to be familiar with how the code looks.
Code
sample.py
# This is a simple program that asks for your name and says hello!
# Ask the user for their name
name = input("What is your name? ")
# Greet the user
print("Hello, " + name + "! Welcome to the world of Python programming.")
Explanation:
#
: Anything after#
is a comment, which explains the code. It doesn't affect how the program runs.input()
: This function asks the user to type something. In this case, it asks for their name.print()
: This function displays information on the screen. Here, it greets the user using the name they entered.
This small program gives an idea of how we interact with users and use simple functions to make the program more engaging.