for i in range (0, 8, 2): the counter will count by
Create a class RandomNumber, with three static methods: - GetFloat will return a number between 0 and 1 using the following algorithm:
seed = ( seed * a + c ) % m result = abs ( seed / m )
- GetInt(max) will return a number from 0 to max, using: result = round(max * GetFloat) - GetInt(min, max) will return a number from min to max (you must create this one totally on your own). The starting values must be: m = 233280; a = 9301; c = 49297; seed = 1;
Create a class "House", with an attribute "area", a constructor that sets its value and a method "ShowData" to display "I am a house, my area is 200 m2" (instead of 200, it will show the real surface). Include getters an setters for the area, too. The "House" will contain a door. Each door will have an attribute "color" (a string), and a method "ShowData" wich will display "I am a door, my color is brown" (or whatever
color it really is). Include a getter and a setter. Also, create a "GetDoor" in the house. A "SmallApartment" is a subclass of House, with a preset area of 50 m2.
Also create a class Person, with a name (string). Each person will have a house. The method "ShowData" for a person will display his/her name, show the data of his/her house and the data of the door of that house. Write a Main to create a SmallApartment, a person to live in it, and to show the data of the person.
Complete the project named "Shapes", adding a class named "Square" to it. For each square, we will store its starting X and Y coordinates (the upper left corner, already stored as a "Location") and the length of its side.
You will have to create:
- A suitable constructor, to assign starting values to X, Y and the side. (2 points)
- A Move method, to change X and Y coordinates. (1 point)
- A Scale method, to change its side (for example, a scale factor of 2 would turn a side of 3 into 6). (1 point)
- A method ToString, to return a string with its data (for example: "Corner (10,5), side 7". (1 point)
- Redefine "GetPerimeter" and "GetArea", so that they return the correct values (2 points).
- Another point corresponds to the attributes and the overall structure.
- The remaining 2 points correspond to the test from "Main"
Complete the project named "Shapes", adding a class named "Square" to it. For each square, we will store its starting X and Y coordinates (the upper left corner, already stored as a "Location") and the length of its side.
You will have to create:
- A suitable constructor, to assign starting values to X, Y and the side. (2 points)
- A Move method, to change X and Y coordinates. (1 point)
- A Scale method, to change its side (for example, a scale factor of 2 would turn a side of 3 into 6). (1 point)
- A method ToString, to return a string with its data (for example: "Corner (10,5), side 7". (1 point)
- Redefine "GetPerimeter" and "GetArea", so that they return the correct values (2 points).
- Another point corresponds to the attributes and the overall structure.
- The remaining 2 points correspond to the test from "Main"
Create a class "PhotoAlbum" with a private attribute "numberOfPages."It should also have a public method "GetNumberOfPages", which will return the number of pages.The default constructor will create an album with 16 pages. There will be an additional constructor, with which we can specify the number of pages we want in the lbum. Create a class "BigPhotoAlbum" whose constructor will create an album with 64 pages. Create a test class "AlbumTest" to create an album with its default constructor, one with 24 pages, a "BigPhotoAlbum" and show the number of pages that the three albums have.
Create a new project, and include in it the class Person that you just created. Create a class "Student" and another class "Teacher", both descendants of "Person". The class "Student" will have a public method "GoToClasses", which will write on screen "I’m going to class."The class "Teacher" will have a public method "Explain", which will show on screen "Explanation begins". Also, it will have a private attribute "subject", a string.The class Person must have a method "SetAge (int n)" which will indicate the value of their age (eg, 20 years old). The student will have a public method "ShowAge" which will write on the screen "My age is: 20 years old" (or the corresponding number). You must create another test class called "StudentAndTeacherTest" that will contain "Main" and:
• Create a Person and make it say hello
• Create a student, set his age to 21, tell him to Greet and display his age
• Create a teacher, 30 years old, ask him to say hello and then explain.
This assignment is based on Exercise 8.4 from your textbook. Each of the following Python functions is supposed to check whether its argument has any lowercase letters.
For each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect.
# 1
def any_lowercase1(s):
for c in s:
if c.islower():
return True
else:
return False
# 2
def any_lowercase2(s):
for c in s:
if 'c'.islower():
return 'True'
else:
return 'False'
# 3
def any_lowercase3(s):
for c in s:
flag = c.islower()
return flag
# 4
def any_lowercase4(s):
flag = False
for c in s:
flag = flag or c.islower()
return flag
# 5
def any_lowercase5(s):
for c in s:
if not c.islower():
return False
return True
write a UDF to return the descriptive [sum, count, min, mean, max] for a list of n number of input numbers.
Why Is Method main Declared static?