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...
1. Create a1. Create a new java file named Name.java that should have Name class based...
1. Create a1. Create a new java file named Name.java that should have Name class based on new java file named Name.java that should have Name class based on the following UML Name - first: String - last: String + Name () + Name (String firstName, String lastName) + getName () : String + setName (String firstName, String lastName) : void + getFirst () : String + setFirst (String firstName) : void + getLast () : String + setLast (String...
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...
Create a new project called Lab05b. Keep the main file named main. Write a function readAndPrint,...
Create a new project called Lab05b. Keep the main file named main. Write a function readAndPrint, and power with parameters noted below in the Functions.h file. //Your Last Name #ifndef FUNCTIONS_H #define FUNCTIONS_H #include <fstream> #include <iostream> #include <string> using namespace std; /*reads from a file and prints every item to the screen*/ // file contains sets of //int //string //Don't forget to use infile.ignore() between << and getline //ifstream must be passed by reference void readAndPrint(ifstream &infile); //uses a...
Write a shell script that will create a new password-type file that contains user information. The...
Write a shell script that will create a new password-type file that contains user information. The file should contain information about the last five users added to the system with each line describing a single user. This information is contained in the last five lines of both the /etc/shadow and the /etc/passwd files. Specifically, you should produce a file where each line for a user contains the following fields: user name, encrypted password, and shell. The fields should be separated...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT