20 Creative Ways to Harness ChatGPT: From Code Fixes to Storytelling

This article compiles a wide range of practical ChatGPT applications—including grammar correction, translation, code explanation, error fixing, creative generation, and more—illustrated with descriptions, code snippets, and images to help users explore the model's versatile capabilities.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
20 Creative Ways to Harness ChatGPT: From Code Fixes to Storytelling

Are you sure you know how to use ChatGPT? This article compiles several practical applications of ChatGPT, ranging from grammar correction to code explanation, error fixing, and creative generation.

Grammar correction

Text translation

Language conversion

Code explanation

Fix code errors

Encyclopedia

Information extraction

Friend chat

Creative generator

Interview questions

Paper outline

Story creation

Question analogy

Create SQL requirement

Sentiment analysis

Transform product description into advertisement

Keyword extraction

Chatbot

Grammar correction

Purpose: polishing articles, papers, etc.

Text translation

Purpose: daily learning, business translation, etc.

Language conversion

Python → JAVA

Purpose: facilitating collaboration between engineers using different languages.

import numpy as np<br/>import plotly.express as px<br/><br/>def thresholding_algo(y, lag, threshold):<br/>    """<br/>    :param y: 输入列表<br/>    :param lag: 滑动窗口大小<br/>    :param threshold: 调节系数,用于调节容忍范围的大小。<br/>    :return:<br/>    """<br/>    # signals:信号列表<br/>    signals = np.zeros(len(y))<br/>    avgFilter = np.zeros(len(y))<br/><br/>    # 初始化平均值列表、差值列表<br/>    avgFilter[lag - 1] = np.mean(y[0:lag])<br/>    dif_li = [0] * len(y)<br/><br/>    for i in range(lag, len(y)):<br/>        if i < len(y) - lag - 30:<br/>            for j in range(i + 11, len(y)):<br/>                if y[j] >= y[i - 1]:<br/>                    break<br/>            if j >= len(y) - 30:<br/>                back = y[i - 1]<br/>            else:<br/>                back = np.mean(y[j + 11:j + 20 + lag])<br/>        else:<br/>            back = y[i - 1]<br/><br/>        # 前后均值差值计算<br/>        tmp = abs(back - avgFilter[i - 1])<br/>        dif = (tmp if tmp > 1 else 1)<br/><br/>        if abs(y[i] - avgFilter[i - 1]) > dif * threshold:<br/>            signals[i] = (1 if y[i] > avgFilter[i - 1] else -1)<br/>            avgFilter[i] = np.mean(y[(i - lag):i])<br/>            y[i] = avgFilter[i - 1]<br/>        else:<br/>            signals[i] = 0<br/>            avgFilter[i] = np.mean(y[(i - lag):i])<br/><br/>        dif_li[i] = dif<br/><br/>    return dict(signals=np.asarray(signals), avgFilter=np.asarray(avgFilter), y=np.asarray(y), dif=np.asarray(dif_li), )
public static Map<String, double[]> thresholding_algo(double[] y, int lag, double threshold) {<br/><br/>    double[] signals = new double[y.length];<br/>    double[] avgFilter = new double[y.length];<br/>    Arrays.fill(avgFilter, 0.0);<br/><br/>    avgFilter[lag - 1] = mean(Arrays.copyOfRange(y, 0, lag));<br/>    double[] dif_li = new double[y.length];<br/>    Arrays.fill(dif_li, 0.0);<br/><br/>    for (int i = lag; i < y.length; i++) {<br/>        int j;<br/>        if (i < y.length - lag - 30) {<br/>            for (j = i + 11; j < y.length; j++) {<br/>                if (y[j] >= y[i - 1]) {<br/>                    break;<br/>                }<br/>            }<br/>            double back;<br/>            if (j >= y.length - 30) {<br/>                back = y[i - 1];<br/>            } else {<br/>                back = mean(Arrays.copyOfRange(y, j + 11, j + 20 + lag));<br/>            }<br/>        } else {<br/>            back = y[i - 1];<br/>        }<br/><br/>        double tmp = Math.abs(back - avgFilter[i - 1]);<br/>        double dif = tmp > 1 ? tmp : 1;<br/><br/>        if (Math.abs(y[i] - avgFilter[i - 1]) > dif * threshold) {<br/>            signals[i] = y[i] > avgFilter[i - 1] ? 1 : -1;<br/>            avgFilter[i] = mean(Arrays.copyOfRange(y, i - lag, i));<br/>            y[i] = avgFilter[i - 1];<br/>        } else {<br/>            signals[i] = 0;<br/>            avgFilter[i] = mean(Arrays.copyOfRange(y, i - lag, i));<br/>        }<br/><br/>        dif_li[i] = dif;<br/>    }<br/><br/>    Map<String, double[]> result = new HashMap<>();<br/>    result.put("signals", signals);<br/>    result.put("avgFilter", avgFilter);<br/>    result.put("y", y);<br/>    result.put("dif", dif_li);<br/><br/>    return result;<br/>}<br/><br/>private static double mean(double[] array) {<br/>    double sum = 0.0;<br/>    for (double d : array) {<br/>        sum += d;<br/>    }<br/>    return sum / array.length;<br/>}

Code explanation-1

Purpose: when we join a new company and encounter incomprehensible code left by a predecessor, having someone explain the code is extremely helpful.

def Fusion_algorithm(y_list):<br/>    """<br/>    最终的融合算法<br/>    1、第一次遍历列表: 处理掉小于上一个值的点,使其等于上一个值。<br/>    2、第二次使用z-score来处理异常点:一种基于统计方法的时序异常检测算法借鉴了一些经典的统计方法,比如Z-score和移动平均线<br/>    该算法将时间序列中的每个数据点都看作是来自一个正态分布,通过计算每个数据点与其临接数据点的平均值和标准差,可以获得Z-score<br/>    并将其用于检测异常值,将z-score大于3的数据点视为异常值,缺点:如果异常点太多,则该算法的准确性较差。<br/>    3、<br/>    :param y_list: 传入需要处理的时间序列<br/>    :return:<br/>    """<br/>    # 第一次处理<br/>    for i in range(1, len(y_list)):<br/>        difference = y_list[i] - y_list[i - 1]<br/>        if difference <= 0:<br/>            y_list[i] = y_list[i - 1]<br/>    # 第二次处理<br/>    ma = np.mean(y_list)<br/>    std = np.std(y_list)<br/>    z_score = [(x - ma) / std for x in y_list]<br/>    for i in range(len(y_list)):<br/>        if z_score[i] > 3:<br/>            print(y_list[i])<br/>            y_list[i] = y_list[i - 1]<br/>    return y_list

Code explanation-2

Note: the previous explanation may have been affected by comments; remove the comments and try again. You can ask follow‑up questions about any unclear points.

import numpy as np<br/>from sklearn.ensemble import IsolationForest<br/>import plotly.express as px<br/>import matplotlib.pyplot as plt<br/>from sklearn.cluster import KMeans<br/>import json<br/><br/>def Fusion_algorithm(y_list):<br/>    for i in range(1, len(y_list)):<br/>        difference = y_list[i] - y_list[i - 1]<br/>        if difference <= 0:<br/>            y_list[i] = y_list[i - 1]<br/>    ma = np.mean(y_list)<br/>    std = np.std(y_list)<br/>    z_score = [(x - ma) / std for x in y_list]<br/>    for i in range(len(y_list)):<br/>        if z_score[i] > 3:<br/>            print(y_list[i])<br/>            y_list[i] = y_list[i - 1]<br/>    return y_list

Fix code errors

Purpose: after writing a piece of code, discover errors? Let ChatGPT help you!

### Buggy Python<br/>import Random<br/>a = random.randint(1,12)<br/>b = random.randint(1,12)<br/>for i in range(10):<br/>    question = "What is " + a + " x " + b + "? "<br/>    answer = input(question)<br/>    if answer = a*b<br/>        print (Well done!)<br/>    else:<br/>        print("No.")

Encyclopedia

Purpose: ChatGPT can answer all your questions! However, its novel generation works best for sci‑fi; other genres are less reliable, perhaps because the training engineers love sci‑fi.

Information extraction

Purpose: as a large‑model NLP tool, information extraction is indispensable.

Friend chat

Purpose: simulate a conversation based on the other person's personality; the feature is not fully refined yet, and there may be fresh uses to explore.

Creative generator

Purpose: when you hit a creative block, let ChatGPT generate ideas for you!

VR and escape rooms

Combine with AR

Interview questions

Purpose: media professionals can obtain interview question lists and answers from ChatGPT.

Interview question list

Interview questions with answers

Paper outline

Purpose: this feature is a lifesaver for graduate students struggling with outlines; it can generate outlines, explain unclear points, and even provide code snippets.

Create paper outline

Explain outline content

class PBA(nn.Module):<br/>    def __init__(self, PerformanceThreshold, DistributionType, AttentionWeightRange):<br/>        super(PBA, self).__init__()<br/>        self.PerformanceThreshold = PerformanceThreshold<br/>        self.DistributionType = DistributionType<br/>        self.AttentionWeightRange = AttentionWeightRange<br/><br/>    def forward(self, input, performance_scores):<br/>        # compute attention scores<br/>        attention_scores = []<br/>        for i in range(len(input)):<br/>            if performance_scores[i] > self.PerformanceThreshold:<br/>                attention_scores.append(performance_scores[i])<br/>            else:<br/>                attention_scores.append(0.0)<br/><br/>        # map performance scores to attention weights<br/>        if self.DistributionType == "softmax":<br/>            attention_weights = F.softmax(torch.tensor(attention_scores), dim=0)<br/>        elif self.DistributionType == "sigmoid":<br/>            attention_weights = torch.sigmoid(torch.tensor(attention_scores))<br/>        else:<br/>            raise ValueError("Unknown distribution type: {}".format(self.DistributionType))<br/><br/>        # scale attention weights to the specified range<br/>        attention_weights = attention_weights * (self.AttentionWeightRange[1] - self.AttentionWeightRange[0]) + self.AttentionWeightRange[0]<br/><br/>        # compute weighted input<br/>        weighted_input = torch.mul(input, attention_weights.unsqueeze(1).expand_as(input))<br/>        output = torch.sum(weighted_input, dim=0)<br/><br/>        return output

Story creation

Purpose: this feature is amazing; after outlining, ChatGPT can write a novel for you!

Love story

Horror story

Question analogy

Purpose: when you want to make a metaphor, this function is very handy.

Create SQL requirement

Purpose: writing SQL can be a headache; this helps you generate SQL quickly.

Sentiment analysis

Purpose: this feature reminds me of the sentiment analysis tasks I performed at my previous company.

Transform product description into advertisement

Purpose: this feature is fantastic for merchants.

Keyword extraction

Purpose: an important NLP task.

Chatbot

Purpose: a simple chat experience that feels quite pleasant.

Summary

I think role‑playing is interesting; prepend dialogues with “Imagine you are xxx”.

There are now some mini‑programs that let AI play roles in conversations, implemented using this method.

prompt engineeringChatGPTtranslationCode debuggingcreative writing
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.