In Python...
To automatically shut down the machine for 5 seconds then restart it, if the temperature reaches 100 degrees or more. Write a program that reads in the temp_readings.txt file.
It should read each temperature and display it. If the temperature is greater than 100 degrees it should display "Shutting down the machine", then it should display "Cooling" five times. Then it should display "Starting the machine" and read in the next temperature from the file.
Below temp_readings.txt file
import random
def main():
temp_readings = open('temp.readings.txt','w')
for count in range(24):
number = random.randint(90, 105)
temp_readings.write(str(number)+"\n");
temp_readings.close();
main()
code.py
import random
from time import sleep
def main():
temp_readings = open("temp.readings.txt", 'w')
for count in range(24):
number = random.randint(90, 105)
temp_readings.write(str(number) + "\n")
temp_readings.close()
temp_readings = open("temp.readings.txt", 'r')
temperatures = temp_readings.read().split('\n')
temperatures.remove('')
temp_readings.close()
for temp in temperatures:
print("Temperature - ",temp)
if int(temp) >= 100 :
print("Shutting down the machine")
sleep(1)
for _ in range(5):
print("Cooling...")
sleep(1)
print("Starting the machine")
sleep(1)
main()
CODE (INDENTATIONS) :

SAMPLE OUTPUT:

PLEASE RATE ! !
Thanks !
In Python... To automatically shut down the machine for 5 seconds then restart it, if the...
I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...
I cant get this python program to read all the unique words in a file. It can only read the number of the unique words in a line. import re import string from collections import Counter # opens user inputted filename ".txt" and (w+) makes new and writes def main(): textname = input("Enter the file to search: ") fh = open(textname, 'r', encoding='utf-8' ) linecount = 0 wordcount = 0 count = {} print("Sumary of the", fh) for line in...
Python 3 Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The filenames are nouns.txt, verbs. txt, articles.txt, and prepositions.txt. (HINT: Define a single new function, getWords. This function should expect a filename as an argument. The function should open an input file with this name, define a temporary list, read words from the file, and add them to the list. The function should then convert the list...
PYTHON The provided code in the ATM program is incomplete. Complete the run method of the ATM class. The program should display a message that the police will be called after a user has had three successive failures. The program should also shut down the bank when this happens. [comment]: <> (The ATM program allows a user an indefinite number of attempts to log in. Fix the program so that it displays a message that the police will be called...
10p
Python
For the following question, refer to the Python module on the right, as well as the code below. 1) What is the output of the following code? #dodgeable.py #main dodgeable.py import dodgeable class Locatable: def NUM_CARS = 3 init (self,x,y): NUM TRUCKS = 2 self.mX = X WIDTH = 60 self.mY = y def setx (self,x): def main (): self.mX = x object_list = [] def sety (self, y): self.mY = y for i in range (NUM_CARS) :...
PYTHON import random # VARIABLES first_num = random.randint(1, 100) sec_num = random.randint(1, 100) totalsum = first_num + sec_num def additon(first_num, sec_num): return first_num + sec_num; # INTRO print("Hello, \n" "this is an app that helps you practice your math skills while generating 6 sets of lucky numbers") question = input('Are you up for a challenge? [Y/N]') if question == 'n': print('okay, see you later') if question == 'y': print("Let's start!!") # USER NAME VALUE uname = input('what is your user...
11p
Python Language
Read the following code for oofraction. import oofraction class OOFraction: def main(): fl = oofraction.o0Fraction( 2, 5) f2 = oofraction.o0Fraction ( 1, 3) f3 = f1 + f2 print (str(3)) main() def __init__(self, Num, Den): self.mNum = Num self.mDen = Den return def_add_(self,other): num = self.mNumother.mDen + other.mNum*self.mDen den = self.mDen*other.mDen f = OOFraction(num,den) return f 1. Write the output below. def_str_(self): s = str( self.mNum )+"/" + str( self.mDen) returns 2. Write a class called wholeNum...
[Using Python] Create a program to generate one random question, from a list of 5, for each repeated run. Report the number of the correct answers after all five questions have been answered. Your 5 questions should be a simple math problem, like "what is 5-4?" use a while loop based on the number of questions use a counter variable to count the number of questions asked e.g. questionCount +=1 user a counter variable to keep track of the correct...
Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...
Python Problem Hello i am trying to finish this code it does not save guesses or count wrong guesses. When printing hman it needs to only show _ and letters together. For example if the word is amazing and guess=a it must print a_a_ _ _ _ not a_ _ _ _ and _a_ _ _ separately or with spaces. The guess has a maximum of 8 wrong guesses so for every wrong guess the game must count it if...