You are on page 1of 3

Welcome to my work sample:

I’m Hamid Ali and I worked a lot in debugging in python if you’re having any issue with your code
then you’re in right place so feel free to contact me I will do my 100% to complete your work and
gain your respect.

Here are some sample of my work.


Python Debugging Libraries: Some Python libraries, such as "ipdb" or "pdb", offer interactive
debugging capabilities.

import ipdb

def divide_numbers(a, b):

result = a / b

return result

def main():

try:

x = 10

y=0

result = divide_numbers(x, y)

print("Result:", result)

except Exception as e:

ipdb.set_trace() # Set a breakpoint at this line

print("Error:", e)

if __name__ == "__main__":

main()

When you run this code, it will raise a ZeroDivisionError, and the program will enter the interactive
debugging mode provided by "ipdb". You'll see a prompt like "(ipdb)" where you can use various
commands to inspect the program's state, step through the code, and find the cause of the error.

Here are some useful commands you can use in "ipdb" interactive debugging mode:
 's': Step into the next line of code.

 'n': Execute the current line and move to the next line.

 'c': Continue execution until the next breakpoint.

 'p variable': Print the value of a specific variable.

 'q': Quit the debugging session.

Here is one big Project I solve in debugging.


import pandas as pd

# Create a sample DataFrame

data = {

'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Emma'],

'Age': [25, 30, 22, 27, 29],

'City': ['New York', 'London', 'Paris', 'Tokyo', 'Sydney']

df = pd.DataFrame(data)

# Display the DataFrame

print("Original DataFrame:")

print(df)

# Filter the DataFrame based on a condition

filtered_df = df[df['Age'] > 25]

# Display the filtered DataFrame

print("\nFiltered DataFrame (Age > 25):")

print(filtered_df)

# Sort the DataFrame by Age in descending order

sorted_df = df.sort_values(by='Age', ascending=False)


# Display the sorted DataFrame

print("\nSorted DataFrame by Age:")

print(sorted_df)

# Group the DataFrame by City and calculate the average age for each city

grouped_df = df.groupby('City')['Age'].mean()

# Display the grouped DataFrame

print("\nGrouped DataFrame (Average Age per City):")

print(grouped_df)

This code imports pandas, creates a DataFrame from a dictionary, filters, sorts, and groups the data
using various pandas functions. The power of pandas lies in its ability to efficiently handle and
manipulate large datasets using a concise and expressive syntax.

Note:

The more you want sample then dm me in here or LinkedIn.

You might also like