Uncategorized
Home > Uncategorized (Page 8)
Posted at 01:50h
in
Uncategorized
by admin
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.
Hint:
...
Posted at 21:45h
in
Uncategorized
by admin
Question:
Alice is looking at a crystal through a microscope. Alice’s microscope has the interesting feature that it can superimpose grid lines over the image that she is looking at.
At level 1 of magnification, Alice sees the image as follows:
Notice that at level 1, there is...
Posted at 23:46h
in
Uncategorized
by admin
Question 1:
Write a program that asks the user to enter his/her name, age, favorite color, and favorite food. Have the program save all four items to a text file called myinfo.txt, each one on a separate line.
Question 2:
Write a program that asks the user to enter...
Posted at 23:45h
in
Uncategorized
by admin
Question 1:
Write a program that asks the user to enter his/her name, age, favorite color, and favorite food. Have the program save all four items to a text file called myinfo.txt, each one on a separate line.
Question 2:
Write a program that asks the user to...
Posted at 17:41h
in
Uncategorized
by admin
Question:
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 Employee which inherits from the Person class and which also has two attributes position and...
Posted at 18:16h
in
Uncategorized
by admin
Question 1:
The hailstone sequence starting at a positive integer n is generated by following two simple rules. If n is even, the next number in the sequence is n/2. If n is odd, the next number in the sequence is 3*n+1. Repeating this process, we generate the hailstone sequence. Write a recursive function hailstone(n) which prints the...
Posted at 01:50h
in
Uncategorized
by admin
Question:
The International Standard Book Number (ISBN) is a 13-digit code for identifying books. These numbers have a special property for detecting whether the number was written correctly.
The 1-3-sum of a 13-digit number is calculated by multiplying the digits alternately by 1’s and 3’s (see example)...
Posted at 01:49h
in
Uncategorized
by admin
Question:
Create a class called Food. The class should contain three class attributes, the name of the food(string), the sugar(int or float), and the fat(int or float) content.
The tastiness of a particular food is based on the amount of sugar + fat that food has. So...
Posted at 01:32h
in
Uncategorized
by admin
Question:
write a program to ask user about the date(year, month and day), then pass these year month and day as arguments to a function calcDay that return the day of the year.
Sample input:
Year: 2016
Month: 6
Day: 23
Sample output:
Day of the year: 175
Hint:
You need consider leap...
Posted at 01:24h
in
Uncategorized
by admin
Question 1:
Use recursion to write a function divides_all that consumes a list of positive integers seq and a positive integer factor. Your function should produce True if every item in seq is a multiple of factor and False otherwise. The helper function is_multiple has been provided for you.
Question 2:
Use recursion to write a function reverse that consumes a list seq and produces a new...