Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

python _ what should I import for calculator

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading