Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 902 Bytes

File metadata and controls

27 lines (18 loc) · 902 Bytes
sidebar_position 1

Sample Program

Before learning about python program, let's see a sample python program to be familiar with how the code looks.

Code

# 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.