美文网首页
PYTHON PRACTICE

PYTHON PRACTICE

作者: gaoljay | 来源:发表于2016-09-05 22:03 被阅读0次
    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)

    相关文章

      网友评论

          本文标题:PYTHON PRACTICE

          本文链接:https://www.haomeiwen.com/subject/trzrettx.html