PYTHON PRACTICE

  1. Print out “This is python class”
  2. Print out the remainder of 97 divided by 24
  3. Print out the result of 4 power 6
  4. The price of apple is 8, you have cash 100, you want to buy two apples, calculate the money you have(calculate it with variables total, apple, remain)
  5. make an introduction
    example:
    name = …
    age = …
    gender = …
    hobby = …
    print out the result using variable. The string will look like this:
    my name is xxx, I am xx years old, I am a xxx(gender), I like xxx(hobby)
  6. make an introduction with input().
  7. create a list with your favorite singers,
    then append it, insert it, pop it, take out the value where the index is 1
  8. create a dictionary where key is everybody’s name in this class, value is gender.
    Then take out the value where the key is your name
  9. create two sets s1 = {1, 2, 3, 6, 7, 9}, s2 = {3, 4, 7, 8, 10}, print out s1 & s2, s1 | s2
  10. Bob's height is 1.75m, his weight is 80.5kg, calculate Bob's BMI(weight / (height * height), using 'if elif' print out the result
     below 18.5:too light
     18.5-25:normal
     25-28:fat
     28-32:too fat
     32:super fat
  11. using for loop to print out 'Hello, xxx!':L = ['Bart', 'Lisa', 'Adam']
  12. define a function called quadratic(a, b, c), return answers of ax2 + bx + c = 0 (hint: use math.sqrt())
  13. Hanoi
  14. Yanghui Triangle:
    <pre>
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    1 5 10 10 5 1
    </pre>

consider every row as a list, using generator to print it out

  1. using map() function to transfer username into formatted name
    input:['adam', 'LISA', 'barT']
    output:['Adam', 'Lisa', 'Bart']:
  2. create a function to calculate the production of each number in the list.
    input:[1, 2, 3, 4]
    output: 24
    hint:using reduce()
  3. filter the palindrome number(123454321)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容