Tuesday, 3 May 2022
Day 27 : Pie Charts using Matplotlib in Python
Python Coding May 03, 2022 Python No comments
#!/usr/bin/env python
# coding: utf-8
# # Pie Charts using Matplotlib in Python
# In[2]:
#Pie Charts using Matplotlib in Python
import matplotlib.pyplot as pyplot
labels = ('Python', 'Java', 'Scala', 'C#')
sizes = [45, 30, 15, 10]
pyplot.pie(sizes,
labels=labels,
autopct='%1.f%%',
counterclock=False,
startangle=105)
# Display the figure
pyplot.show()
#clcoding.com
# In[ ]:
# In[ ]:
Day 26 : Real time Currency Converter with Python
Python Coding May 03, 2022 Python No comments
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
pip install forex_python
# # Real-time Currency Converter with Python
# In[7]:
from forex_python.converter import CurrencyRates
c = CurrencyRates()
amount = int(input("Enter the amount: "))
from_currency = input("From Currency: ").upper()
to_currency = input("To Currency: ").upper()
print(from_currency, " To ", to_currency, amount)
result = c.convert(from_currency, to_currency, amount)
print(result)
#clcoding.com
# In[ ]:
Day 25 : Extract Text from PDF with Python
Python Coding May 03, 2022 Python No comments
Day 24 : Validate Anagrams using Python
Python Coding May 03, 2022 Python No comments
Day 23 : Contact Book in Python
Python Coding May 03, 2022 Python No comments
Day 22 : Pick a Random Card using Python
Python Coding May 03, 2022 Python No comments
#!/usr/bin/env python
# coding: utf-8
# # Pick a Random Card using Python
# In[8]:
import random
cards = ["Diamonds", "Spades", "Hearts", "Clubs"]
ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10,
"Jack", "Queen", "King", "Ace"]
def pick_a_card():
card = random.choices(cards)
rank = random.choices(ranks)
return(f"The {rank} of {card}")
print(pick_a_card())
#clcoding.com
# In[ ]:
Day 21 : Fidget Spinner game with Python
Python Coding May 03, 2022 Python No comments
#!/usr/bin/env python
# coding: utf-8
# # Fidget Spinner game with Python
# In[7]:
from turtle import *
state = {'turn': 0}
def spinner():
clear()
angle = state['turn']/10
right(angle)
forward(100)
dot(120, 'cyan')
back(100)
right(120)
forward(100)
dot(120, 'green')
back(100)
right(120)
forward(100)
dot(120, 'blue')
back(100)
right(120)
update()
def animate():
if state['turn']>0:
state['turn']-=1
spinner() #clcoding.com
ontimer(animate, 20)
def flick():
state['turn']+=10
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
width(20)
onkey(flick, 'space')
listen()
animate()
done()
# In[ ]:
# In[ ]:
Day 20 : Spelling Correction with Python
Python Coding May 03, 2022 Python No comments
Day 19 : Chessboard using Matplotlib in Python
Python Coding May 03, 2022 Python No comments
#!/usr/bin/env python
# coding: utf-8
# # Chessboard using Matplotlib in Python
# In[17]:
import matplotlib.pyplot as plt
dx, dy = 0.015, 0.015
x = np.arange(-4.0, 4.0, dx)
y = np.arange(-4.0, 4.0, dy)
X, Y = np.meshgrid(x, y)
extent = np.min(x), np.max(x), np.min(y), np.max(y)
z1 = np.add.outer(range(8), range(8)) % 2
plt.imshow(z1, cmap="binary_r", interpolation="nearest", extent=extent, alpha=1)
def chess(x, y):
return (1 - x / 2 + x ** 5 + y ** 6) * np.exp(-(x ** 2 + y ** 2))
z2 = chess(X, Y)
plt.imshow(z2, alpha=0, interpolation="bilinear", extent=extent)
plt.title("Chess Board in Python")
plt.show()
#clcoding.com
# In[ ]:
Day 18 : Three Dimensional contour plots
Python Coding May 03, 2022 Python No comments
Popular Posts
-
Explanation of the Code This code demonstrates Python's iterable unpacking feature, specifically using the * operator to collect rema...
-
Explanation If you read through , which defines assignment expressions, you’ll see a section called Exceptional cases, which has an exampl...
-
Python is often hailed as the “Swiss Army knife” of programming languages due to its simplicity, versatility, and powerful capabilities. F...
-
Python has quickly become one of the most popular programming languages worldwide, and for good reason. It's versatile, easy to learn, a...
-
Explanation The code in this quiz is tricky! Here you are modifying the list that the generator wants to use. Here is the key to understan...
-
The Business Analytics Masters program by Euron is an exceptional course tailored to meet the growing demand for professionals who can tra...
-
Explanation Input Lists : a is a list of integers: [1, 2, 3] b is a list of strings: ['x', 'y', 'z'] zip Function...
-
Explanation np.array([1, 2, 3, 4]) : Creates a NumPy array arr with the elements [1, 2, 3, 4]. np.clip(arr, 2, 3) : The np.clip() function...
-
14 Foundational Concepts Every Python Programmer Should Master Python, a versatile and beginner-friendly language, offers a plethora of fe...