Example:
Provide a brief description of an interpreted programming language.
Usage:
Utilize the LLM to elucidate high-level programming concepts, terminologies, and the roles of various components in a programming environment. This approach is ideal for establishing a clear conceptual foundation.
Example 1:
Explain the rules for naming variables in Python.
Example 2:
Describe how comments are used in Python and provide common examples.
Usage:
Leverage the LLM to clarify language-specific syntax and rules, ensuring a solid understanding of the fundamental elements and nuances that govern programming language structure.
Example 1:
Explain and fix the following error:
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
Cell In [34], line 1
----> 1 5/0
ZeroDivisionError: division by zero
Example 2:
Debug the following program:
print(5 + )
Usage:
Employ the LLM to diagnose errors by interpreting error messages and suggesting corrections, thereby enhancing code functionality and reliability.
Example:
Provide a detailed explanation of the following code snippet:
%%writefile hello.py
"""
This program says hello and asks for your name.
It also asks for your age.
"""
print('Hello, world!')
myName = input('What is your name? ') # ask for their name
print('It is good to meet you, ' + myName)
print('The length of your name is:\n' + str(len(myName)))
myAge = input('What is your age? ') # ask for their age
print('You will be ' + str(int(myAge) + 1) + ' in a year.')
Usage:
Request a comprehensive, step-by-step breakdown of the code to understand its logic, control flow, and purpose behind each component.
Example:
Add detailed comments to the following code to explain its functionality:
%%writefile hello.py
print('Hello, world!')
myName = input('What is your name? ')
print('It is good to meet you, ' + myName)
print('The length of your name is:\n' + str(len(myName)))
myAge = input('What is your age? ') # ask for their age
print('You will be ' + str(int(myAge) + 1) + ' in a year.')
Usage:
Enhance code clarity by inserting meaningful annotations. These comments can assist other developers in understanding the code and serve as a useful reference for future revisions.
Challenge 1:
Write a script that accepts a five-digit integer from the user, separates it into its individual digits, and prints each digit with three spaces in between.
Hint: Use floor division (//
) and modulus (%
) operations to isolate each digit.
Challenge 2:
Implement a Python function that removes all punctuation from a given string.
Usage:
Engage with coding challenges that test practical application skills, algorithm development, and problem-solving, reinforcing the ability to translate conceptual understanding into working code.
Original Code:
from math import log2
count_new = 0
count_york = 0
count_new_york = 0
for i, tok in enumerate(tokens):
if tok == "new":
count_new += 1
try:
next_tok = tokens[i+1]
if next_tok == "york":
count_new_york += 1
except IndexError:
pass
if tok == "york":
count_york += 1
p_new = count_new / len(tokens)
p_york = count_york / len(tokens)
p_new_york = count_new_york / len(tokens)
pmi = log2(p_new_york / (p_new * p_york))
print("p_new =", p_new)
print("p_york =", p_york)
print("p_new_york =", p_new_york)
print("pmi =", pmi)
Task:
Improve the above code by enhancing readability, implementing robust error handling, and optimizing performance.
Usage:
Utilize the LLM to suggest refactoring strategies that promote better code structure and efficiency, ensuring the code is more maintainable and less prone to runtime issues.
Example:
Design an efficient algorithm for sorting a large dataset and provide an explanation of its time complexity.
Usage:
Consult the LLM to assist with algorithm design, complexity analysis, and the selection of appropriate data structures for solving complex problems.
Example:
Optimize the following function to reduce its runtime for large inputs:
def calculate_sum(n):
total = 0
for i in range(n):
total += i
return total
Usage:
Request performance improvements and optimization techniques from the LLM to enhance resource utilization and speed, particularly for handling large-scale inputs.
Example:
Provide suggestions to improve coding style and adherence to best practices for the following code snippet.
Usage:
Improve code maintainability and readability by aligning with industry-standard practices and style guidelines, ensuring the code is clean and professional.
Example:
Demonstrate how to integrate the SymPy library to perform symbolic integration.
Usage:
Learn how to effectively integrate and utilize third-party libraries and APIs within your projects, expanding your toolkit for solving complex computational tasks.