Author: admin
Home > Articles posted by admin (Page 9)
Question:
Write a function luckySum(a, b, c) to calculate sum of given 3 int values, a b c. The function will have a return value of their sum. However, if one of the values is 13 then it does not count towards the sum and values to its...
Question:
How to create ending screen shows the following 3 lines of information:
Game Over
Your score is: ??
press space to restart
and the game will be restarted if you press the space.
...
Question 1:
Use TKinter to create following window with three buttons:
the “blue” button will show “blue” in the label
the “red” button will show “red” in the label
if left mouse button click the “color” button will show “blue” in the label, while right mouse...
Question:
How to create ending screen shows the following 3 lines of information:
Game Over
Your score is: ??
press space to restart
and the game will be restarted if you press the space.
...
Question:
Continue modify the program we made in the class:
create Energy class. A new energy crystal object will be created when the enemy spaceship explode, the energy will bounce in the window with x speed of randint(-3, 3) and y speed of randint(1, 2)
use spritecollide...
Question 1:
Create a Python class Person with attributes: name and age of type string.
Create a display() method that displays the name and age of an object created via the Person class.
Create a child class Student which inherits from the Person class and which also has a section attribute.
Create a method displayStudent() that displays the name,...
Question:
The factorial function (symbol: !) says to multiply all whole numbers from our chosen number down to 1.
Examples:
4! = 4 × 3 × 2 × 1 = 24
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040
1! = 1
Factorial is not defined for...
Question:
A provincial government is going to build roads to connect of any two towns in the province(but not necessarily directly connected by road, as long as it can be reached indirectly by road). They have the table lists the distance between any two towns. The...
Question:
A common problem in mathematics is to determine which quadrant a given point lies in. There are four quadrants, numbered from 1 to 4, as shown in the diagram below:
For example, the point A, which is at coordinates (12, 5) lies in quadrant 1 since...
Question 1:
Jack has an LED clock radio, which is a 12-hour clock, displaying times from 12:00 to 11:59. The hours do not have leading zeros but minutes may have leading zeros, such as 2:07 or 11:03.
When looking at her LED clock radio, Jack likes to...