Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.appmodconfig

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAS Confidence Score: 100%

JAS - Just a suggestion
Clarification on .gitignore Entry

I see the .appmodconfig entry is still present from the last review. If this file is intended to hold local, user-specific, or secret configurations, then this is the correct approach. However, if it's a default or template configuration file required for the application to run, it should be checked into version control. Could you please confirm the purpose of this file to ensure it's being handled correctly?

9 changes: 9 additions & 0 deletions python/P01_hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Author: OMKAR PATHAK
# This program prints the entered message

def justPrint(text):
'''This function prints the text passed as argument to this function'''
print(text)

if __name__ == '__main__':
justPrint('Hello01 appmod')
15 changes: 15 additions & 0 deletions python/P02_InstanceMethods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Author: OMKAR PATHAK
#In this example we will be seeing how instance methods are used
#Instance methods are accessed by: instance.method()

class Vehicle():
#Class Methods/ Attributes

#Here self is passed as an argument because instance is passed as first argument
def type(self): #Without self it throws an error

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning Confidence Score: 100%

Shadowing Built-in Function 'type'

I notice we're naming this method type. In Python, type() is a very common built-in function used to check an object's class. While this works inside the class, it can be confusing for others reading the code and might lead to unexpected behavior if someone tries to use the built-in type within this scope. Let's rename it to something more descriptive like get_vehicle_type or display_type to follow best practices.

Suggested change
def type(self): #Without self it throws an error
def display_type(self):

print(self)
print('I have a type')

car = Vehicle()
print(car)
car.type()
16 changes: 16 additions & 0 deletions python/P02_VariableScope copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#Author: OMKAR PATHAK
#This programs shows the rules for variable scope

# LEGB Rule: Local, Enclosing, Global, Built-in

x = 80 # Global x

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Non-Descriptive Variable Name

The variable name 'x' is a single-character name which is non-descriptive. It should be renamed to reflect its purpose, such as 'global_count' or 'base_value'.

Suggested change
x = 80 # Global x
global_value = 80 # Global value


def test():
#global x
y = 100 # Local y

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Non-Descriptive Variable Name

The variable name 'y' is a single-character name. Using more descriptive names like 'local_offset' or 'increment_value' enhances code clarity.

Suggested change
y = 100 # Local y
local_value = 100 # Local value

x = 20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Non-Descriptive Variable Name

The variable name 'x' is non-descriptive. Renaming it to something like 'local_limit' would improve readability.

Suggested change
x = 20
local_limit = 20

print(x + y) #prints 'Local x' and 'Local y'

if __name__ == '__main__':
test()
print(x) #prints 'Global x'
16 changes: 16 additions & 0 deletions python/P02_VariableScope.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#Author: OMKAR PATHAK
#This programs shows the rules for variable scope

# LEGB Rule: Local, Enclosing, Global, Built-in

x = 'Global x'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Non-Descriptive Variable Name

The variable name 'x' is a single character and does not convey the purpose of the data it holds. Using more descriptive names like 'global_message' or 'scope_indicator' improves code maintainability.

Suggested change
x = 'Global x'
global_message = 'Global x'


def test():
#global x
y = 'Local y'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Non-Descriptive Variable Name

The variable name 'y' is a single character and lacks descriptive context. Renaming it to something like 'local_message' or 'test_output' would make the function's intent clearer.

Suggested change
y = 'Local y'
local_message = 'Local y'

x = 'Local x'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Non-Descriptive Variable Name

The variable name 'x' is non-descriptive. While it demonstrates shadowing in this scope example, using a name like 'local_scope_text' would be more expressive.

Suggested change
x = 'Local x'
local_scope_text = 'Local x'

print(x +', '+ y) #prints 'Local x' and 'Local y'

if __name__ == '__main__':
test()
print(x) #prints 'Global x'
47 changes: 47 additions & 0 deletions python/P03_ListsOperations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#Author: OMKAR PATHAK
#This program gives examples about various list operations

#Syntax: list[start: end: step]

myList = [1, 2, 3, 4, 5, 6, 7, 8, 9]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAS Confidence Score: 100% View Citation

JAS - Just a suggestion
Non-Descriptive Variable Name

The variable name 'myList' is generic. Using a more descriptive name like 'numbers' or 'integer_list' improves code clarity and follows best practices.

Suggested change
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9]
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]

#index 0 1 2 3 4 5 6 7 8
# -9 -8 -7 -6 -5 -4 -3 -2 -1

#List Slicing
print('Original List:',myList)
print('First Element:',myList[0]) #Prints the first element of the list or 0th element of the list
print('Element at 2nd Index position:',myList[2]) #Prints the 2nd element of the list
print('Elements from 0th Index to 4th Index:',myList[0: 5]) #Prints elements of the list from 0th index to 4th index. IT DOESN'T INCLUDE THE LAST INDEX
print('Element at -7th Index:',myList[-7]) #Prints the -7th or 3rd element of the list

#To append an element to a list
myList.append(10)
print('Append:',myList)

#To find the index of a particular element
print('Index of element \'6\':',myList.index(6)) #returns index of element '6'

#To sort the list
myList.sort()

#To pop last element
print('Poped Element:',myList.pop())

#To remove a particular element from the lsit BY NAME
myList.remove(6)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning Confidence Score: 100%

Potential ValueError in list.remove()

I noticed we're using myList.remove(6) here. While it works for this specific example, remove() raises a ValueError if the element isn't in the list. To make this more robust, we should check if the element exists before trying to remove it.

Suggested change
myList.remove(6)
if 6 in myList:
myList.remove(6)

print('After removing \'6\':',myList)

#To insert an element at a specified Index
myList.insert(5, 6)
print('Inserting \'6\' at 5th index:',myList)

#To count number of occurences of a element in the list
print('No of Occurences of \'1\':',myList.count(1))

#To extend a list that is insert multiple elemets at once at the end of the list
myList.extend([11,0])
print('Extending list:',myList)

#To reverse a list
myList.reverse()
print('Reversed list:',myList)
16 changes: 16 additions & 0 deletions python/P04_Factorial copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#Author: OMKAR PATHAK
#This program finds the favtorial of the specified numbers
#For example, factorial of 5 = 5*4*3*2*1 = 120

def factorial(number):
'''This function finds the factorial of the number passed as argument'''
if number < 0:
print('Invalid entry! Cannot find factorial of a negative number')
Comment on lines +7 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning Confidence Score: 100%

Logic Error: Missing Return for Negative Input

I notice that when a negative number is entered, we print an error message but don't return a value. This causes the function to continue executing and eventually crash or return None incorrectly when it hits the recursive call. We should return a specific value or raise an exception to handle this case properly.

Suggested change
if number < 0:
print('Invalid entry! Cannot find factorial of a negative number')
if number < 0:
print('Invalid entry! Cannot find factorial of a negative number')
return None

if number == 0 or number == 1:
return 1
else:
return number * factorial(number - 1)

if __name__ == '__main__':
userInput = int(input('Enter the Number to find the factorial of: '))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Variable Naming Convention

The variable name 'userInput' uses camelCase, which is not the standard naming convention for Python variables. Following PEP 8, variables should use snake_case to maintain consistency across the codebase.

Suggested change
userInput = int(input('Enter the Number to find the factorial of: '))
user_input = int(input('Enter the Number to find the factorial of: '))

print(factorial(userInput))
16 changes: 16 additions & 0 deletions python/P04_Factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#Author: OMKAR PATHAK
#This program finds the favtorial of the specified numbers
#For example, factorial of 5 = 5*4*3*2*1 = 120

def factorial(number):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Forbidden Generic Parameter Name

The parameter name 'number' is explicitly listed as a forbidden generic name. Using more specific names improves code clarity and follows the defined naming standards.

Suggested change
def factorial(number):
def factorial(input_value):

'''This function finds the factorial of the number passed as argument'''
if number < 0:
print('Invalid entry! Cannot find factorial of a negative number')
Comment on lines +7 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100%

Logic Error: Missing Return for Negative Input

I notice that when a negative number is entered, we print an error message but the function continues to execute. This leads to a RecursionError because the code proceeds to the else block and attempts to calculate the factorial of an even smaller negative number indefinitely. We should return early or raise an exception to prevent this crash.

Suggested change
if number < 0:
print('Invalid entry! Cannot find factorial of a negative number')
if number < 0:
print('Invalid entry! Cannot find factorial of a negative number')
return None

if number == 0 or number == 1:
return 1
else:
return number * factorial(number - 1)

if __name__ == '__main__':
userInput = int(input('Enter the Number to find the factorial of: '))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAS Confidence Score: 100% View Citation

JAS - Just a suggestion
Inconsistent Naming Convention (camelCase in Python)

The variable 'userInput' uses camelCase, which deviates from the standard Python snake_case convention. Renaming it to 'user_input' ensures consistency with PEP 8 and project standards.

Suggested change
userInput = int(input('Enter the Number to find the factorial of: '))
user_input = int(input('Enter the Number to find the factorial of: '))

print(factorial(userInput))
112 changes: 112 additions & 0 deletions python/P05_Pattern copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#Author: OMKAR PATHAK
#This program prints various patterns

def pattern1(level):
'''This function prints the following pattern:

*
**
***
****

'''
for i in range(1, level + 1):
print()
for j in range(i):
print('*', end = '')

def pattern2(level):
'''This function prints the following pattern:

****
***
**
*

'''
for i in range(level, 0, -1):
print()
for j in range(i):
print('*', end = '')

def pattern3(level):
'''This function prints the following pattern:

*
**
***
****

'''
counter = level
for i in range(level + 1):
print(' ' * counter + '*' * i)
counter -= 1

def pattern4(level):
'''This function prints the following pattern:

****
***
**
*

'''
counter = 0
for i in range(level, 0 ,-1):
print(' ' * counter + '*' * i)
counter += 1

def pattern5(level):
'''This function prints the following pattern:

*
***
*****

'''
# first loop for number of lines
for i in range(level + 1):
#second loop for spaces
for j in range(level - i):
print (" ",end='')
# this loop is for printing stars
for k in range(2 * i - 1):
print("*", end='')
print()


if __name__ == '__main__':
userInput = int(input('Enter the level: '))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAS Confidence Score: 100% View Citation

JAS - Just a suggestion
Inconsistent Naming Convention

In Python, variable names should follow the snake_case convention. 'userInput' uses camelCase, which is inconsistent with the rest of the file and PEP 8 standards.

Suggested change
userInput = int(input('Enter the level: '))
user_input = int(input('Enter the level: '))

pattern1(userInput)
print()
pattern2(userInput)
print()
pattern3(userInput)
print()
pattern4(userInput)
print()
pattern5(userInput)
print()

def pattern6(userInput):
'''
following is the another approach to solve pattern problems with reduced time complexity

for

*
**
***
****
*****
'''

num = int(input('Enter number for pattern'))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning Confidence Score: 100%

Redundant Input Prompt in Nested Function

I noticed that pattern6 asks for user input inside the function, even though it already accepts userInput as a parameter. This makes the parameter useless and creates a confusing user experience where the program asks for the same information twice. We should use the passed parameter instead.

Suggested change
num = int(input('Enter number for pattern'))
num = userInput

pattern = '*'
string = pattern * num
x = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Non-Descriptive Variable Name

The variable name 'x' is a single-character name used for business logic. Renaming it to 'current_index' or 'substring_length' would improve code readability.

Suggested change
x = 0
substring_length = 0


for i in string:
x = x + 1
print(string[0:x])
Comment on lines +92 to +112

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAS Confidence Score: 100%

JAS - Just a suggestion
Unreachable Nested Function Definition

It looks like pattern6 is defined inside the if __name__ == '__main__': block but is never actually called. Because it's defined locally within that block, it won't be accessible elsewhere. We should move the definition to the top level with the other patterns and call it like the others.

112 changes: 112 additions & 0 deletions python/P05_Pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#Author: OMKAR PATHAK
#This program prints various patterns

def pattern1(level):
'''This function prints the following pattern:

*
**
***
****

'''
for i in range(1, level + 1):
print()
for j in range(i):
print('*', end = '')

def pattern2(level):
'''This function prints the following pattern:

****
***
**
*

'''
for i in range(level, 0, -1):
print()
for j in range(i):
print('*', end = '')

def pattern3(level):
'''This function prints the following pattern:

*
**
***
****

'''
counter = level
for i in range(level + 1):
print(' ' * counter + '*' * i)
counter -= 1

def pattern4(level):
'''This function prints the following pattern:

****
***
**
*

'''
counter = 0
for i in range(level, 0 ,-1):
print(' ' * counter + '*' * i)
counter += 1

def pattern5(level):
'''This function prints the following pattern:

*
***
*****

'''
# first loop for number of lines
for i in range(level + 1):
#second loop for spaces
for j in range(level - i):
print (" ",end='')
# this loop is for printing stars
for k in range(2 * i - 1):
print("*", end='')
print()


if __name__ == '__main__':
userInput = int(input('Enter the level: '))
pattern1(userInput)
print()
pattern2(userInput)
print()
pattern3(userInput)
print()
pattern4(userInput)
print()
pattern5(userInput)
print()

def pattern6(userInput):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAS Confidence Score: 100%

JAS - Just a suggestion
Unreachable Function Definition

It looks like pattern6 is defined inside the if __name__ == '__main__': block but is never actually called. Since it's nested inside this block, it won't be available for import by other modules either. We should move the definition outside the block and call it alongside the other patterns.

'''
following is the another approach to solve pattern problems with reduced time complexity

for

*
**
***
****
*****
'''

num = int(input('Enter number for pattern'))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning Confidence Score: 100%

Redundant Input Prompt in pattern6

I noticed that pattern6 is defined to take userInput as an argument, but then it immediately asks for input again using input(). This makes the function parameter redundant and creates a confusing user experience where they have to enter the same value twice. We should use the passed parameter instead.

Suggested change
num = int(input('Enter number for pattern'))
num = userInput

pattern = '*'
string = pattern * num
x = 0

for i in string:
x = x + 1
print(string[0:x])
18 changes: 18 additions & 0 deletions python/P06_CharCount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#Author: OMKAR PATHAK
#This program checks for the character frequency in the given string

def charFrequency(userInput):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning Confidence Score: 100% View Citation

Function Naming Convention (Case Style)

In Python, function names should follow the snake_case convention. Renaming charFrequency to char_frequency aligns with PEP 8 standards and improves consistency.

Suggested change
def charFrequency(userInput):
def char_frequency(userInput):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Variable Naming Convention (Case Style)

In Python, function parameters and local variables should follow the snake_case convention. Renaming userInput to user_input ensures compliance with language-specific standards.

Suggested change
def charFrequency(userInput):
def charFrequency(user_input):

'''This fuction helps to count the char frequency in the given string '''
userInput = userInput.lower() #covert to lowercase
dict = {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Forbidden Generic/Built-in Name

Avoid using dict as a variable name as it shadows the built-in Python dict type. This can lead to subtle bugs or confusion. Use a more descriptive name like char_counts.

Suggested change
dict = {}
char_counts = {}

for char in userInput:
if char in dict:
if char in keys:
Comment on lines +9 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100%

Logic Error: Undefined Variable 'keys'

While the inefficient .keys() call was removed, the following line still references the variable keys, which is no longer defined. This will result in a NameError when the code executes.

Suggested change
if char in dict:
if char in keys:
if char in dict:

dict[char] += 1
else:
dict[char] = 1
return dict

if __name__ == '__main__':
userInput = str(input('Enter a string: '))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Confidence Score: 100% View Citation

Variable Naming Convention (Case Style)

Variable names in Python should use snake_case. Renaming userInput to user_input follows the standard naming convention for the language.

Suggested change
userInput = str(input('Enter a string: '))
user_input = str(input('Enter a string: '))

print(charFrequency(userInput))
Loading