Saturday 14:00 Homework
Home > Saturday 14:00 Homework (Page 10)
Question:
Make a program to verify whether the credit card numbers from ABCD Bank are valid or not.
A valid credit card from ABCD Bank has the following characteristics:
It must start with a 4, 5 or 6.
It must contain exactly 16 digits.
It must only consist...
Question:
Create an OunceConversion object to convert any number of fluid ounces to the equivalent number of gallons, quarts, pints, and gills. (There are 128 fluid ounces in a gallon. There are 32 fluid ounces in a quart. There are 16 fluid ounces in a pint. There are 4 fluid...
Question:
You are given a string . Suppose a character 'a' occurs consecutively n times in the string. Replace these consecutive occurrences of the character 'a' with (n, 'a') in the string.
Input Format: A single line of input consisting of the string .
Output Format: A single line of...
Question:
Using function or object method to write a program to return the number of times that the string
"code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
For example:
'aaacodebbb' will have 1 "code"
'codexxcode' will have 2 "code"
'cozexxcope'...
Question:
Write a Python program (either use function or object method) to check the validity of password input by users.
Validation :
At least 1 letter between [a-z] and 1 letter between[A-Z].
At least 1 number between [0-9].
At least 1 character from [$#@].
Minimum length 6...
Question:
Create an object WordReverse to reverse a string.
You need one argument (which is the original string) to create the object.
def __init__(self, word):
You need one method to reverse the string
def reverse(self):
You can print the object with the following expected output...
Question 1.
Write a short program to generate a list of five random integer numbers from 1 to 20, and print them out.
Question 2.
Write a short program that prints out a random decimal number every 3 seconds for 30 seconds.
Hint: You need import module time. time.sleep(5) means wait 5 seconds
Bonus...
Question:
Create a Tank object which have the attributes of:
name
direction(up/down/left/right)
x position and
y position
The Tank object also have a method:
move (direction, steps)
Using __init__ to Initial the tank to make sure it start from x position of 0 and y position of 0
Print out...
Question:
Make a class definition for a BankAccount. It should have attributes for :
– its name (a string),
– account number (a string or integer),
– and balance (a float).
It should have methods to:
– make deposits with displaying the balance,
– and make withdrawals with displaying the balance.
...
Question:
Please write a program using function. Each player in a tournament plays six games. There are no ties. The tournament director places the players in groups based on the results of games as follows:
if a player wins 5 or 6 games, they are placed...