Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions day-01/functions_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import psutil
# cpu usage check karne ke liye psutil library ka use karte hai, isko install karne ke liye pip install psutil command ka use karte hai


# Function = "Kamm karna"

# def sum_of_two_numbers():

# num1 = int(input("Enter the first number :"))
# num2 = int(input("Enter the second number :"))
# sum = num1+num2
# print(sum)
# sum_of_two_numbers()



# env = input("Enter the environment : ")
# if env == "Dev":
# print("Not correct env")
# elif env == "Prod":
# def sum_of_two_numbers():

# num1 = int(input("Enter the first number :"))
# num2 = int(input("Enter the second number :"))
# sum = num1+num2
# print(sum)
# sum_of_two_numbers()
# else:
# print("Please enter correct env")


# env = input("Enter the environment : ")
# if env == "Dev":
# print("Not correct env")
# elif env == "Prod":
# sum_of_two_numbers()
# else:
# print("Please enter correct env")



# cpu_usage = int(input("Enter the CPU usage : "))
# def check_cpu_usage():
# cpu_usage = int(input("Enter the CPU usage : "))
# if cpu_usage >= 80:
# print("Send them an email")
# else:
# print("CPU usage is normal")
# check_cpu_usage()

def check_cpu_usage():
cpu_threshold = int(input("Enter the CPU threshold : "))
current_cpu_usage = psutil.cpu_percent(interval=1) # interval = 1 means it will check the CPU usage for 1 second
print("Current CPU usage is : ", current_cpu_usage)
if current_cpu_usage > cpu_threshold:
print("Send them an email")
else:
print("CPU usage is normal")
check_cpu_usage()
22 changes: 22 additions & 0 deletions day-02/api_data_fetcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import requests
import json


api_url = "https://official-joke-api.appspot.com/random_joke"

def get_jokes():
response = requests.get(url=api_url)
print(response.json())
# final = json.loads(response.text)
# print(final)
# new_final = json.dumps(final)
with open ("jokes.json" , "w") as json_file:
json_file.write(response.text)
print("data written to json file successfully")
for key,value in response.json().items():
setup = response.json()["setup"]
punchline = response.json()["punchline"]
return setup, punchline
setup, punchline = get_jokes()
print(setup)
print(punchline)
1 change: 1 addition & 0 deletions day-02/jokes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"general","setup":"Did you hear the story about the cheese that saved the world?","punchline":"It was legend dairy.","id":65}