Write the definition of a class Counter containing:
Write a program that asks the user for a number between 10 and 30 inclusive and will validate, that is test, the input. It should repeatedly ask the user for this number until the input is within the valid range.
I don't really understand this
Day:
Month:
Year: Then, your program should ask the user to select from a menu of choices using this formatting:
Menu:
1) Calculate the number of days in the given month.
2) Calculate the number of days left in the given year.
Please enter a date
Day: 5
Month: 5
Year: 1984
Menu:
1) Calculate the number of days in the given month.
2) Calculate the number of days left in the given year.
1
31Please enter a date
Menu:
1) Calculate the number of days in the given month.
2) Calculate the number of days left in the given year.
31Please enter a date
Day: 21
Month: 6
Year: 2016
Menu:
1) Calculate the number of days in the given month.
2) Calculate the number of days left in the given year.
2
193Please enter a date
Menu:
1) Calculate the number of days in the given month.
2) Calculate the number of days left in the given year.
1931
1 2 1
1 2 4 2 1
1 2 4 8 4 2 1
1 2 4 8 16 8 4 2 1
1 2 4 8 16 32 16 8 4 2 1
1 2 4 8 16 32 64 32 16 8 4 2 1
1 2 4 8 16 32 64 128 64 32 16 8 4 2 1
1 2 4 8 16 32 64 128 256 128 64 32 16 8 4 2 1
By using nested loops, write the code of this triangular shape.
Matrix Rotations
You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.
Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.
Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.
After the update, all the previous rotation operations have to be applied to the updated initial matrix.
Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.
Write a class named "BankAccount" with the following attributes: id, currency and balance. The class has a constructor with only two of the attributes: id and currency. The value of the currency, if omitted, has a default value "EUR0". The third attribute by default is zero. We suppose that when we activate a bank account its balance is initially empty.
Task 2:
Write a Python class named "Calculator" that has no attributes.The class has only one method named "performOperation()" that takes in input three parameters, two numeric values (A and B) and one string value representing one of the four basic mathematical operations (+","", "*" or "/"). For each operation, it returns the result of the respective operation for the two numbers. In case the second value is zero and the operation is "/", the method returns a string message "Error: Can not divide by zero". If the operation is not as expected, the method returns a string message "Error: Operation not supported".
Write a Python class named "Pencil" that has three attributes: brand (string), color (string), thickness (int).
The class must include a constructor method that initializes each variable to an appropriate value, and the class should include methods for setting the value of each type and retrieving the value of each type.
#active buzzer code
loco_iot.enable(msg.SUBTYPE_DO_1)
data = [1]
loco_iot.setData(msg.SUBTYPE_DO_1, data)
time.sleep(2)
data = [0]
loco_iot.setData(msg.SUBTYPE_DO_1, data)
#code lcd
loco_iot.enable(msg.SUBTYPE_LCD)
data = [4, 1, ord('a')]
loco_iot.setData(msg.SUBTYPE_LCD, data)
data = [5, 1, ord('b')]
loco_iot.setData(msg.SUBTYPE_LCD, data)
time.sleep(5)
5a) Push button + LCD + Buzzer + LED
Write a Python program to create two polyphonic tones using the Buzzer and a push-button to switch between the two tones. Interface the LCD to display which tone is currently being played, and an LED to blink at random intervals when
5a) Push button + LCD + Buzzer + LED
Write a Python program to create two polyphonic tones using the Buzzer and a push-button to switch between the two tones. Interface the LCD to display which tone is currently being played, and an LED to blink at random intervals when the tone is played.