TORONTO KIDS COMPUTER CLUB | Markham Saturday 9:30 Python Homework 20.08.01.
18065
post-template-default,single,single-post,postid-18065,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Markham Saturday 9:30 Python Homework 20.08.01.

04 Aug Markham Saturday 9:30 Python Homework 20.08.01.

Question 1:
Modify the Dice class we made in the last class, so it could compare with different dies using ==. In order to complete this task, you need to overwrite __eq__.


Question 2:
Create Card class so it can complete the following tasks:

  • Card() – You can initial the card with random value (Assume the smallest card value is ‘2’, then followed by ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ’10’, ‘J’, ‘Q’, ‘K’, ‘A’) and according rank (integer from 2 to 14).
  • Shuffle() – will randomly change the card value and rank and return its rank.
  • you can compare two card object like c1>c2 and c1==c2.
  • you can use print(c1) shows the card value
  • you can use print([c1,c2]) show each card value and rank in the list

No Comments

Sorry, the comment form is closed at this time.