Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

You will be given a list of tuples where each tuple indicates a point i.e. (x, y) in a 2-dimensional coordinate system. You need to write a python program to find the minimum distance and the point that is closest to the origin i.e. (0,0)

Hint:

The formula of distance =√ [ (x₂ - x₁)² + (y₂ - y₁)²]

As you are calculating the distance from the origin (0,0), you can simply use distance = √ [ (x²+y²)] 

You can create a list of distances from each point and sort that list using your personal favorite sorting algorithm.


Sample Input 1 

points = [(5,3), (2,9), (-2,7), (-3,-4), (0,6), (7,2)] 

Sample Output 1 

Minimum distance = 5.0 

Here the closest point is (-3,-4) which has a distance of 5.0 from the origin.


Sample Input 2 

points = [(1,7), (4,5), (-1,7), (-2,0), (1,1), (5,-1)] 

Sample Output 2 

Minimum distance = 1.4142135623730951 Here the closest point is (1,1) which has a distance of 1.4142135623730951 from the origin.


SNAKY CONVERSION

you are given a string S print the string in N rows containing a snaky pattern represenation as described below

INPUT:the first line should be a string

explanation:

s=AWESOMENESS N=4

consider the following snaky representation of the word

A E

W M N

E O E S

S S

the first row contains characters AE

the 2nd row contains characters WMN

the 3rd row contains characters EOES

THE fourth row contains characters SS

INPUT:

NEWSLETTER 3

OUTPUT:

NLE

ESETR

WT

INPUT:AWESOMENESS 4

OUTPUT:

AE

WMN

 EOES 

SS


There is a chocolate vending machine.intially it contains a total of K chocolates N people are standing in a queue from left to rigth.Each person wants to withdraw chocolates.The i-i-th person wants to take Ai units of chocolates.People come in and try to withdraw chocolates one by one,in the increasing order of their indices.Whenever someone tries to withdraw chocolate,it will give them.Otherwise,it will throw an error and not give out anything in that case this person will return home directly without trying to do anything else for each person determine whether they will get the required amount of chocolate or not

input:The 1st line of input contains a single integer T denoting the no.of test cases the description of T test cases follows

the first line of each test case contais two separated integers N and K

the second line contains N space-separated integers A1,A2,A3----AN

INPUT:

2

5 10

3 5 3 2 1

4 6

10 8 6 4

OUTPUT:

11010

0010

INPUT:2

6 15

16 1 2 6 4 5

10 5

1 2 6 5 4 3 2 1 1 1

OUTPUT:

011110

1100001000


In rahul's school every student is uniquely identified by a string which is printed on the id card of the student .This unique id is comprised of letters and digits separated by hyphens into groups of different lengths.The college administration decides to standardize this unique id on the id card by regrouping the letters of the previous unique id to a fixed group length.the college administration also does not want to have lowercase letters in the new id.you need to help the college administration with this task.Given the previous id,and the no.of characters to group,you need to generate the new id

note:while generating the new unique id ,group the characters from right to left

input:the 1st line containing a string S representing a unique id.

the 2nd line containing an integer N representing group length

i/p:2-4A0r7-4k

3

o/p:24-A0R-74K

i/p:

5F3Z-2e-9-w

4

O/P:5F3Z-2E9W


Write the correct title code that will do the following.





1) Ask the user to put the name of the nurtle screen.





2) Ask the user to input the background color of the turtle screen.





3) Ask the user to input a number that will instruct the turtle to move in accordance with number entered.





4) Ask the user to mput a number that will instruct the tunle to turn in accordance with the number





write a program to print the given input word three times in a single line separated by spaces


Many companies use telephone numbers like 555-GET-FOOD so the number is easier

for their customers to remember. On a standard telephone, the alphabetic

letters are mapped to numbers in the following fashion:


A, B, C: 2

D, E, F: 3

G, H, I: 4

J, K, L: 5

M, N, O: 6

P, Q, R, S: 7

T, U, V: 8

W, X, Y, Z: 9


Write a program that asks the user to enter a 10-character telephone number in

the format XXX-XXX-XXXX. The application should display the telephone

number with any alphabetic characters that appeared in the original translated

to their numeric equivalent.



Given this list of students containing age and name, students = [{"age": 19, "name": "Eunice"}, {"age": 21, "name": "Agnes"}, {"age": 18, "name": "Teresa"}, {"age": 22, "name": "Asha"}], write a function that greets each student and tells them the year they were born. e.g Hello Eunice, you were born in the year 2002.



Create a Class Rectangle with the following Attributes and Methods

Attributes: The class has attributes width and length that represent the two sides of a rectangle 

Methods:

 Add a method named area which returns the area (A) of the rectangle using the formula A=width*length

Add a method named perimeter which returns the perimeter (P) of the rectangle using the formula P=2(length+width)



1. Copy the countdown function from Section 5.8 of your textbook.




def countdown(n):



if n <= 0:



print('Blastoff!')



else:



print(n)



countdown(n-1)




Write a new recursive function countup that expects a negative argument and counts “up” from that number. Output from running the function should look something like this:




>>> countup(-3)



-3



-2



-1



Blastoff!




Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.)




If the number is positive, the program should call countdown. If the number is negative, the program should call countup. Choose for yourself which function to call (countdown or countup) for input of zero.




Provide the following.




The code of your program.



Output for the following input: a positive number, a negative number, and zero.



An explanation of your choice for what to call for input of zero.







LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS