Note that there are some explanatory texts on larger screens.

plurals
  1. POClear the data python uses?
    primarykey
    data
    text
    <p>I just made a program that takes user input in the form of a float and converts the number from MM to inches. I recently noticed that when I run the program the more the program loops (takes user input) The more memory the program starts to use up. How can I make it so that it doesn't use more memory every time it takes user input? I should add that I am very new to programming, python is the first language I started teaching myself, I'm not using books other than the Python documentation, and I am mostly just going through other peoples source code and running it/editing it to figure out whats doing what. This is the first program I wrote on my own. And I have only been teaching myself Python for a little under 3 weeks Here's the code</p> <pre><code>Inches = float(25.4) Surface_Inches = "**********Surface in Inches**********" Enter_Number = "**********Enter Number in MM**********" Final_Number = "**********Number in Inches**********" WTF = "Sorry I could not recognize that, please try again" keep_running = True help = """ Commands: type (exit, quit, end, or kill) to exit the program type RA to enter Surface finish conversion If you are in Surface conversion mode you must enter Ra number in MM that needs converted to Inches. """ import time import math import os print("Welcome to the converter") time.sleep(.75) print("I can convert units of measurement from MM to Inches") time.sleep(.75) while keep_running: print("Enter Number or type RA for Surface conversion") print(Enter_Number) number = (input()) if number in('end', 'quit', 'exit', 'kill'): break elif number in('clear'): os.system('CLS') elif number in('help'): print(help) elif number in('Ra', 'RA', 'ra', 'rA', 'Surface', 'Finish'): print("Enter the Surface Finish in MM") Surface = (input()) if Surface in('help'): print(" ") print(help) print(" ") else: try: Surface_Finish = float(Surface) except ValueError: print(WTF) else: Surface_IN_Finish = Surface_Finish/Inches Answer = (float(Surface_IN_Finish *1000)) if Answer &lt; 1 : #if the converted results is less than 1 the answers 1 Answer = 1 print(Surface_Inches) print(" ") print('\t', " %.0f" % Answer) print(" ") print(Surface_Inches) else: try: MM = float(number) except ValueError: #checks to see if the user input is a number time.sleep(0.5) print(WTF) else: Results = float(MM \ Inches) Final_Form = ("%.3f%" % Results) #creates a float that goes to 3 decimal places print(Final_Number) print(" ") print('\t', " ", Final_form) print(" ") print(Final_Number) from tkinter import Tk #Imports the Tk Module final_form2 = (str(final_form)) r = Tk() r.withdraw() # I have no idea what this does r.clipboard_clear() r.clipboard_append(final_form2) #appends final_form2 to clipboard </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload