python二级选择题简书,Python-21~25题

---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:

解法一:

972912dc66f1

解法二

972912dc66f1

972912dc66f1

---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:

解法一

972912dc66f1

972912dc66f1

解法二

972912dc66f1

972912dc66f1

---23---

Question:

>Write a method which can calculate square value of number

Solution:

972912dc66f1

972912dc66f1

---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:

972912dc66f1

972912dc66f1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值