From d4101a3335939ace7743af8f50b5a89d6d123a59 Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Fri, 6 Feb 2026 13:32:19 +0530 Subject: [PATCH 1/2] PR chenges --- Test/P01_hello.py | 28 +++++++++ Test/P02_VariableScope.py | 16 ++++++ Test/P03_ListsOperations.py | 48 ++++++++++++++++ Test/P04_Factorial.py | 17 ++++++ Test/P05_Pattern.py | 112 ++++++++++++++++++++++++++++++++++++ Test/P06_CharCount.py | 18 ++++++ Test/P07_PrimeNumber.py | 23 ++++++++ Test/login.py | 35 +++++++++++ 8 files changed, 297 insertions(+) create mode 100644 Test/P01_hello.py create mode 100644 Test/P02_VariableScope.py create mode 100644 Test/P03_ListsOperations.py create mode 100644 Test/P04_Factorial.py create mode 100644 Test/P05_Pattern.py create mode 100644 Test/P06_CharCount.py create mode 100644 Test/P07_PrimeNumber.py create mode 100644 Test/login.py diff --git a/Test/P01_hello.py b/Test/P01_hello.py new file mode 100644 index 0000000..2bab912 --- /dev/null +++ b/Test/P01_hello.py @@ -0,0 +1,28 @@ +# 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) + a=input("Enter a number: ") + b=input("Enter another number: ") + base_value = 10 + increment_value=20 + difference = increment_value - base_value + divide_value = increment_value / base_value + multiply_value = increment_value * base_value + floor_division = increment_value // base_value # // -> integer division + + print("Floor Division:", floor_division) + # print("Difference is:", increment_value - base_value) + print("Divide value is:", divide_value) + print("Multiply value is:", multiply_value) + print("Modulus:", increment_value % base_value ) # % -> remainder + print('Addition is:', int(a) + int(b)) + +if __name__ == '__main__': + justPrint('Hello Sindhuja') + justPrint('Hello Sindhuja') + justPrint('Hello Sindhuja') + + diff --git a/Test/P02_VariableScope.py b/Test/P02_VariableScope.py new file mode 100644 index 0000000..505eb22 --- /dev/null +++ b/Test/P02_VariableScope.py @@ -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 + +def test(): + #global x + y = 100 # Local y + x = 20 + print(x + y) #prints 'Local x' and 'Local y' + +if __name__ == '__main__': + test() + print(x) #prints 'Global x' diff --git a/Test/P03_ListsOperations.py b/Test/P03_ListsOperations.py new file mode 100644 index 0000000..53c5d13 --- /dev/null +++ b/Test/P03_ListsOperations.py @@ -0,0 +1,48 @@ +#Author: OMKAR PATHAK +#This program gives examples about various list operations +# User story id : Prod - PYTH-003 + +#Syntax: list[start: end: step] + +myList = [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) +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) diff --git a/Test/P04_Factorial.py b/Test/P04_Factorial.py new file mode 100644 index 0000000..f5262c3 --- /dev/null +++ b/Test/P04_Factorial.py @@ -0,0 +1,17 @@ +#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') + if number == 0 or number == 1: + print("Hello") + return 1 + else: + return number * factorial(number - 1) + +if __name__ == '__main__': + userInput = int(input('Enter the Number to find the factorial of: ')) + print(factorial(userInput)) diff --git a/Test/P05_Pattern.py b/Test/P05_Pattern.py new file mode 100644 index 0000000..db988a0 --- /dev/null +++ b/Test/P05_Pattern.py @@ -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): + ''' + following is the another approach to solve pattern problems with reduced time complexity + + for + + * + ** + *** + **** + ***** + ''' + + num = int(input('Enter number for pattern')) + pattern = '*' + string = pattern * num + x = 0 + + for i in string: + x = x + 1 + print(string[0:x]) diff --git a/Test/P06_CharCount.py b/Test/P06_CharCount.py new file mode 100644 index 0000000..ae13486 --- /dev/null +++ b/Test/P06_CharCount.py @@ -0,0 +1,18 @@ +#Author: OMKAR PATHAK +#This program checks for the character frequency in the given string + +def charFrequency(userInput): + '''This fuction helps to count the char frequency in the given string ''' + userInput = userInput.lower() #covert to lowercase + dict = {} + for char in userInput: + keys = dict.keys() + if char in keys: + dict[char] += 1 + else: + dict[char] = 1 + return dict + +if __name__ == '__main__': + userInput = str(input('Enter a string: ')) + print(charFrequency(userInput)) diff --git a/Test/P07_PrimeNumber.py b/Test/P07_PrimeNumber.py new file mode 100644 index 0000000..485de60 --- /dev/null +++ b/Test/P07_PrimeNumber.py @@ -0,0 +1,23 @@ +#Author: OMKAR PATHAK +#This program checks whether the entered number is prime or not + +def checkPrime(number): + '''This function checks for prime number''' + isPrime = False + if number == 2: + print(number, 'is a Prime Number') + if number > 1: + for i in range(2, number): + if number % i == 0: + print(number, 'is not a Prime Number') + isPrime = False + break + else: + isPrime = True + + if isPrime: + print(number, 'is a Prime Number') + +if __name__ == '__main__': + userInput = int(input('Enter a number to check: ')) + checkPrime(userInput) diff --git a/Test/login.py b/Test/login.py new file mode 100644 index 0000000..fb9e10c --- /dev/null +++ b/Test/login.py @@ -0,0 +1,35 @@ +class LoginSystem: + def __init__(self): + self.valid_email = os.getenv("VALID_EMAIL") + self.valid_password = os.getenv("VALID_PASSWORD") + self.failed_attempts = 0 + self.locked = False + + def login(self, email, password): + if self.locked: + return "Account is locked. Contact support." + + if email == self.valid_email and password == self.valid_password: + self.failed_attempts = 0 + return "Login Successful ✅" + + else: + self.failed_attempts += 1 + + if self.failed_attempts >= 3: + self.locked = True + return "Account locked due to 3 failed attempts ❌" + + return f"Invalid credentials. Attempts left: {3 - self.failed_attempts}" + +# ----- Testing the function ----- + +app = LoginSystem() + +print(app.login("wrong@test.com", "123")) # Test case 1 +print(app.login("wrong@test.com", "123")) # Test case 2 +print(app.login("wrong@test.com", "123")) # Test case 3 (locks account) +print(app.login("user@test.com", "Password@123")) # Should fail because account is locked +print("TC4:", app.login("wrong@test.com", "123")) # This will now lock +print("TC5:", app.login("user@test.com", "Password@123")) # Locked account case +print("TC6:", app.login("user@test.com", "Password@123")) # Locked account case From 690b3c0d7988bd95149a71fb7ccc5f55a05e24a3 Mon Sep 17 00:00:00 2001 From: Sindhuja Golagani Date: Fri, 6 Feb 2026 13:54:51 +0530 Subject: [PATCH 2/2] Update Test/P01_hello.py add print statement Co-authored-by: appmod-pr-genie[bot] <229331807+appmod-pr-genie[bot]@users.noreply.github.com> --- Test/P01_hello.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Test/P01_hello.py b/Test/P01_hello.py index 2bab912..7fc6319 100644 --- a/Test/P01_hello.py +++ b/Test/P01_hello.py @@ -18,7 +18,10 @@ def justPrint(text): print("Divide value is:", divide_value) print("Multiply value is:", multiply_value) print("Modulus:", increment_value % base_value ) # % -> remainder - print('Addition is:', int(a) + int(b)) + try: + print('Addition is:', int(a) + int(b)) + except ValueError: + print('Error: Please enter valid numeric values.') if __name__ == '__main__': justPrint('Hello Sindhuja')