r/learnpython • u/shadow_banshee • Nov 14 '21
URGENT: need to learn python ASAP
Hi all. I used to know some python a couple years ago and don’t remember too much of it. I stupidly volunteered to help a cute girl with coding for her class and now she’s needing help with it. Can someone teach me how to do good python stuff in the next 2 days. I understand for loops and while loops and printing strings and Booleans. Are there any other major things I need to know??? Thank you in advance. I just don’t wanna look stupid in front of her cuz I really like her and want to be helpful.
0
Upvotes
3
u/Ill_Be_Alright Nov 14 '21
Graphing can be pretty nice. If you know how to use the append command “listName.append(variable)”, u can use the following code to fairly easily create a graph of something:
•import matplotlib.pyplot as plt •fig, ax = plt.subplots() •ax.plot(xVariable, yVariable)
There are plenty other bells and whistles, such as changing the range of that graph, or adding a legend to it:
•ax.plot(xVariable, yVariable, label=“equation”) •fig.legend(loc = “lower left”)
That code will graph it, and then put a legend in the lower left that has the “equation” labeled. Other bells and whistles below:
•ax.scatter(xVar, yVar) #creates a scatter plot instead
•ax.plot(x, y, linestyle=“dashed”, color=“magenta”) #plots it as a dashed magenta line. A list of colors and line styles can simply be googled