Question

In: Computer Science

Use your IDE (PyCharm) to create a new file named countertop.py. Type in the following lines,...

Use your IDE (PyCharm) to create a new file named countertop.py. Type in the following lines, exactly as they are shown here (including the four spaces before the indented lines of code) and save the file:

def countertop(sideLength):

""" Compute the area of a square countertop with a missing wedge.

The parameter x is the length of one side of the square. """

square = sideLength ** 2 # area of the full square

triangle = ((sideLength / 2) ** 2) / 2 # area of the missing wedge

return square - triangle.

Now we want to use the countertop function to calculate the area given the user’s input and print out the result. Take input from the user like we did in problem 1. Then call the countertop function and store the result in a variable, before printing that variable on the next line. Try running the program in the IDE

Solutions

Expert Solution

IDLE CODE

============================================================================================

def countertop(sideLength):
""" Compute the area of a square countertop with a missing wedge.
The parameter x is the length of one side of the square. """
square = sideLength ** 2 # area of the full square
triangle = ((sideLength / 2) ** 2) / 2 # area of the missing wedge
return square - triangle


side=float(input('Enter side length: '))
res=countertop(side)
print('output is: ',res)

============================================================================================

output


Related Solutions

​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create a variable named base_fee and set the value to 5.5. Prompt the user for the zone. The zones can be an integer value from 1 to any value for the zone. Convert the zone to an integer. Display the zone on the SenseHat with a scroll speed of 0.3, make the text blue, and the background yellow. Scroll "The zone is " and the...
Create a file named Good1 nano Good1 Type Welcome in the file and save it. What...
Create a file named Good1 nano Good1 Type Welcome in the file and save it. What command gives you a long listing of your filenames in the current directory, including permissions attached to each file. What command would you use to change a file’s permissions to include read, write and execute permission for the owner of the file only. Explain the following file permissions    a) 777          b) 765          c) 400          d) 666          e) 600         ...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
Using PyCharm, create a new Project lab8. Under lab8 create a new Directory exercise, then create...
Using PyCharm, create a new Project lab8. Under lab8 create a new Directory exercise, then create a Python file called nested.py, type the following: Test your code by putting the following at the bottom of the file: make_table_of_stars(2,3) (as shown in the code above). Run the file by right clicking in the code area of Pycharm, then choosing “Run nested”. Your output should be: *** *** (2 rows with 3 columns of stars). Reverse the 2 and 3. What happens?...
Create a file named work.sh in your hw5 directory. Give this file read and write permission...
Create a file named work.sh in your hw5 directory. Give this file read and write permission (no execute permissions) for you alone. No other account should have any access privileges to this file. Change the permissions on the work.sh file so you have read and write permissions. Give everybody else, including the group, read permissions only. Give yourself read, write and execute permissions to the file work.sh. Give everyone else, including the group, execute permissions only. Create a directory named...
Create a cronjob which does the following tasks 1.) create a file named <yourname>.txt 2.) in...
Create a cronjob which does the following tasks 1.) create a file named <yourname>.txt 2.) in the 35th minute of the hour change the permission to 755 3.) Create a shell script named first.sh in which you print your name and redirect the output by 45th minute of the hour to the text file
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using...
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January" through "December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs...
Consider a text file that you will create named “employees.txt”. The file contains data organized according...
Consider a text file that you will create named “employees.txt”. The file contains data organized according to the following format:John Smith 10 15Sarah Johnson 40 12Mary Taylor 27 13Jim Stewart 25 8For instance, “John” is the first name, “Smith” is the last name, “10” is the number of hours per week, and “15” is the hourly rate.Write a program that computes the weekly salary of each employee. The program prints the first name, last name, and weekly salary of each...
The requirements for this program are as follows: Create a header file named “Employee.h”. Inside this...
The requirements for this program are as follows: Create a header file named “Employee.h”. Inside this header file, declare an Employee class with the following features: Private members a std::string for the employee’s first name a std::string for the employee’s last name an unsigned int for the employee’s identification number a std::string for the city in which the employee works Public members A constructor that takes no arguments A constructor that takes two arguments, representing: the employee’s first name the...
Create a class named Horse that contains the following data fields: name - of type String...
Create a class named Horse that contains the following data fields: name - of type String color - of type String birthYear - of type int Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field, races (of type int), that holds the number of races in which the horse has competed and additional methods to get and set the new field. ------------------------------------ DemoHorses.java public class DemoHorses {     public static void...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT