diff --git a/07_Practice.py b/07_Practice.py index 734c931..cc73d96 100644 --- a/07_Practice.py +++ b/07_Practice.py @@ -6,7 +6,7 @@ # Print squares of numbers from 1 to n n = int(input("Enter a number:")) -for i in range(1,n): +for i in range(1,n+1): print(i**2) diff --git a/09_Global_local.py b/09_Global_local.py index d333112..55013f8 100644 --- a/09_Global_local.py +++ b/09_Global_local.py @@ -4,7 +4,7 @@ def greet(): print(msg) greet() - +"""print("Outside:", msg)""" # This will raise an error since msg is not defined outside the function # global variables msg = "Hello" @@ -16,11 +16,11 @@ def greet_global(): def fun(): - print("Inside Function", s) + print("Inside Function: ", s) s = "I love Geeksforgeeks" fun() -print("Outside Function", s) +print("Outside Function: ", s) # Modifying Global Variables Inside a Function @@ -30,4 +30,4 @@ def fun(): print(s) s = "I love Geeksforgeeks " fun() -print("Outside Function", s) +print("Outside Function: ", s) diff --git a/14_Decorators.py b/14_Decorators.py index 6af1d83..798014c 100644 --- a/14_Decorators.py +++ b/14_Decorators.py @@ -40,7 +40,8 @@ def square(x): -# Types of Decorators +"""Types of Decorators""" + # 1. Function Decorators # Function decorators are used to modify or enhance the behavior of functions. def simple_decorator(func): @@ -86,7 +87,7 @@ def say_hello(self): obj.say_hello() -# Common Built-in Decorators in Python +"""Common Built-in Decorators in Python""" # @staticmethod class MathOperations: @staticmethod diff --git a/15_Strings.py b/15_Strings.py index 11a963b..d333903 100644 --- a/15_Strings.py +++ b/15_Strings.py @@ -16,7 +16,7 @@ print(str4.strip()) # Remove leading and trailing spaces print(str3.replace("Venkateswara", "College")) # Replace substring print(str3.split()) # Split into a list of words -print(str3.find("a")) # Find the index of a substring +print(str3.find("a")) # Find the first occurence index of a substring print(str3.index("Venkateswara")) # Find the index of a substring (raises error if not found) print(str3.count("a")) # Count occurrences of a character print(str3.startswith("Ven")) # Check if string starts with a substring