[SOLVED] CSCI161 Assignment 2

25.00 $

Category: Tags: , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon assignment02-xubiuw.zip (477.7 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (1 vote)

Objective:

To work with basic input-output and decision making commands.

Assignment:

Write a python program that prints a menu, with options performing the following operations. The option number should be provided as user input. The functions performed by each option is given below:

Option 1: User input your name and age store it in variables ‘name’ and ‘age’ respectively. Then print the statement as “My name is <<name>> and my age is << age>>”.

Option 2: Accept two coordinate values as float and store them in variables x1, y1, x2 and y2. Find the distance between two points (x1, y1) and (x2, y2) using the formula, sqrt((x2 – x1)2 + (y2 – y1)2) and print them. (Hint: You may need to import math module and use sqrt () and pow ()).

Option 3: Exit from the program.

Sample Output:

Menu:

  1. Option 1
  2. Option 2
  3. Exit

Please enter an option: >>1

Please enter your name: abc

Please enter your age: 10

My name is abc and my age is 10.

Menu:
1. Option 1

CSCI 161L Assignment 2

Points 10

2. Option 2

3. Exit
Please enter an option:

>>2

Please enter the x value of first coordinate: 30
Please enter the y value of first coordinate: 20

Please enter the x value of second coordinate: 50
Please enter the y value of second coordinate: 40

The distance between (x1, y1) and (x2, y2) is 28.2842

Instructions:

 Preferred programming environment:

 OS
 Interpreter  Editor

: Linux (Mint)
: Python 3
: gedit or any other editor of your choice

  •   The program is saved as a file with .py extension. Submit the .py file to blackboard.
  •   The program should include a comment block at the top with your name, course number

    and course section, assignment number.

  • assignment02-xubiuw.zip