Monday 4 October 2021

Python Project [ Digital Clock]


This script create a digital clock as per the system's current time.

Input:



import tkinter as tk
from time import strftime
def light_theme():
frame = tk.Frame(root, bg="white")
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl_1 = tk.Label(frame, font=('calibri', 40, 'bold'),
background='White', foreground='black')
lbl_1.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl_1.config(text=string)
lbl_1.after(1000, time)
time()
def dark_theme():
frame = tk.Frame(root, bg="#22478a")
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl_2 = tk.Label(frame, font=('calibri', 40, 'bold'),
background='#22478a', foreground='black')
lbl_2.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl_2.config(text=string)
lbl_2.after(1000, time)
time()
root = tk.Tk()
root.title("Digital-Clock")
canvas = tk.Canvas(root, height=140, width=400)
canvas.pack()
frame = tk.Frame(root, bg='#22478a')
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl = tk.Label(frame, font=('calibri', 40, 'bold'),
background='#22478a', foreground='black')
lbl.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl.config(text=string)
lbl.after(1000, time)
time()
menubar = tk.Menu(root)
theme_menu = tk.Menu(menubar, tearoff=0)
theme_menu.add_command(label="Light", command=light_theme)
theme_menu.add_command(label="Dark", command=dark_theme)
menubar.add_cascade(label="Theme", menu=theme_menu)
root.config(menu=menubar)
root.mainloop()

Output :







Join us: https://t.me/jupyter_python

Python Project [An application to save any random article from Wikipedia to a text file].


An application to save any random article from Wikipedia to a text file.



Output of the project






Source Code: 


from bs4 import BeautifulSoup
import requests

# Trying to open a random wikipedia article
# Special:Random opens random articles
res = requests.get("https://en.wikipedia.org/wiki/Special:Random")
res.raise_for_status()

# pip install htmlparser
wiki = BeautifulSoup(res.text, "html.parser")

r = open("random_wiki.txt", "w+", encoding='utf-8')

# Adding the heading to the text file
heading = wiki.find("h1").text

r.write(heading + "\n")
for i in wiki.select("p"):
    # Optional Printing of text
    # print(i.getText())
    r.write(i.getText())

r.close()
print("File Saved as random_wiki.txt")










Join us: https://t.me/jupyter_python

Program that converts arrays into a list, loops through the list to form a string using the chr() function




Input :


#Program that converts arrays into a list, loops through the list to form a string using the chr() function
#clcoding.com
import numpy as np
def ord_to_character(words = ""):
    
    x = np.array([112,121,134,123,32,96,34,56,67,111,98,97,119,105,113])
    
    y = np.array([78,90,104,123,132,53,34,56,97,116,98,27,119,77,117,12])
    
    z = np.array([111,112,134,123,21,32,108,106,89,70,80,103,103,120,121])
    
    letters = x.tolist() + y.tolist()  + z.tolist()
    
    for letter in letters:
        words += chr(letter)
        
        
    return words 


sentence = ord_to_character()
print(sentence)
    
Output :


py†{ `"8CobawiqNZh{„5"8atbwMuop†{ ljYFPggxy



Join us: https://t.me/jupyter_python

Plotting a colourful Scatter Plot using Matplotlib








from matplotlib import pyplot as plt

x = [10,20,30,40,50]
y = [200,300,100,400,500]
colors=[70,20,80,10,50]
sizes=[100,50,300,250,150]

plt.scatter(x,y,c=colors,s=sizes,cmap="Accent",alpha=1.0)
plt.colorbar()
plt.show





Join us: https://t.me/jupyter_python

Plotting Histogram using Pyplot







from matplotlib import pyplot as plt 

marks=[90,50,40,60,55,44,30,10,34,84]
grade_intervals=[0,35,70,100]
plt.title("Student Grades")
plt.hist(marks,grade_intervals,histtype="bar",rwidth=0.5,facecolor="blue")
plt.xticks([0,35,70,100])
plt.xlabel("Percentage")
plt.ylabel("No. of Students")
plt.show()


Join us: https://t.me/jupyter_python

Plotting Colourful Pie Chart In MatPlotlib




from matplotlib import pyplot as plt 

student_performance = ["Excellent","Good","Average","Poor"]
student_values = [15,25,12,8]
plt.figure(figsize=(7,10))
plt.pie(student_values,labels=student_performance,startangle=90,
        explode=[0.2,0,0,0],shadow=True,colors=["black","blue","yellow","red"],autopct="%2.1f%%")


plt.legend(title="Perfomances")
plt.show




Wednesday 23 June 2021

HANDLING MISSING DATA (FillNa) IN PANDAS



Firstly, we are importing an excel sheet as a DataFrame,
 

import pandas as pd
ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")
dt = pd.DataFrame(ds)
print(dt)








Now, Let's perform some operations related to FillNa()











Join us: https://t.me/jupyter_python

HANDLING MISSING DATA (dropna) IN PANDAS


Firstly, we are importing an excel sheet as a DataFrame,
 

import pandas as pd
ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")
dt = pd.DataFrame(ds)
print(dt)






Now, Let's perform some operations related to DROPNA


















Join us: https://t.me/jupyter_python

ILOC[ ] IN PANDAS - PYTHON

Firstly, we are importing an excel sheet as a DataFrame,
 
import pandas as pd

ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")

dt = pd.DataFrame(ds)






Now, Let's perform some operations related to ILOC 












Join us: https://t.me/jupyter_python

LOC[ ] IN PANDAS - PYTHON



LOC[ ] IN PANDAS

Firstly, we are importing an excel sheet as a DataFrame,
 
import pandas as pd

ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")

dt = pd.DataFrame(ds)







Now, Let's perform some operations related to LOC and ILOC 














Join us: https://t.me/jupyter_python

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (115) C (77) C# (12) C++ (82) Course (62) Coursera (179) coursewra (1) Cybersecurity (22) data management (11) Data Science (91) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (19) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (44) Meta (18) MICHIGAN (5) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (747) Python Coding Challenge (210) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses