TORONTO KIDS COMPUTER CLUB | Wednesday Friday 15:00 Python Practice 20.08.19.
18169
post-template-default,single,single-post,postid-18169,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Wednesday Friday 15:00 Python Practice 20.08.19.

20 Aug Wednesday Friday 15:00 Python Practice 20.08.19.

Question:

  • Create a list called “attributes” , it contains “HP”, “Attack”, “Defense”, “Special Attack”, “Special Defense”, “Speed”
  • Modify the list above, replace “Special Attack” and “Special Defense” with “Magic” and “Stamina”
  • Add “Special skills” in the end of the list
  • Delete “Speed” from the list.
  • Insert “Special Attack” and “Special Defense” just before “Special skills”
2 Comments
  • Jesse Shi
    Posted at 18:26h, 21 August Reply

    attributes = [“HP”, “Attack”, “Defense”, “Special Attack”, “Special Defence”, “Speed”]
    print (attributes)
    [‘HP’, ‘Attack’, ‘Defense’, ‘Special Attack’, ‘Special Defence’, ‘Speed’]

    (attributes.pop(5))
    ‘Speed’
    print(attributes)
    [‘HP’, ‘Attack’, ‘Defense’, ‘Special Attack’, ‘Special Defence’]

    attributes.insert(len(attributes), “Special skills”)
    >>> attributes
    [‘HP’, ‘Attack’, ‘Defense’, ‘Special Attack’, ‘Special Defence’, ‘Special skills’]

    attributes[3] = “Magic”
    attributes[4] = “Stamina”
    print(attributes)
    [‘HP’, ‘Attack’, ‘Defense’, ‘Magic’, ‘Stamina’, ‘Special skills’]

  • Ethan Li
    Posted at 18:52h, 21 August Reply

    a=[‘HP’,’Attack’, ‘Defense’,’Special Attack’,’Special Defense’,’Speed’]

    a[4]:’Magic’
    a[5]:’Stamina’

    a. append(‘Special skills’)

    del a[6]

    a.insert(6, ‘Special Attack’)
    a. insert(7, ‘Special Defense’)

Post A Comment