# 1. If you are in a city and have to walk from where you are, having .pdf

A

1. If you are in a city and have to walk from where you are, having planar coordinates (0, 0), to a destination having planar coordinates (x, y), then there are two ways of computing the distance you have to travel. One is called the euclidean distance, r1 = sqrt( x^2 + y^2) Note that this distance might require you to cut across lawns and through buildings. There is another way to measure distance called the taxi–cab distance, r2 = |x| + |y| which is the distance a taxi–cab would have to travel along the city blocks. Write a program which reads the destination coordinates, (x, y), and calls a single function, distance, which computes both the euclidean distance and the taxi–cab distance. The main program (not the function) must then print both distances to the screen. Solution import math #importing math to use sqrt function #distance function def distance(x, y): euclidean_distance = math.sqrt(x**2 + y**2) #calculating euclidean_distance taxi_cab_distance = abs(x) + abs(y) #calculating taxi_cab_distance return euclidean_distance, taxi_cab_distance #returning euclidean_distance and taxi_cab_distance coord = input(\"Enter the coordinates: \") #taking input x and y as a tuple x = coord[0] y = coord[1] euclidean_distance, taxi_cab_distance = distance(x, y) #calling the function #print statements print \"Euclidean Distance: \", euclidean_distance print \"Taxi Cab Distance: \", taxi_cab_distance.

CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf von
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfRajJain516913
19 views53 Folien
Computer graphics lab manual von
Computer graphics lab manualAnkit Kumar
15.8K views144 Folien
computer graphics-C/C++-dancingdollcode von
computer graphics-C/C++-dancingdollcodeBhavya Chawla
409 views11 Folien
TSP algorithm (Computational Thinking) Dropbox von
TSP algorithm (Computational Thinking) DropboxSeb Sear
194 views12 Folien
In the MATLAB, If you were to write a function to calculate the drag.pdf von
In the MATLAB, If you were to write a function to calculate the drag.pdfarchanenterprises
2 views1 Folie

## Similar a 1. If you are in a city and have to walk from where you are, having .pdf

Solving a “Transportation Planning” Problem through the Programming Language “C” von
Solving a “Transportation Planning” Problem through the Programming Language “C”Shahadat Hossain Shakil
1.3K views15 Folien
C++ program to calculate area of a polygon using #include bits.pdf von
C++ program to calculate area of a polygon using #include bits.pdfARYAN20071
34 views3 Folien
Computer graphics notes 2 tutorials duniya von
Computer graphics notes 2 tutorials duniyaTutorialsDuniya.com
122 views50 Folien
15 views10 Folien
Lecture _Line Scan Conversion.ppt von
Lecture _Line Scan Conversion.pptGaganvirKaur
40 views46 Folien
Computer graphics notes von
Computer graphics notesRAJKIYA ENGINEERING COLLEGE, BANDA
888 views55 Folien

### Similar a 1. If you are in a city and have to walk from where you are, having .pdf(20)

Solving a “Transportation Planning” Problem through the Programming Language “C” von Shahadat Hossain Shakil
Solving a “Transportation Planning” Problem through the Programming Language “C”
C++ program to calculate area of a polygon using #include bits.pdf von ARYAN20071
C++ program to calculate area of a polygon using #include bits.pdf
ARYAN2007134 views
Writeup advanced lane_lines_project von Manish Jauhari
Manish Jauhari15 views
Lecture _Line Scan Conversion.ppt von GaganvirKaur
Lecture _Line Scan Conversion.ppt
GaganvirKaur40 views
Hi- I have a programing problem of finding monotonic heuristics (in py (4).pdf von Ian0J2Bondo
Hi- I have a programing problem of finding monotonic heuristics (in py (4).pdf
Ian0J2Bondo2 views
I JUST NEED THE GRAPHH FILE PLEASE In this project yo.pdf von sukhvir71
I JUST NEED THE GRAPHH FILE PLEASE In this project yo.pdf
sukhvir712 views
Post mission analysis noise reduction von rohit baghel
Post mission analysis noise reduction
rohit baghel289 views
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docx von infantsuk
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docx
infantsuk4 views
Unit 2 von ypnrao
Unit 2
ypnrao259 views
Computer Graphics Unit 2 von SanthiNivas
Computer Graphics Unit 2
SanthiNivas36 views
Visual Basic(Vb) practical von Rahul juneja
Visual Basic(Vb) practical
Rahul juneja1.8K views
DDA algorithm von Yash Patel
DDA algorithm
Yash Patel16.3K views
4 CG_U1_M3_PPT_4 DDA.pptx von ssuser255bf1
4 CG_U1_M3_PPT_4 DDA.pptx
ssuser255bf119 views
F# Presentation for SmartDevs, Hereford von Kit Eason
F# Presentation for SmartDevs, Hereford
Kit Eason887 views
DESIGN, IMPLEMENT AND SIMULATE AN AGENT MOTION PLANNING ALGORITHM IN 2D AND 3... von csandit
DESIGN, IMPLEMENT AND SIMULATE AN AGENT MOTION PLANNING ALGORITHM IN 2D AND 3...
csandit1.5K views

## Más de alokkesh

MyCompanyemployee (person, street, city)works (person, departmen.pdf von
MyCompanyemployee (person, street, city)works (person, departmen.pdfalokkesh
2 views1 Folie
Java codePlease, provide comments, classes, and all the steps to s.pdf von
2 views2 Folien
Let G be a simple graph with n vertices. Show thata) G is a tree i.pdf von
Let G be a simple graph with n vertices. Show thata) G is a tree i.pdfalokkesh
2 views1 Folie
Last question is Matlab 4.3. Could someone figure these out. Especia.pdf von
Last question is Matlab 4.3. Could someone figure these out. Especia.pdfalokkesh
2 views1 Folie
is acute or chronic exposure to heptachlor more of a danger to human.pdf von
is acute or chronic exposure to heptachlor more of a danger to human.pdfalokkesh
2 views1 Folie
In a rising interest rate environment, how would bond values change .pdf von
In a rising interest rate environment, how would bond values change .pdfalokkesh
2 views1 Folie

### Más de alokkesh(20)

MyCompanyemployee (person, street, city)works (person, departmen.pdf von alokkesh
MyCompanyemployee (person, street, city)works (person, departmen.pdf
alokkesh2 views
Java codePlease, provide comments, classes, and all the steps to s.pdf von alokkesh
alokkesh2 views
Let G be a simple graph with n vertices. Show thata) G is a tree i.pdf von alokkesh
Let G be a simple graph with n vertices. Show thata) G is a tree i.pdf
alokkesh2 views
Last question is Matlab 4.3. Could someone figure these out. Especia.pdf von alokkesh
Last question is Matlab 4.3. Could someone figure these out. Especia.pdf
alokkesh2 views
is acute or chronic exposure to heptachlor more of a danger to human.pdf von alokkesh
is acute or chronic exposure to heptachlor more of a danger to human.pdf
alokkesh2 views
In a rising interest rate environment, how would bond values change .pdf von alokkesh
In a rising interest rate environment, how would bond values change .pdf
alokkesh2 views
alokkesh2 views
How can an age structure diagram indicate a growing or declining pop.pdf von alokkesh
How can an age structure diagram indicate a growing or declining pop.pdf
alokkesh4 views
Graph your data (scatterplot). The x-axis should represent the trial .pdf von alokkesh
Graph your data (scatterplot). The x-axis should represent the trial .pdf
alokkesh3 views
For this problem, consider the following sequence, which is the trans.pdf von alokkesh
For this problem, consider the following sequence, which is the trans.pdf
alokkesh2 views
find the sample size n , needed to find the estimate the percentage .pdf von alokkesh
find the sample size n , needed to find the estimate the percentage .pdf
alokkesh2 views
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf von alokkesh
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf
alokkesh2 views
Consider the consequences or a mutation in the DNA template sequence .pdf von alokkesh
Consider the consequences or a mutation in the DNA template sequence .pdf
alokkesh2 views
Construct the circle orthogonal to the given circle, and passing thro.pdf von alokkesh
Construct the circle orthogonal to the given circle, and passing thro.pdf
alokkesh2 views
Complete the following static method called repeatString (outline be.pdf von alokkesh
Complete the following static method called repeatString (outline be.pdf
alokkesh3 views
Assume that Google, If two different employers are randomly selected.pdf von alokkesh
Assume that Google, If two different employers are randomly selected.pdf
alokkesh2 views
An array is declared as follows int table[2] (5); Its values are st.pdf von alokkesh
An array is declared as follows int table[2] (5); Its values are st.pdf
alokkesh3 views
A)Consider a comparator with two 8-bit inputs, a and b. The a and .pdf von alokkesh
A)Consider a comparator with two 8-bit inputs, a and b. The a and .pdf
alokkesh4 views
A pearson correlation is computed for a sample of n = 18 pairs of X a.pdf von alokkesh
A pearson correlation is computed for a sample of n = 18 pairs of X a.pdf
alokkesh1 view
A class has 80 students, and the mean height is 5 feet 11 inches. A .pdf von alokkesh
A class has 80 students, and the mean height is 5 feet 11 inches. A .pdf
alokkesh1 view

## Último

ppt_dunarea.pptx von
ppt_dunarea.pptxvvvgeorgevvv
53 views5 Folien
UNIT NO 13 ORGANISMS AND POPULATION.pptx von
UNIT NO 13 ORGANISMS AND POPULATION.pptxMadhuri Bhande
43 views33 Folien
ANGULARJS.pdf von
ANGULARJS.pdfArthyR3
52 views10 Folien
NodeJS and ExpressJS.pdf von
NodeJS and ExpressJS.pdfArthyR3
50 views17 Folien
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice von
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a ChoiceTaste
52 views50 Folien
JRN 362 - Lecture Twenty-Two von
JRN 362 - Lecture Twenty-TwoRich Hanley
39 views157 Folien

### Último(20)

UNIT NO 13 ORGANISMS AND POPULATION.pptx von Madhuri Bhande
UNIT NO 13 ORGANISMS AND POPULATION.pptx
ANGULARJS.pdf von ArthyR3
ANGULARJS.pdf
ArthyR352 views
NodeJS and ExpressJS.pdf von ArthyR3
NodeJS and ExpressJS.pdf
ArthyR350 views
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice von Taste
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Taste52 views
JRN 362 - Lecture Twenty-Two von Rich Hanley
JRN 362 - Lecture Twenty-Two
Rich Hanley39 views
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE... von Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
JQUERY.pdf von ArthyR3
JQUERY.pdf
ArthyR3107 views
Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf von TechSoup
Ask The Expert! Nonprofit Website Tools, Tips, and Technology.pdf
TechSoup 62 views
The Future of Micro-credentials: Is Small Really Beautiful? von Mark Brown
The Future of Micro-credentials: Is Small Really Beautiful?
Mark Brown102 views
Six Sigma Concept by Sahil Srivastava.pptx von Sahil Srivastava
Six Sigma Concept by Sahil Srivastava.pptx
Sahil Srivastava51 views
INT-244 Topic 6b Confucianism von S Meyer
INT-244 Topic 6b Confucianism
S Meyer49 views

### 1. If you are in a city and have to walk from where you are, having .pdf

• 1. 1. If you are in a city and have to walk from where you are, having planar coordinates (0, 0), to a destination having planar coordinates (x, y), then there are two ways of computing the distance you have to travel. One is called the euclidean distance, r1 = sqrt( x^2 + y^2) Note that this distance might require you to cut across lawns and through buildings. There is another way to measure distance called the taxi–cab distance, r2 = |x| + |y| which is the distance a taxi–cab would have to travel along the city blocks. Write a program which reads the destination coordinates, (x, y), and calls a single function, distance, which computes both the euclidean distance and the taxi–cab distance. The main program (not the function) must then print both distances to the screen. Solution import math #importing math to use sqrt function #distance function def distance(x, y): euclidean_distance = math.sqrt(x**2 + y**2) #calculating euclidean_distance taxi_cab_distance = abs(x) + abs(y) #calculating taxi_cab_distance return euclidean_distance, taxi_cab_distance #returning euclidean_distance and taxi_cab_distance coord = input("Enter the coordinates: ") #taking input x and y as a tuple x = coord[0] y = coord[1] euclidean_distance, taxi_cab_distance = distance(x, y) #calling the function #print statements print "Euclidean Distance: ", euclidean_distance print "Taxi Cab Distance: ", taxi_cab_distance
Aktuelle SpracheEnglish
Español
Portugues
Français
Deutsche