Code in Python
Hello I need an os module to restart and re-run the whole code when the multiplier limit is reached. So when the code stops the outputs I need it to initialize again.
import os, sys
initial=int(input("Initial value :
")) #taking inputs
multiplier=float(input("Multiplier : "))
compound=int(input("No of compounds : "))
print("Your values are:")
mult=initial
#initalizing to find answer
for i in
range(0,compound):
#multiplying by multiplier
print(round(mult,1))
mult=mult*multiplier
#! /bin/env python3
import os, sys
def initilize():
global compound,mult,initial,multiplier
initial=int(input("Initial value : ")) #taking inputs
multiplier=float(input("Multiplier : "))
compound=int(input("No of compounds : "))
print("Your values are:")
mult=initial #initalizing to find answer
if __name__ == '__main__':
initilize()
for i in range(0,compound): #multiplying by multiplier
print(round(mult,1))
mult=mult*multiplier
os.execv(__file__, sys.argv)
#for restart the program you need to give permission using the given command:
#chmod a+x file_name.py
#because of os security
Get Answers For Free
Most questions answered within 1 hours.