Day #26 - Exercise 2: Solution

Day #26 - Exercise 2: Solution

ยท

3 min read

Introduction

Welcome to my 26th blog post. Today I verified my solution to Exercise 2 Day #15 - Exercise 2: Time Module with the mentor and also revised the concepts learnt till day #26.

So let's get started......

Exercise 2: Solution

import time

name = input("Enter your Name \n ")

timestamp = time.strftime("%H:%M:%S")
print("\n", timestamp)

hours = int(time.strftime('%H'))
print(hours)

minutes = int(time.strftime('%M'))
print(minutes)

seconds = int(time.strftime('%S'))
print(seconds)


if (hours>4 and hours < 12 ):
    print("goodmorning")
elif(hours>12 and hours<16):
    print("good afternoon")
elif(hours>16 and hours<21):
    print("good evening")
else:
    print("goodnight")

print("Hi ", name, "time now is ", timestamp, )

Output

Enter your Name 
 Chintan

 22:37:23
22
37
23
goodnight
Hi  Chintan time now is  22:37:23
PS D:\coding\python\instagram\Python - Day #15>

Revision

Till now we learnt all the following concepts in python:

  1. Modules and Pip

  2. Comments, escape sequence characters, print()

  3. Variables and Data type

  4. Mathematical Operators

  5. Build a project: calculator

  6. Typecasting

  7. input() function

  8. Strings in python

  9. String slicing and operations

  10. String methods

  11. If Else conditional statement

  12. Time module

  13. Match case statement

  14. For loop, While loop

  15. Break and continue

  16. Function and function arguments

  17. List and list methods

  18. Tuple and operation on tuples

Resources Used

You can watch the video of Day#25 by clicking on the below link ๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡

Conclusion

Thanks, guys for going through this blog post. On day #26 we were provided with the solution to Exercise 2 that we solved on Day #15 - Exercise 2: Time Module

In this exercise we used time module to fetch the current time details i.e Hours, minutes, seconds. I also used strftime() function and typecasting to make the values fetched more readable in int format and perform operations. Meanwhile, I also revised the concepts learnt till Day #26 in python to be firm with fundamentals.

Thank you if you read this post and have found this post useful. I hope you have joined me and are enjoying my magical journey of python coding. This is it for Day #26

See you in the next one.....


About Me

Hey Guys, I am Chintan Jain from CodeWithJain. I am a trader and content creator. I am also passionate about tech and hence wanted to explore the field of tech. I always wanted to learn to code so I watched many tutorials but procrastinated practicing coding. To get into the habit of coding consistently I am starting to BLOG with HASHNODE on daily basis.

I will document my coding journey from scratch and share my daily learnings in a blog post on HASHNODE. I hope you all will enjoy my content and my coding journey.

So what are you waiting for, smash the FOLLOW and LIKE buttons and follow along my coding journey, a step to create more beautiful digital products and empower people.


ย