import pyperclip as pc
text1 = input("Enter a text : ")
pc.copy(text1)
text2 = pc.paste()
print(text2)
#Source Code --> clcoding.com
Hello Clcoding
Python Coding August 17, 2024 Python No comments
Python Coding August 16, 2024 Python No comments
pip install alive-progress
from alive_progress import alive_bar
import time
items = range(100)
with alive_bar(len(items)) as bar:
for item in items:
time.sleep(0.05)
bar()
|████████████████████████████████████████| 100/100 [100%] in 5.0s (19.83/s)
from alive_progress import alive_bar
import time
tasks = ['task1', 'task2', 'task3', 'task4']
with alive_bar(len(tasks), title='Processing Tasks') as bar:
for task in tasks:
time.sleep(0.5)
bar.text = f'Working on {task}'
bar()
Processing Tasks |████████████████████████████████████████| 4/4 [100%] in 2.0s (2.00/s)
from alive_progress import alive_bar
import time
outer_items = range(3)
inner_items = range(5)
with alive_bar(len(outer_items) * len(inner_items), title='Processing') as bar:
for _ in outer_items:
for _ in inner_items:
time.sleep(0.1) # Simulate work
bar()
Processing |████████████████████████████████████████| 15/15 [100%] in 1.5s (9.94/s)
from alive_progress import alive_bar
import time
file_size = 1024
chunk_size = 64
with alive_bar(file_size // chunk_size, title='Downloading') as bar:
for _ in range(0, file_size, chunk_size):
time.sleep(0.1)
bar()
Downloading |████████████████████████████████████████| 16/16 [100%] in 1.6s (9.83/s)
from alive_progress import alive_bar
import time
total_items = 50
with alive_bar(total_items, title='Processing',
spinner='dots_waves', bar='smooth') as bar:
for _ in range(total_items):
time.sleep(0.1)
bar()
Processing |████████████████████████████████████████| 50/50 [100%] in 5.0s (9.95/s)
Python Coding August 15, 2024 Python No comments
pip install speedtest-cli
import speedtest as st
def Speed_Test():
test = st.Speedtest()
down_speed = test.download()
down_speed = round(down_speed / 10**6, 2)
print("Download Speed in Mbps: ", down_speed)
up_speed = test.upload()
up_speed = round(up_speed / 10**6, 2)
print("Upload Speed in Mbps: ", up_speed)
ping = test.results.ping
print("Ping: ", ping)
Speed_Test()
#source code -> clcoding.com
Download Speed in Mbps: 20.57
Upload Speed in Mbps: 18.47
Ping: 26.177
Python Coding August 15, 2024 Python No comments
import numpy as np
import matplotlib.pyplot as py
import matplotlib.patches as patch
a = patch.Rectangle((0,1), width=9, height=2, facecolor='#138808', edgecolor='grey')
b = patch.Rectangle((0,3), width=9, height=2, facecolor='#ffffff', edgecolor='grey')
c = patch.Rectangle((0,5), width=9, height=2, facecolor='#FF6103', edgecolor='grey')
m,n = py.subplots()
n.add_patch(a)
n.add_patch(b)
n.add_patch(c)
radius=0.8
py.plot(4.5,4, marker = 'o', markerfacecolor = '#000080', markersize = 9.5)
chakra = py.Circle((4.5, 4), radius, color='#000080', fill=False, linewidth=7)
n.add_artist(chakra)
for i in range(0,24):
p = 4.5 + radius/2 * np.cos(np.pi*i/9 + np.pi/48)
q = 4.5 + radius/2 * np.cos(np.pi*i/9 - np.pi/48)
r = 4 + radius/2 * np.sin(np.pi*i/9 + np.pi/48)
s = 4 + radius/2 * np.sin(np.pi*i/9 - np.pi/48)
t = 4.5 + radius * np.cos(np.pi*i/9)
u = 4 + radius * np.sin(np.pi*i/9)
n.add_patch(patch.Polygon([[4.5,4], [p,r], [t,u],[q,s]], fill=True,
closed=True, color='#000080'))
py.axis('equal')
py.show()
#clcoding.com
Python Coding August 10, 2024 Python No comments
import sympy as sp
x = sp.Symbol('x')
f = input("Enter the function(in terms of x):")
F_indefinite = sp.integrate(f, x)
print("Indefinite integral ∫f(x) dx =", F_indefinite)
a = float(input("Enter the lower limit of integration: "))
b = float(input("Enter the upper limit of integration: "))
F_definite = sp.integrate(f, (x, a, b))
print(f"Definite integral ∫f(x) dx from {a} to {b} =", F_definite)
#clcoding.com
Indefinite integral ∫f(x) dx = x**3/3 + 3*x
Definite integral ∫f(x) dx from 9.0 to 27.0 = 6372.00000000000
Python Coding August 09, 2024 Data Science, Python No comments
Python Coding August 08, 2024 Python No comments
import requests
from bs4 import BeautifulSoup
city = input("Enter City Name: ")
city_formatted = city.lower().replace(" ", "-")
url = f"https://www.timeanddate.com/weather/{city_formatted}"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
try:
temperature = soup.find("div", class_="h2").get_text(strip=True)
description = soup.find("div", class_="h2").find_next("p").get_text(strip=True)
print(f"Weather in {city}:")
print(f"Temperature: {temperature}")
print(f"Condition: {description}")
except AttributeError:
print("Please check the city name and try again.")
#clcoding.com
Please check the city name and try again.
Python Coding August 07, 2024 Python No comments
Python Coding August 07, 2024 Python No comments
The above code is used to create and display an interactive map using the folium library in Python, specifically within a Jupyter Notebook environment. Below is a step-by-step explanation of the code:
import foliumfrom IPython.display import display
This code creates an interactive map centered on New York City, adds a marker with a popup and a custom icon, and displays the map within a Jupyter Notebook.
Python Coding August 04, 2024 Python No comments
Mistake:
def add_item(item, items=[]):
items.append(item)
return items
Problem: Default mutable arguments, like lists or dictionaries, retain changes between function calls, which can lead to unexpected behavior.
Fix:
def add_item(item, items=None):
if items is None:
items = []
items.append(item)
return items
#clcoding.com
Mistake:
result = []
for i in range(10):
result.append(i * 2)
Problem: This approach is verbose and less efficient than it could be.
Fix:
result = [i * 2 for i in range(10)]
#clcoding.com
Explanation: List comprehensions are more Pythonic, concise, and often faster.
Mistake:
x = 10
def example():
print(x)
x = 5
example()
Problem: This raises an UnboundLocalError because Python considers x inside example() as a local variable due to the assignment.
Fix:
x = 10
def example():
global x
print(x)
x = 5
example()
#clcoding.com
Mistake:
def calculate(x):
print(f"Debug: x = {x}")
return x * 2
result = calculate(5)
Problem: Relying on print() statements for debugging can clutter code and is less efficient.
Fix:
def calculate(x):
return x * 2
result = calculate(5)
# Use a debugger for inspection
import pdb; pdb.set_trace()
#clcoding.com
Python Coding August 04, 2024 Python No comments
1. Simplicity and Clarity
Keep It Simple: Avoid unnecessary complexity. Each function should do one thing and do it well.
Descriptive Naming: Use clear, descriptive names for functions and variables. Avoid abbreviations unless they are widely understood.
Type Annotations: Use type hints to clarify what types of arguments a function expects and what it returns.
def calculate_area(radius: float) -> float:
return 3.14 * radius * radius
#clcoding.com
2. Avoid Hardcoding
Use Constants: Define constants for values that shouldn't change. Avoid magic numbers.
Parameterization: Make functions flexible by passing parameters instead of hardcoding values. python
PI = 3.14159
def calculate_circumference(radius: float, pi:
float = PI) -> float:
return 2 * pi * radius
#clcoding.com
3. Readability
Docstrings: Include a docstring that explains what the function does, its parameters, and its return value.
Consistent Indentation: Stick to 4 spaces per indentation level.
Avoid Long Lines: Break lines at 79 characters where possible.
def calculate_bmi(weight: float, height: float) -> float:
"""
Calculate the Body Mass Index (BMI).
:param weight: Weight in kilograms.
:param height: Height in meters.
:return: BMI value.
"""
return weight / (height ** 2)
#clcoding.com
4. Testing and Error Handling
Input Validation: Check for invalid inputs and handle them gracefully.
Unit Tests: Write tests for each function. Ensure edge cases are covered.
def divide_numbers(numerator: float, denominator: float) -> float:
if denominator == 0:
raise ValueError("Denominator cannot be zero.")
return numerator / denominator
#clcoding.com
5. Performance
Efficiency: Avoid unnecessary computations. Optimize for performance if the function will be called frequently or handle large data sets.
Avoid Global State: Don’t rely on or modify global variables
def is_prime(n: int) -> bool:
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
#clcoding.com
6. DRY Principle
Don’t Repeat Yourself: Reuse code by abstracting common functionality into separate functions or modules.
def get_positive_input(prompt: str) -> float:
value = float(input(prompt))
if value <= 0:
raise ValueError("Input must be a +ve number.")
return value
#clcoding.com
Python Coding August 03, 2024 Python No comments
from rich.console import Console
from rich.text import Text
console = Console()
# Create the message and color mapping
text = "Happy Friendship Day!"
colors = [
"red", "yellow", "green", "cyan", "blue", "white", "magenta",
"red", "yellow", "green", "cyan", "blue", "magenta", "red",
"yellow", "green", "white", "cyan", "blue", "magenta", "red"
]
# Generate the colorful message
message = Text()
[message.append(char, style=color) for char,color in zip(text, colors)]
console.print(message)
#clcoding.com
Happy Friendship Day!
import pyfiglet
from termcolor import colored
text = "Happy Friendship Day!"
fonts = ["slant"]
for i, word in enumerate(text.split()):
font = pyfiglet.Figlet(font=fonts[i % len(fonts)])
color = ["red", "green", "yellow", "blue", "magenta"][i % 5]
ascii_art = font.renderText(word)
print(colored(ascii_art, color))
#clcoding.com
__ __
/ / / /___ _____ ____ __ __
/ /_/ / __ `/ __ \/ __ \/ / / /
/ __ / /_/ / /_/ / /_/ / /_/ /
/_/ /_/\__,_/ .___/ .___/\__, /
/_/ /_/ /____/
______ _ __ __ _
/ ____/____(_)__ ____ ____/ /____/ /_ (_)___
/ /_ / ___/ / _ \/ __ \/ __ / ___/ __ \/ / __ \
/ __/ / / / / __/ / / / /_/ (__ ) / / / / /_/ /
/_/ /_/ /_/\___/_/ /_/\__,_/____/_/ /_/_/ .___/
/_/
____ __
/ __ \____ ___ __/ /
/ / / / __ `/ / / / /
/ /_/ / /_/ / /_/ /_/
/_____/\__,_/\__, (_)
/____/
Happy Friendship Day using Python
print('\n'.join
([''.join
([('Friendship'[(x-y)%8 ]
if((x*0.05)**2+(y*0.1)**2-1)
**3-(x*0.05)**2*(y*0.1)
**3<=0 else' ')
for x in range(-30,30)])
for y in range(15,-15,-1)]))
print("Happy Friendship Day !!")
#clcoding.com
shFriends iendshFri
endshFriendshFrie hFriendshFriendsh
iendshFriendshFriendshFriendshFriendshFri
iendshFriendshFriendshFriendshFriendshFrien
iendshFriendshFriendshFriendshFriendshFriends
endshFriendshFriendshFriendshFriendshFriendsh
ndshFriendshFriendshFriendshFriendshFriendshF
dshFriendshFriendshFriendshFriendshFriendshFr
shFriendshFriendshFriendshFriendshFriendshFri
hFriendshFriendshFriendshFriendshFriendshFrie
riendshFriendshFriendshFriendshFriendshFrie
endshFriendshFriendshFriendshFriendshFrie
ndshFriendshFriendshFriendshFriendshFrien
hFriendshFriendshFriendshFriendshFrie
riendshFriendshFriendshFriendshFrie
endshFriendshFriendshFriendshFrie
shFriendshFriendshFriendshFri
riendshFriendshFriendshFr
ndshFriendshFriendshF
FriendshFriends
ndshFrien
Fri
i
Happy Friendship Day !!
Python Coding August 03, 2024 Python Coding Challenge No comments
cl1 = "hello"
cl1_unicode = "hell\u00f6"
print(cl1 != cl1_unicode)
In Python, the comparison cl1 != cl1_unicode checks whether the two strings cl1 and cl1_unicode are different.
Here's the breakdown:
cl1 = "hello": This string contains the characters "h", "e", "l", "l", "o".
cl1_unicode = "hell\u00f6": This string contains the characters "h", "e", "l", "l", followed by the Unicode character \u00f6, which represents "ö".
When comparing cl1 and cl1_unicode:
"hello" is different from "hellö" because the last character in cl1_unicode ("ö") is different from the last character in cl1 ("o").
So, cl1 != cl1_unicode evaluates to True because the strings are not identical.
The print statement outputs True, indicating the strings are not equal.
Python Coding August 03, 2024 Python No comments
Closures
What: Functions that capture the local state of the environment in which they were created.
Why: Useful for creating function factories or decorators.
def outer(x):
def inner(y):
return x + y
return inner
add_five = outer(5)
print(add_five(10))
#clcoding.com
Function Annotations
What: Provides a way to attach metadata to function arguments and return values.
Why: Helps in providing hints about the expected data types, which improves code readability.
def add(a: int, b: int) -> int:
return a + b
print(add(2, 3))
#clcoding.com
Returning Multiple Values
What: Python allows functions to return multiple values as a tuple.
Why: Enables you to return complex data without creating a class or data structure.
def get_name_age():
name = "clcoding"
age = 30
return name, age
name, age = get_name_age()
print(name, age)
#clcoding.com
clcoding 30
Docstrings
What: Strings that describe what a function does, placed as the first line within the function body.
Why: Helps in documenting your code, making it more understandable.
def add(a, b):
"""Returns the sum of two numbers."""
return a + b
print(add.__doc__)
#clcoding.com
Returns the sum of two numbers.
Lambda Functions
What: Small, anonymous functions defined using lambda.
Why: Useful for short functions that are used once or passed as arguments to higher-order functions.
double = lambda x: x * 2
print(double(5))
items = [1, 2, 3, 4, 5]
squared = list(map(lambda x: x**2, items))
print(squared)
#clcoding.com
10
[1, 4, 9, 16, 25]
***args and kwargs
What: args and *kwargs allow functions to accept an arbitrary number of positional and keyword arguments, respectively.
Why: Useful when you don’t know in advance how many arguments will be passed.
def print_args(*args):
for arg in args:
print(arg)
print_args(1, 2, 3)
def print_kwargs(**kwargs):
for key, value in kwargs.items():
print(f"{key}: {value}")
print_kwargs(name="clcoding", age=30)
#clcoding.com
1
2
3
name: clcoding
age: 30
Default Arguments
What: Allows you to set default values for function parameters.
Why: Makes your functions more flexible and easier to use.
def greet(name="Guest"):
print(f"Hello, {name}!")
greet()
greet("clcoding")
#clcoding.com
Hello, Guest!
Hello, clcoding!
Python Coding July 31, 2024 Python No comments
Password authentication process using Python
import hashlib, os
def hash_psd(psd: str) -> str:
salt = os.urandom(16)
hashed_psd = hashlib.pbkdf2_hmac('sha256',
psd.encode(), salt, 100000)
return salt.hex() + hashed_psd.hex()
def verify_psd(stored_psd: str, provided_psd: str) -> bool:
salt = bytes.fromhex(stored_psd[:32])
stored_hash = stored_psd[32:]
hashed_psd = hashlib.pbkdf2_hmac('sha256',
provided_psd.encode(),salt,100000)
return hashed_psd.hex() == stored_hash
if __name__ == "__main__":
psd_to_store = input("Enter a Password: ")
stored_psd = hash_psd(psd_to_store)
print(f'Stored Password: {stored_psd}')
psd_attempt = 'clcoding'
is_valid = verify_psd(stored_psd, psd_attempt)
print(f'Password is valid: {is_valid}')
#clcoding.com
Stored Password: ec87cb3f526a3dc27e5a67fe7878f850a6b24c71c2941edc5bbe2c3500afc164cebb1ec8bbbc6a2260faa4825307600e
Password is valid: True
Python Coding July 27, 2024 Python No comments
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-07-27/olympics.csv')
print(df.head())
medal_counts = df.groupby('team')['medal'].count().reset_index()
medal_counts = medal_counts.sort_values(by='medal', ascending=False).head(10)
print(medal_counts)
top_countries = medal_counts['team'].head(5)
df_top_countries = df[df['team'].isin(top_countries)]
medals_by_year = df_top_countries.groupby(['year', 'team'])['medal'].count().reset_index()
# Plot: Medals Over Time for Top 5 Countries
plt.figure(figsize=(14, 8))
sns.lineplot(data=medals_by_year, x='year', y='medal', hue='team')
plt.title('Medals Over Time for Top 5 Countries')
plt.xlabel('Year')
plt.ylabel('Number of Medals')
plt.legend(title='Country')
plt.show()
# What is the distribution of medals by sport?
medals_by_sport = df.groupby('sport')['medal'].count().reset_index()
medals_by_sport = medals_by_sport.sort_values(by='medal', ascending=False).head(10)
# Plot: Top 10 Sports by Number of Medals
plt.figure(figsize=(14, 8))
sns.barplot(data=medals_by_sport, x='medal', y='sport', palette='viridis')
plt.title('Top 10 Sports by Number of Medals')
plt.xlabel('Number of Medals')
plt.ylabel('Sport')
plt.show()
#clcoding.com
Python Coding July 25, 2024 Python No comments
import turtle
def draw_ring(color, x, y):
turtle.penup()
turtle.color(color)
turtle.goto(x, y)
turtle.pendown()
turtle.circle(50)
turtle.speed(5)
turtle.width(5)
draw_ring("blue", -120, 0)
draw_ring("black", 0, 0)
draw_ring("red", 120, 0)
draw_ring("yellow", -60, -50)
draw_ring("green", 60, -50)
turtle.hideturtle()
turtle.done()
#clcoding.com
Python Coding July 25, 2024 Python Coding Challenge No comments
In Python, dictionaries are compared based on their keys and corresponding values. When you use the != operator to compare two dictionaries, it checks if there is any difference between them.
Here’s the explanation for the given code:
dict1 = {"a": 1, "b": 2}
dict2 = {"a": 1, "b": 3}
print(dict1 != dict2)
dict1 is created with keys "a" and "b" having values 1 and 2, respectively.
dict2 is created with keys "a" and "b" having values 1 and 3, respectively.
The comparison dict1 != dict2 checks if dict1 is not equal to dict2.
Python compares each key-value pair in dict1 with the corresponding key-value pair in dict2.
Both dictionaries have the same keys: "a" and "b".
For key "a", both dictionaries have the value 1. So, these are equal.
For key "b", dict1 has the value 2 and dict2 has the value 3. These are not equal.
Since there is at least one key-value pair that differs ("b": 2 in dict1 vs. "b": 3 in dict2), the dictionaries are considered not equal.
Result:
The expression dict1 != dict2 evaluates to True.
Therefore, the output of print(dict1 != dict2) will be True, indicating that dict1 is not equal to dict2.
Python Coding July 21, 2024 Java No comments
Are you eager to dive into the world of Java programming and software engineering? Coursera offers an excellent course titled Java Programming and Software Engineering Fundamentals that provides a comprehensive foundation in these essential skills. Whether you're a beginner or looking to refresh your knowledge, this course is a great starting point.
Java is one of the most widely-used programming languages in the world. Its versatility, robustness, and cross-platform capabilities make it a favorite among developers. Java powers a multitude of applications, from mobile apps to large-scale enterprise systems. By learning Java, you open doors to a vast array of career opportunities in software development, web development, data science, and more.
The "Java Programming and Software Engineering Fundamentals" course is designed to take you from zero to proficient in Java programming. Here's a breakdown of what you can expect:
Introduction to Java Programming
Object-Oriented Programming (OOP)
Data Structures and Algorithms
Software Engineering Fundamentals
Practical Projects
The "Java Programming and Software Engineering Fundamentals" course on Coursera is an excellent opportunity to gain a deep understanding of Java and software engineering. With its comprehensive curriculum, expert instructors, and flexible learning options, this course is a valuable resource for anyone looking to advance their programming skills.
Ready to embark on your Java programming journey? Enroll today and take the first step towards becoming a proficient Java developer!
Python Coding July 21, 2024 Python Coding Challenge No comments
This Python code defines a function and then calls it with specific arguments. Let's break it down step by step:
Function Definition:
def func(x, y):
return x + y
def func(x, y):: This line defines a function named func that takes two parameters, x and y.
return x + y: This line specifies that the function will return the sum of x and y.
Function Call:
print(func(y=2, x=3))
func(y=2, x=3): This calls the func function with x set to 3 and y set to 2. The order of the arguments doesn't matter here because they are passed as keyword arguments.
The function func adds x and y, so 3 + 2 results in 5.
print(5): The print function then outputs the result, which is 5.
Putting it all together, the code defines a function that adds two numbers, then calls the function with x as 3 and y as 2, and prints the result, which is 5.
Python Coding July 20, 2024 Python Coding Challenge No comments
The code provided consists of two parts: defining a dictionary and using the fromkeys method to create a new dictionary. Let's break it down:
Defining a Dictionary:
d = {'a': 1, 'b': 2, 'c': 3}
Here, d is a dictionary with three key-value pairs:
'a' maps to 1
'b' maps to 2
'c' maps to 3
Using dict.fromkeys:
print(dict.fromkeys(d, 0))
The dict.fromkeys method is used to create a new dictionary from the keys of an existing iterable (in this case, the dictionary d). The method signature is:
dict.fromkeys(iterable, value)
iterable: An iterable containing keys.
value: The value to assign to each key in the new dictionary.
In this code, d is used as the iterable. When d is used as an iterable, it provides its keys ('a', 'b', and 'c'). The second argument is 0, which means all keys in the new dictionary will have the value 0.
Therefore, the new dictionary created by dict.fromkeys(d, 0) will have the same keys as d but with all values set to 0:
{'a': 0, 'b': 0, 'c': 0}
Output:
The print statement will output:
{'a': 0, 'b': 0, 'c': 0}
In summary, the code defines a dictionary d and then creates a new dictionary with the same keys as d but with all values set to 0, and prints this new dictionary.
Python Coding July 19, 2024 Python Coding Challenge No comments
7. Error Prevention
Reason: PEP 8 includes guidelines that help prevent common errors, such as mixing tabs and spaces for indentation.
Without PEP 8:
def calculate_sum(a, b):
return a + b
print("Sum calculated")
Cell In[16], line 3
print("Sum calculated")
^
IndentationError: unexpected indent
With PEP 8:
def calculate_sum(a, b):
return a + b
print("Sum calculated")
Sum calculated
6. Community Standard
Reason: PEP 8 is the de facto standard for Python code. Following it ensures your code aligns with what other Python developers expect, making it easier for others to read and contribute to your projects.
Without PEP 8:
class Person:
def __init__(self,name,age):
self.name=name
self.age=age
def getDetails(self):
return self.name + " is " + str(self.age)
With PEP 8:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def get_details(self):
return f"{self.name} is {self.age}"
5. Professionalism
Reason: Following PEP 8 shows that you care about writing high-quality code. It demonstrates professionalism and attention to detail, which are valuable traits in any developer.
Without PEP 8:
def square(x):return x*x
With PEP 8:
def square(x):
return x * x
4. Maintainability
Reason: Code that adheres to a standard style is easier to maintain and update. PEP 8’s guidelines help you write code that is more maintainable in the long run.
Without PEP 8:
def processData(data):
result = data["name"].upper() + " is " + str(data["age"]) + " years old"
return result
With PEP 8:
def process_data(data):
result = f"{data['name'].upper()} is {data['age']} years old"
return result
#clcoding.com
3. Collaboration
Reason: When everyone on a team follows the same style guide, it’s easier for team members to read and understand each other’s code, making collaboration smoother.
Without PEP 8:
def fetchData():
# fetch data from API
data = {"name":"John","age":30}
return data
With PEP 8:
def fetch_data():
# Fetch data from API
data = {"name": "John", "age": 30}
return data
2. Readability
Reason: Readable code is easier to understand and debug. PEP 8 encourages practices that make your code more readable.
Without PEP 8:
def add(a,b):return a+b
With PEP 8:
def add(a, b):
return a + b
1. Consistency
Reason: Consistent code is easier to read and understand. PEP 8 provides a standard style guide that promotes consistency across different projects and among different developers.
Without PEP 8:
def my_function():print("Hello"); print("World")
my_function()
Hello
World
With PEP 8:
def my_function():
print("Hello")
print("World")
my_function()
Hello
World
Free Books Python Programming for Beginnershttps://t.co/uzyTwE2B9O
— Python Coding (@clcoding) September 11, 2023
Top 10 Python Data Science book
— Python Coding (@clcoding) July 9, 2023
🧵:
Top 4 free Mathematics course for Data Science ! pic.twitter.com/s5qYPLm2lY
— Python Coding (@clcoding) April 26, 2024
Web Development using Python
— Python Coding (@clcoding) December 2, 2023
🧵: