Question

In: Computer Science

Python: I want to make the following code to prompt the user if want to run...

Python: I want to make the following code to prompt the user if want to run the software again. I am new to python, so i do not know if it works like c++. If can explain that would be much appreciated

base = float(input("Enter base of the triagle: "))

Triangle_Right = float(input("Enter right side of the triagle: "))

Triangle_Left = float(input("Enter left side of the triagle: "))

height = float(input("Enter the height of the triangle: "))

perimiter = base + Triangle_Right + Triangle_Left

area = (base*height)/2

print("The perimiter is =", perimiter)

print("The area is =", area)


Solutions

Expert Solution

# read a base value for triangle and store it in variable base as a float(same as c++ float)
base = float(input("Enter base of the triangle: "))
# read a right side value for triangle and store it in variable Triangle_Right as a float(same as c++ float)
Triangle_Right = float(input("Enter right side of the triangle: "))
# read a left side value for triangle and store it in variable Triangle_Left as a float(same as c++ float)
Triangle_Left = float(input("Enter left side of the triangle: "))
# read a height value for triangle and store it in variable height as a float(same as c++ float)
height = float(input("Enter the height of the triangle: "))
# calculate perimeter
perimeter = base + Triangle_Right + Triangle_Left
# calculate are
area = (base * height) / 2
# print perimeter
print("The perimeter is =", perimeter)
# print area
print("The area is =", area)

"""
This is mostly like C++
don't need to use ; after each statement
print is used like cout
and input is used instead of cin
all other statements are mostly same
"""


Related Solutions

code in python I want to make a function that adds all the multipliers together. The...
code in python I want to make a function that adds all the multipliers together. The code is posted below and please look at wanted output section to see what I want the code to output. The last line of the code is the only addition I need. Thanks. Code: 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    ...
*** Using Python *** Your program must prompt the user for their city or zip code...
*** Using Python *** Your program must prompt the user for their city or zip code and request weather forecast data from openweathermap.org. Your program must display the weather information in an READABLE format to the user. Requirements: Create a Python Application which asks the user for their zip code or city. Use the zip code or city name in order to obtain weather forecast data from: http://openweathermap.org/ Display the weather forecast in a readable format to the user. Use...
Python Code: Write a program to prompt the user to enter a first name, last name,...
Python Code: Write a program to prompt the user to enter a first name, last name, student ID, number of hours completed and GPA for 5 students. Use a loop to accept the data listed below. Save the records in a text file. Write a second program that reads the records from your new text file, then determines if the student qualifies for Dean’s list or probation. Display the records read from the file on screen with appropriate headings above...
lets say i make a PYTHON code that lets a user guess a number between 1-1000,...
lets say i make a PYTHON code that lets a user guess a number between 1-1000, every failed attempt you get a hint (go lower or go higher) how can i penalize the user if they dont follow the hints, example ( go higher!... your next pick: a smaller number... 2 you loose $100 for not following hint) 2 and the user has unlimited attempts, until he guesses the number, this is made using random.randint(1,1000) function THE ONLY THING IM...
I need a java code Write a simple program to prompt the user for a number...
I need a java code Write a simple program to prompt the user for a number between 1 and 12 (inclusive) and print out the corresponding month. For example:   The 12th month is December. Use a java "switch" statement to convert from the number (1-12) to the month. Also use a "do while" loop and conditional checking to validate that the number entered is between 1 and 12 inclusive and if not, prompt the user again until getting the correct...
what is the solution of this code? Also how would I run it in python to...
what is the solution of this code? Also how would I run it in python to check? q = Queue() q.enqueue(10) q.enqueue(12) q.enqueue(15) for i in range(len(q)): → if len(q) % 2 == 0: → → q.enqueue(q.dequeue()) → else: → → q.dequeue() print(q)
In Python, your program will read in a number (no need to prompt the user), and...
In Python, your program will read in a number (no need to prompt the user), and then reads in that number of lines from the terminal. Then the program should print an array of strings formatted in a nice regular box. So if the user inputs this: 5 Grim visaged war has smooth’d his wrinkled front And now, instead of mounting barded steeds To fright the souls of fearful adversaries He capers nimbly in a lady’s chamber To the lascivious...
I need to make this into a Java Code: Write a program that prompts the user...
I need to make this into a Java Code: Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate: circleCircumference = 2πr circleArea = πr2 sphereArea = 4πr2 sphereVolume = 43πr3 You must use π as defined in the java.lang.Math class. Your prompt to the user to enter the number of days must be: Enter radius: Your output must be of the format: Circle Circumference = circleCircumference Circle Area...
In python I have my code written and I want just 4 functions to be fix...
In python I have my code written and I want just 4 functions to be fix in my code according to rule. My code is running but it has some problem regarding to rules. (I have did all the other things so you do not have to worry about other functions) 1) all the players has to play until he/she reaches to at least 500 points in first round. When user reach 500 points for the first time, user may...
Could you modify my code so it meets the following requirement? (Python Flask) I want the...
Could you modify my code so it meets the following requirement? (Python Flask) I want the user to register for account using email and password, then store that data into a text file. Then I want the data to be read when logging in allowing the user to go to home page. -------------Code-------------------- routes.py from flask import Flask, render_template, redirect, url_for, request, session import json, re app = Flask(__name__) '''@app.before_request def before_request(): if 'visited' not in session: return render_template("login.html") else:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT