---21---
Question:
>A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps.
>The numbers after the direction are steps. Please write a program to compute the distance from current position after a sequence of movement and original point. If the distance is a float, then just print the nearest integer.
Example:
>If the following tuples are given as input to the program:
UP 5
DOWN 3
LEFT 3
RIGHT 2
>Then, the output of the program should be:2
Solution:
解法一:
解法二
---22---
Question:
>Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically.
>Suppose the following input is supplied to the program:
New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3.
>Then, the output should be:
2:2
3.:1
3?:1
New:1
Python:5
Read:1
and:1
between:1
choosing:1
or:2
to:1
Solution:
解法一
解法二
---23---
Question:
>Write a method which can calculate square value of number
Solution:
---24---
Question:
>Python has many built-in functions, and if you do not know how to use it, you can read document online or find some books. But Python has a built-in document function for every built-in functions.
>Please write a program to print some Python built-in functions documents, such as abs(), int(), raw_input()
>And add document for your own function
没理解~~~
---25---
Question:
>Define a class, which have a class parameter and have a same instance parameter
Solution: