The coordinates of different persons are given in the following dictionary.
position = ('A': (2, 5), 'B': (1, 7), 'C': (9, 5), 'D': (2, 6))
You will take 2 inputs for person X's location where the first
input specifies person X's current location in the x-axis and the second input specifies person X's current location in the y-axis.
Your work is to find the person closest to person X by
calculating the
distance between person X and every other person in the dictionary.
Hint: The distance between two coordinates is given by the
formula (You
need to import math):
math.sqrt((x2-x1)**2 + (y2-y1)**2)
Sample Input 1:
Enter person X's x coordinate: 3
Enter person X's y coordinate: 6
Sample Output 1:
D
Write a Python program that takes a string as an input where multiple numbers are separated by hashes(#). Your first task is to create a list of numbers and print it.
Your second task is to create a dictionary that will have the index of the
list as key, and for the even indices, multiplication from start to that index as value, while for the odd indices, summation from start to that
index as value. Finally, print the dictionary.
Sample Input 1:
1#2#3#4
Sample Output 1:
[1, 2, 3, 4]
(0:1, 1:3, 2:6, 3:10}
Sample Input 2:
5#6#7
Sample Output 2:
[5, 6, 7]
{0: 5, 1:11, 2: 210}
Write a Python program that reads a number and finds the sum of the series
of 1 + 33 + 111 + 3333 +....+N terms. Then it puts the reverse digit of the sum to a list and prints it. [Cannot use built-in reverse() or reversed()]
Sample Input 1:
5
Sample Output 1:
Sum of series: 14589 Reverse sum of series in list: [9, 8, 5, 4, 1]
Different shapes have different dimensions and properties that can be used to compute their area and perimeter. Using namespace technique, create a C++ program that compute the area of circle, rectangle, triangle and sphere. Each shape must have its own namespace that houses two functions, the one for calculating the area and the other for perimeter or circumference.
Input: ramisgood
goodforall.
Output: good.
Input a random positive integer. Then create an integer array that has a size equal to the inputted integer.
Using a loop, add random integer values into the array one by one. The number of values to be stored is dependent on the inputted positive integer given in the first instruction.
Print out the largest integer among all the elements on the array, by any means necessary.
Input
The first line contains the size of the array.
The next lines contains an integer.
5
5
34
3
23
10
An array containing 5 integer elements is already provided for you in the code editor below.
Print out the cube of the 1st, 3rd, and 5th element of the given array.
Output
Multiple lines containing the cubes of the 3 elements of the given array.
-8
1
27
Write a java program that will accept marks for 10 students who sat for a java examination. Total mark for the examination is 80. Determine the number of students who passed and failed the examination
Write c++ program to check whether agiven number is even or odd
Write a program using one-dimensional array that searches a number if it is found on the list of the given 5 input numbers and locate its exact location in the list.
Sample input/output dialogue:
Enter a list of numbers: 5 4 8 2 6 Enter a number to be searched: 2 2found in location 4