#------------------------------ #-- Name: Ahmed Abdeen Ahmed #-- Username: ahamed #-- Assignment: (1) #------------------------------ #-- program to convert Fehrenheit tempreture to Celcius #-- The formula is: #-- celc = ((fahr - 32) * 5) / 9 print "Problem 1 starts..." #-- prompt for a fahrenheit temprature and convert it to float fahr = float(raw_input("Enter a temprature in Fahrentheit: ")) #--computing the celcius from the previously entered fahrenheit celc = ((fahr - 32) * 5) / 9 #-- print the results print "The tempreture is Celcius is: " , celc print "problem 1 ends......\n\n\n" #------------------------- END OF PROBLEM 1 ------------------------ #-- A point in plane has two coordinates: x and y. #-- Write a program that asks the user for the coordinates of two points, #-- then calculates and reports the distance between the two points. #-- The distance between two points in the plane can be calculated by #-- taking the square root of the sum of squared differences in x and y. # | #-9- #-8- #-7- p1(7,6) #-6-------------x #-5- | #-4- | p2(10,3) #-3-------------x------x #-2- | | #-1- | | #-0-1-2-3-4-5-6-7-8-9-10------------ #-- the following is the algorithm of solving the problem #-- get the differences in x and y coordinates #-- square the differences #-- sum the squared differneces #-- square root the sum of the square differences print "Problem 2 starts...\n" #-- prompt for the p1 coordinates p1_x = int(raw_input("Enter x coordinate for point 1: ")) p1_y = int(raw_input("Enter y coordinate for point 1: ")) #-- prompt for the p2 coordinates p2_x = int(raw_input("Enter x coordinate for point 2: ")) p2_y = int(raw_input("Enter y coordinate for point 2: ")) #-- get the differences in x coordinate and square it squareSumXs = (p1_x - p2_x) ** 2 #-- get the differences in y coordinate and square it squareSumYs = (p1_y - p2_y) ** 2 #-- the distance is: #-- sqrt(squareSumX + squareSumY) distance = (squareSumXs + squareSumYs) ** 0.5 #-- print the final result print "The distance between Point1(", p1_x, "," , p1_y , ") and Point2(", p2_x, "," , p2_y , ") is" , distance print "\nproblem 2 ends.....\n\n\n"