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
-
Python is often hailed as the “Swiss Army knife” of programming languages due to its simplicity, versatility, and powerful capabilities. F...
-
Object-Oriented Programming (OOP) is a cornerstone of modern software development. It offers a systematic approach to organizing and struc...
-
Step-by-Step Breakdown 1. Lists a and b are defined: a = [ 1 , 2 ] b = [3, 4] a is a list containing [1, 2]. b is a list containing [3, ...
-
Explanation: Input List: The input list is numbers = [1, 2, 3, 4]. Lambda Function: The lambda x: x * 2 function takes each element x from...
-
Explanation: Initial List: my_list = [1, 2, 3, 4, 5, 6]. Enumerate: enumerate(my_list) generates pairs of index and value. However, modify...
-
Through a recent series of breakthroughs, deep learning has boosted the entire field of machine learning. Now, even programmers who know c...
-
100 Data Structure and Algorithm Problems to Crack Coding Interviews Unlock your potential to ace coding interviews with this comprehensiv...
-
This textbook grew out of notes for the ECE143 Programming for Data Analysis class that the author has been teaching at University of Cali...
-
Code Explanation: Lists keys and values: keys = ['a', 'b', 'c'] is a list of strings that will serve as the keys f...