python基础单选题汇总_CSDN经典:Python基础练习100题(1~ 5)汇总前辈们智慧的结晶练习题(上篇)...

说起来有很长一段时间没有逛博客了,今天也是突发奇想的不知道咋回事就逛起了博客,看到了这篇文章!原作者是在Python2的时候创建的,分享10道python基础练习题,这里面课都是前辈们的智慧结晶啊,总之了:个人觉得,是非常适合小白来练习,一起来看看吧!

Question 1:

* Write a program which can compute the factorial of a given numbers.The results should be printed in a comma-separated sequence on a single line Suppose the following input is supplied to the program: 8

Then, the output should be:40320 *

解法一:

解法二:

(这两个不同的解法可还看得懂?很简单的逻辑思维解题法)

Question 3:

With a given integral number n, write a program to generate a dictionary that contains (i, i x i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary.Suppose the following input is supplied to the program: 8

Then, the output should be:

{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}

解法一:

解法二:

(这道题个人还是挺喜欢的,越喜欢就越佩服出题人的智慧)

Question 4:

Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number.Suppose the following input is supplied to the program:

34,67,55,33,12,98

Then, the output should be:

['34', '67', '55', '33', '12', '98']

('34', '67', '55', '33', '12', '98')

解法一:

(这道题个人也很喜欢,入门时候基本上百分90的人都有做过吧?)

Question 5:

Define a class which has at least two methods:getString: to get a string from console input

printString: to print the string in upper case.

Also please include simple test function to test the class methods.

解法一:

更多相关CSDN经典:Python基础练习100题内容关注小编敬请期待为你带来更优质的相关文章!

谢谢各位的关注收藏,我们下期再见。

CSDN经典:Python基础练习100题 ( 5~10)汇总大家智慧的结晶下篇

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值