• Nie Znaleziono Wyników

Gets the coordinates for two points from the user and computes the distance

N/A
N/A
Protected

Academic year: 2021

Share "Gets the coordinates for two points from the user and computes the distance"

Copied!
1
0
0

Pełen tekst

(1)

Open Source Frameworks for Rapid Application Development

Python exercises

Work environment: https://repl.it/languages/python3 Write Python programs that will solve problems listed below:

1. Get the user’s first and last name with two input calls and outputs them in reverse order with a comma between them.

2. Get the user’s full name with one input call and display the name as last, first.

3. Gets the coordinates for two points from the user and computes the distance. Round your answer totwo decimal places.

4. At Jenny’s birthday party she orders a 32 piece pizza. Have the user (probably Jenny) enter thenumber of people at the party that will be eating pizza and output the number of slices each one gets.As you know the pizza might not divide evenly. There are two ways to handle this. The first is toignore the extra pieces and give everyone the same amount. The second way is to cut up the extrapieces so that everyone gets the same amount. Your program must output both options. E.g.

Number of guests: 10

Option 1: 3 slices each, 2 left over Option 2: 3.2 slices each

5. Get a sentence from the user and display it back with one word per line.

6. When building and enclosure for a python the amount of area at the base of the enclosure should bepropor- tionate to the length of the snake. The minimum needed is 1/2 square foot for each foot inlength up to and including 6 and 3/4 square foot for each foot after that.

e.g. 9’ python needs 5.25 square feet (6 * 0.5 + 3 * 0.75)

Create a program that asks the user how long their python is and tell them the minimum area theyneed for the base of its enclosure.

7. We have given list l = [3, 5, 6, 3, 6, 4, 5, 3, 8, 3]. Create a dictionary counts whose keys are the values of the items appearing in the list l, and the values of the number of occurrences of these items in the list l.

8. Palindromes are words that are the same forwards and backwards. Create a program that gets aword from the user and tells them if it is palindrome or not. Your program should not care aboutcapitalization.

9. As you might know, the persistence of a number is the number of steps it takes to get a one-digitnumber when separating the digits and multiplying them together. What you may not have noticedis that persistence is inherently recursive. The persistence of any one-digit number is zero. Thepersistence of any other number is one plus the persistence of the digits multiplied together. Create arecursive function called persistence that computes the persistence of any whole number.

1

Cytaty

Powiązane dokumenty

The changes are supposed to improve the situation of the working class, but the executioners of said changes would belong to the industrial party.. Peaceful reforms, not

Для фронтальних зображень, зроблених в один і той же день, прийнятна точність розпізнавання, як правило, становить 95%.. Для зображень,

As excellent sample prepara- tion is a prerequisite for perfect microscopy, Leica Microsystems Life Science division also offers the most comprehensive product

2. 2% of newly manufactured processors have damaged cores. A laptop with a damaged core overheats; overheating also appears in 0.002% of laptops with fully functional cores. We

Thus eigenfunctions of the Fourier transform defined by the negative definite form −x 2 in one variable are the same as eigenfunctions of the classical in- verse Fourier

(b) It is an immediate consequence of the definition of the group law that if an elliptic curve is represented as a double cover of the line and one branch point is chosen as the

At what distance from centre of the circle with radius 1 will the circle be seen at a right

Find the area of the smaller section of land ABC, given the additional information shown below... A recreation park has