From 2f2150be6cc5a4852df6f1f6d1be323ad51c322b Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Tue, 3 Feb 2026 21:22:40 +0530 Subject: [PATCH 1/7] Commit changes --- Programs/P02_VariableScope.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Programs/P02_VariableScope.py b/Programs/P02_VariableScope.py index 6286822..505eb22 100644 --- a/Programs/P02_VariableScope.py +++ b/Programs/P02_VariableScope.py @@ -3,13 +3,13 @@ # LEGB Rule: Local, Enclosing, Global, Built-in -x = 'Global x' +x = 80 # Global x def test(): #global x - y = 'Local y' - x = 'Local x' - print(x +', '+ y) #prints 'Local x' and 'Local y' + y = 100 # Local y + x = 20 + print(x + y) #prints 'Local x' and 'Local y' if __name__ == '__main__': test() From b4d632c4e677789e38b099c54cc0287561feceb8 Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Wed, 4 Feb 2026 13:48:43 +0530 Subject: [PATCH 2/7] Commit changes --- Programs/P01_hello.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Programs/P01_hello.py b/Programs/P01_hello.py index 6d8ff9a..d6bdcfa 100644 --- a/Programs/P01_hello.py +++ b/Programs/P01_hello.py @@ -12,7 +12,7 @@ def justPrint(text): floor_division = increment_value // base_value # // -> integer division print("Floor Division:", floor_division) - print("Difference is:", increment_value - base_value) + # 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 From 5f686e5d0ec1b9b241b60151cfd92a1b0467fcf2 Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Wed, 4 Feb 2026 14:07:31 +0530 Subject: [PATCH 3/7] Commit changes --- Programs/P01_hello.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Programs/P01_hello.py b/Programs/P01_hello.py index d6bdcfa..b0f3dac 100644 --- a/Programs/P01_hello.py +++ b/Programs/P01_hello.py @@ -16,6 +16,7 @@ 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:', base_value + increment_value) if __name__ == '__main__': justPrint('Hello Sindhuja') From 1aa50ef8c5e729fd3da3886af6b4fe2a52a27e48 Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Wed, 4 Feb 2026 14:22:08 +0530 Subject: [PATCH 4/7] Commit changes --- Programs/P01_hello.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Programs/P01_hello.py b/Programs/P01_hello.py index b0f3dac..38f65c8 100644 --- a/Programs/P01_hello.py +++ b/Programs/P01_hello.py @@ -16,7 +16,7 @@ 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:', base_value + increment_value) + print('Addition is:', base_value + increment_value) if __name__ == '__main__': justPrint('Hello Sindhuja') From 0b0ca83c5a1738ff6994e299adf284a9da82c9f1 Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Wed, 4 Feb 2026 14:29:55 +0530 Subject: [PATCH 5/7] Commit changes --- Programs/P01_hello.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Programs/P01_hello.py b/Programs/P01_hello.py index 38f65c8..2bab912 100644 --- a/Programs/P01_hello.py +++ b/Programs/P01_hello.py @@ -4,6 +4,8 @@ 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 @@ -16,7 +18,7 @@ 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:', base_value + increment_value) + print('Addition is:', int(a) + int(b)) if __name__ == '__main__': justPrint('Hello Sindhuja') From 1696203bb686103d28f86746d4a5e0fee9fc02e6 Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Wed, 4 Feb 2026 23:04:20 +0530 Subject: [PATCH 6/7] List operations --- Programs/P03_ListsOperations.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Programs/P03_ListsOperations.py b/Programs/P03_ListsOperations.py index f2d5dfc..53c5d13 100644 --- a/Programs/P03_ListsOperations.py +++ b/Programs/P03_ListsOperations.py @@ -1,5 +1,6 @@ #Author: OMKAR PATHAK #This program gives examples about various list operations +# User story id : Prod - PYTH-003 #Syntax: list[start: end: step] From dde091ce2795bfae8f647b743503204619cc03d5 Mon Sep 17 00:00:00 2001 From: Sindhuja-G Date: Wed, 4 Feb 2026 23:12:12 +0530 Subject: [PATCH 7/7] List operations --- Programs/listoperations.py | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Programs/listoperations.py diff --git a/Programs/listoperations.py b/Programs/listoperations.py new file mode 100644 index 0000000..53c5d13 --- /dev/null +++ b/Programs/listoperations.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)