Question

In: Computer Science

use *python Though CPUs, and computer hardware in-general, are not the main focus of this course,...

use *python

Though CPUs, and computer hardware in-general, are not the main focus of this course, it can be useful to know a thing or two about computer hardware. The CPU (Central Processing Unit) is generally the piece of hardware that carries out the instructions of the python programs that you run in this class.

In this short PA, you will write a program that takes a few input values related to CPU performance. The program should determine whether or not the specified CPU is within one of four categories: high-performance, medium-performance, low-performance, and in need of an upgrade. Name the file cpu.py. Shown below is an example of the program prompting the user for three inputs, and then printing out the corresponding CPU performance category:

Press ENTER or type command to continue
Enter CPU gigahertz:
2.7
Enter CPU core count:
2
Enter CPU hyperthreading (True or False):
False

That is a low-performance CPU
  • The first input, Gigahertz, should be converted to a float
  • The second input, core count, should be an integer
  • The third input, hyperthreading, should be a boolean. You should think of a way to go from a string 'True' or 'False' into a boolean True or False. (In case you were wondering, hyperthreading is a feature of some CPUs allowing for better performancce).

The program should spit out one of 4 strings:

  • That is a high-performance CPU.
  • That is a medium-performance CPU.
  • That is a low-performance CPU.
  • That CPU could use an upgrade.

How you determine which to print out should be based on the below tables:

If the CPU has hyperthreading

performance level min GHz min cores
high-performance 2.7 6
medium-performance 2.4 4
low-performance 1.9 2

If the CPU does not have hyperthreading

performance level min GHz min cores
high-performance 3.2 8
medium-performance 2.8 6
low-performance 2.4 2

There’s also one “special-case” rule: If a CPU has 20 or more cores, regardless of the other stats, it should be considered high-performance.

Examples

Below are several examples of program runs. There will be more tests on Gradescope.

Enter CPU gigahertz:
2.0
Enter CPU core count:
8
Enter CPU hyperthreading (True or False):
True

That is a low-performance CPU.
Enter CPU gigahertz:
4.0
Enter CPU core count:
6
Enter CPU hyperthreading (True or False):
False

That is a medium-performance CPU.

Solutions

Expert Solution

'''

Python version : 2.7

Python program to determine the whether or not the specified CPU is within one of four categories:

high-performance, medium-performance, low-performance, and in need of an upgrade.

'''

# input of cpu gigahertz

cpu_ghz = float(raw_input('Enter CPU gigahertz:\n'))

# input of cpu cores count

cpu_cores = int(raw_input('Enter CPU core count:\n'))

# input of cpu hyperthreading

cpu_hyperthreading_input = raw_input('Enter CPU hyperthreading (True or False):\n')

# convert the string input to boolean

if cpu_hyperthreading_input == 'True':

               cpu_hyperthreading = True

else:

               cpu_hyperthreading = False

              

# check if cpu cores >= 20, then high performance cpu      

if cpu_cores >=20:

               print('That is high-performance CPU.')

elif cpu_hyperthreading == True: # check if hyperthreading is True

              

               # cpu gigahertz is min 2.7 and cores are min 6, then high performance

               if(cpu_ghz >= 2.7 and cpu_cores >= 6):

                              print('That is high-performance CPU.')

               # cpu gigahertz is min 2.4 and cores are min 4, then medium performance

               elif(cpu_ghz >=2.4 and cpu_cores >= 4):

                              print('That is medium-performance CPU.')

               # cpu gigahertz is min 1.9 and cores are min 2, then low performance        

               elif(cpu_ghz >= 1.9 and cpu_cores >= 2):

                              print('That is low-performance CPU.')

               else: # needs an upgrade

                              print('That CPU could use an upgrade.')

              

else: # check if hyperthreading is False

               # cpu gigahertz is min 3.2 and cores are min 8, then high performance

               if(cpu_ghz >= 3.2 and cpu_cores >= 8):

                              print('That is high-performance CPU.')

               # cpu gigahertz is min 2.8 and cores are min 6, then medium performance

               elif(cpu_ghz >= 2.8 and cpu_cores >= 6):

                              print('That is medium-performance CPU.')

               # cpu gigahertz is min 2.4 and cores are min 2, then low performance        

               elif(cpu_ghz >= 2.4 and cpu_cores >= 2):

                              print('That is low-performance CPU.')

               else: # needs an upgrade

                              print('That CPU could use an upgrade.')

                             

#end of program                            

Code Screenshot:

Output:


Related Solutions

1. What might cause you to use diagnostic tools to scan a computer for hardware errors?
1. What might cause you to use diagnostic tools to scan a computer for hardware errors?
USE BASIC PYTHON Focus on Basic file operations, exception handling. Save a copy of the file...
USE BASIC PYTHON Focus on Basic file operations, exception handling. Save a copy of the file module6data.txt (Below) Write a program that will a. Open the file module6data.txt b. Create a second file named processed. txt c. Read the numbers from the first file one at a time. For each number write into second file, if possible, its I. Square ii. Square root iii. Reciprocal (1/number)use a math module function for the square root. use exception handling to trap possible...
The definitions section on HER and Electronic Patient Record Meaningful use of EHR- priorities, main focus...
The definitions section on HER and Electronic Patient Record Meaningful use of EHR- priorities, main focus of stage 1 , stage 2 and stage 3 of meaningful use Benefits of HER : general, for the nurses, healthcare provider, for consumers, for payers Could you help me define these and set up a small study guide. Thank you!
Please, Use your own words . sorry No handwriting. COURSE: Human Computer Interaction Usability testing is...
Please, Use your own words . sorry No handwriting. COURSE: Human Computer Interaction Usability testing is a significant aspect for effective interface development. List and briefly describe any four methods of usability testing. N.B. The question asks about methods of usability testing not tools used in usability testing (surveys are an example of tools).
General guidelines: Use EXCEL or PHStat to do the necessary computer work. Do all the necessary...
General guidelines: Use EXCEL or PHStat to do the necessary computer work. Do all the necessary analysis and hypothesis test constructions, and explain completely. Read the textbook Chapter 11. Solve the textbook example on page 403, "Mobile Electronics," in order to compare four different in-store locations with respect to their average sales. Use One-Way ANOVA to analyze the data set, data, given for this homework. Use 5% level of significance. 1) Do the Levene test in order to compare the...
General guidelines: Use EXCEL or PHStat to do the necessary computer work. Do all the necessary...
General guidelines: Use EXCEL or PHStat to do the necessary computer work. Do all the necessary analysis and hypothesis test constructions, and explain completely. Read the textbook Chapter 13. Imagine that you are managing a mobile phone company. You want to construct a simple linear regression model to capture and represent the relationship between the number of customers and the annual sales level for a year with 95% confidence. You had conducted a pilot study for the past fifteen years...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT