Greetings in Python

Have you ever wanted to write a simple python program that outputs a simple greeting based on the time with our name.

Today I'll show ou a simple way on how you can achieve this.

Problem Definition

Write a simple python program that takes your name as input and outputs a greeting like "Good morning Billy" if it's morning and afternoon if its in the afternoon.


1. Take a string as input, in this case your name.

2. Check for the time and return the hours(We will use the 24-hour system)

3. Create a loop to loop and find the correct statement that matches the time.

4. Print the given string while looping through the given commands and append your name.




Enter your Name: Billy
Good afternoon Billy

We needed to import the datetime module so as we can use the time module.

That's all hope you learnt something today.