Skip to content

Commit 7a8ebd4

Browse files
style: fix code formatting issues
All changes were made so that PEP 8 is followed. Fixes include: - Added missing (and removed extra) blank lines (end of file and around classes and functions) - Added missing spaces between `#`s for comments - Added missing spaces around operators (arithmetic, comparison, commas, dict colons, etc.) - Removed redundant parentheses - Use double-quotes for docstrings instead of single-quotes - Removed spaces around keyword argument equal signs - Fixed incorrect indentations Note: line lengths (which are supposed to stay below 79 characters) were ignored for now
1 parent 9a5f5f4 commit 7a8ebd4

111 files changed

Lines changed: 395 additions & 382 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
print("ram")
2-
print("Hello World")
2+
print("Hello World")

basics/01_introduction/04_mad_libs_story_generator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" This program generates a fun story by asking the user for different types of words"""
22

3+
34
def mad_libs_story():
45
# Ask the user for words
56
name = input("Enter a name: ")
@@ -25,6 +26,7 @@ def mad_libs_story():
2526
# Print the story
2627
print(story)
2728

29+
2830
# Run the story generator
2931
if __name__ == "__main__":
3032
mad_libs_story()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Addition of Two Numbers
22
first_number = int(input("Enter the Number : "))
33
second_number = int(input("Enter the Number : "))
4-
print(f"Addition of {first_number} and {second_number} is {first_number + second_number}")
4+
print(f"Addition of {first_number} and {second_number} is {first_number + second_number}")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
number = int(input("Enter the First Number : "))
2-
print(f"Square of {number} is {number ** 2}")
2+
print(f"Square of {number} is {number ** 2}")
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Write a python function which converts inches to cms
22

3+
34
def inch_cm(n):
45
inch = n * 2.54
56
return inch
67

8+
79
n = int(input("Enter the Number : "))
810
ch = inch_cm(n)
9-
print(ch)
11+
print(ch)
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
a = 1000
2+
3+
24
def code():
3-
global a #The global keyword allows a function to modify a global variable.
5+
global a # The global keyword allows a function to modify a global variable.
46
a = 12
57
print(a)
68

9+
710
code()
811
print(a)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
user_input = input(12) #Type of Input()
1+
user_input = input(12) # Type of Input()
22
input_type = type(user_input)
3-
print(input_type)
3+
print(input_type)
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
print("1.")
2-
a = "12.009" #String
3-
b = float(a) #String to Float
2+
a = "12.009" # String
3+
b = float(a) # String to Float
44
print(type(b))
55

66
print("2.")
7-
a = "12b" #String
8-
"""b = float(a) """ #Error-Occured @TypeError
7+
a = "12b" # String
8+
"""b = float(a) """ # Error-Occured @TypeError
99
print(type(b))
1010

1111
print("3.")
1212
z = "123"
1313
b = int(z)
1414
print(type(b))
15-
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
#Maybe the Program not work but you just see the types like how union used in the program by import typing
1+
# Maybe the Program not work but you just see the types like how union used
2+
# in the program by import typing
23

34
from typing import List, Union, Tuple
4-
def sum(a:Union[int,str],b:int) -> int:
5-
sum = a+b
5+
6+
7+
def sum(a: Union[int, str], b: int) -> int:
8+
sum = a + b
69
return sum
7-
a = sum(2,3)
8-
print(a)
910

1011

12+
a = sum(2, 3)
13+
print(a)
1114

12-
n : int = 5
15+
n: int = 5
1316
name: str = "Harry"
14-
def sum(a: int, b: int) -> int:
15-
return a+b
17+
18+
19+
def sum(a: int, b: int) -> int:
20+
return a + b
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
#Comparison Operator
2-
a=(4/2)==2
1+
# Comparison Operator
2+
a = (4/2) == 2
33
print(a)
44

5-
#Assignment Operator
5+
# Assignment Operator
66
a = 20
7-
a=a+10 # or a += 10
7+
a = a + 10 # or a += 10
88
print(a)
99

10-
#Logical Operators
10+
# Logical Operators
1111
print("\n")
1212
print("Truth Table of 'or'")
13-
print("True or True : ",True or True)
14-
print("True or False: ",True or False)
15-
print("False or False: ",False or False)
16-
print("False or True: ",False or True)
13+
print("True or True : ", True or True)
14+
print("True or False: ", True or False)
15+
print("False or False: ", False or False)
16+
print("False or True: ", False or True)
1717
print("\n")
1818
print("Truth Table of 'and'")
19-
print("True and True : ",True and True)
20-
print("True and False: ",True and False)
21-
print("False and False: ",False and False)
22-
print("False and True: ",False and True)
19+
print("True and True : ", True and True)
20+
print("True and False: ", True and False)
21+
print("False and False: ", False and False)
22+
print("False and True: ", False and True)

0 commit comments

Comments
 (0)