Welcome to GLAB-370.1.1! In this lab, you will learn how to write a simple "Hello, World!" program in Python. We will also make the program interactive and engage the learner to create their own program at the end. Let's get started!
To complete this lab, you should have basic knowledge of programming concepts and some familiarity with Python. If you are new to Python, don't worry! This lab is designed to be beginner-friendly.
Before we begin coding, let's make sure you have Python installed on your computer. Follow the following
ACT-370.1.1-InstallingPython
- Open your favorite text editor or integrated development environment (IDE).
- Create a new file and save it with a .py extension. For example, hello_world.py.
Copy and paste the following code into your Python file:
# Interactive Hello World Program
name = input("Enter your name: ")
print("Hello, " + name + "! Welcome to the world of Python!")
To run the program, follow these steps:
- Open a terminal or command prompt.
- Navigate to the directory where you saved the Python file.
- Type python hello_world.py (replace hello_world.py with the name you gave your file) and press Enter.
- You should see a prompt asking for your name. Enter your name and press Enter. The program will then display a personalized greeting.
Now, let's make the program more interactive by adding a prompt for the user to enter their age. Modify the code as follows:
# Interactive Hello World Program
name = input("Enter your name: ")
age = input("Enter your age: ")
print("Hello, " + name + "! Welcome to the world of Python!")
print("You are " + age + " years old.")
Save the changes and run the program again. This time, you'll be prompted to enter both your name and age. The program will display your personalized greeting along with your age.
Congratulations on completing the interactive Hello World program! Now it's time to get creative.
- Think of a simple program idea and try to implement it using Python. Create "ai name" game, that will ask two questions, your name based on that it will print your ai name as "ai"+"yourname"
- Once you've finished creating your program, save it in a new Python file as ai.py.
- Please submit your file
In this lab, you learned how to write a simple "Hello, World!" program in Python and made it interactive by adding prompts for user input. You also got the opportunity to create your own program.
Keep exploring Python and practicing your programming skills. The possibilities are endless, and you're well on your way to becoming a proficient Python developer.