Skip to content
Merged
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
2 changes: 1 addition & 1 deletion 07_Practice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
8 changes: 4 additions & 4 deletions 09_Global_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -30,4 +30,4 @@ def fun():
print(s)
s = "I love Geeksforgeeks "
fun()
print("Outside Function", s)
print("Outside Function: ", s)
5 changes: 3 additions & 2 deletions 14_Decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 15_Strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down