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:
Modules and Pip
Comments, escape sequence characters, print()
Variables and Data type
Mathematical Operators
Build a project: calculator
Typecasting
input() function
Strings in python
String slicing and operations
String methods
If Else conditional statement
Time module
Match case statement
For loop, While loop
Break and continue
Function and function arguments
List and list methods
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.