im a beginner. I know the pythons alphabet. I need help for getting project of people.
I worked pygame only. I am scared about when a person give me project what should I do. which libraries I need to import .and what codes should I use .pls help me about it.
do u know what I’m saying? ((like if I wanna write a calculator witch libraries should I import and how should I know this and write it? ))
>Solution :
Well, what you need to import is highly dependent on what you’re trying to do. For example, if you want to make something with a gui, import tkinter. Or for something a little more your level, considering you’re new, you could make a program that generates 1 random number a second 5 times. This would require you to import random and time. It would look something like this:
import random
import time
for i in range(5):
print(random.randint(0, 100))
time.sleep(1)
where random.randint is using the function randint from the random library, 0 is the minimum number, and 100 is the max. time.sleep uses the sleep function from the time library, 1 is the amount of time in seconds the program should stop for. Range tells the for loop how many times it should loop through the designated code.