Write a Python class named Product which has attributes product_id, product_name,
number of items. Include the constructor and other required methods to set and get the
class attributes. The class should have 2 additional methods to add and remove products
from the inventory. If the number of items for a product in the inventory is less than zero,
the user should be notified with a print message stating, “Product is out of stock”. Create
2 instances of the class and display all its associated attributes.
simple code
please find the question on below link:
https://drive.google.com/file/d/17pfgTzAo5QxJ0K511KVR59WrywFI6iyH/view?usp=sharing
2. Write a Matlab function that accepts a vector of values and returns a vector of derivatives at those points. You can assume that the values are given on an equally spaced array with spacing h. Use the two point central difference formula df dx = fi+1 − fi−1 2h for all points except the two endpoints. For the endpoints use a one-sided derivative that uses two points. The function should have the form
The following C++ program segment computes C = A * B, where A is an “m” by “n”
matrix, B is an “n” by “r” matrix and C is an “m” by “r” matrix.
for (long int i = 0; i < m; i++)
for (long int j = 0; j < r; j++)
{
long double Sum = 0;
for (long int k = 0; k < n; k++)
Sum = Sum + A[i][k] * B[k][j];
C[i][j] = Sum;
}
i) How many times does the code iterate in computing Sum?
ii) How many times does the code iterate in computing the j column of C, i.e. C[i][j] for a fixed i and j = 1, 2, 3, ..., r?
iii) How many times does the code iterate in computing the complete matrix C?
a) How many logs are in the stack?
Create class SavingsAccount. Use a static variable annualInterestRate to store the annual
interest rate for all account holders. Each object of the class contains a private instance variable
savingsBalance indicating the amount the saver currently has on deposit. Provide method
calculateMonthlyInterest to calculate the monthly interest by multiplying the
savingsBalance by annualInterestRate divided by 12—this interest should be added to
savingsBalance. Provide a method modifyInterestRate that sets the
annualInterestRate to a new value.
Write a program to test class SavingsAccount. Instantiate two savingsAccount objects, saver1
and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to
4%, then calculate the monthly interest for each of 12 months and print the new balances for both savers.
Next, set the annualInterestRate to 5%, calculate the next month’s interest and print the new
balances for both savers. Also, provide the UML class diagram of your class.
Write a program to print the right alphabet tringle up to the given N rows.
Input
The input be a single line containing a positive integer(N).
Output
The output should bbe N rows with letters.
Note:there is a space after each letter.
Explanation:
For example, if the given number of rows is 4, your code should print the following pattern.
A
A B
A B C
A B C D
Input:
4
Output:
A
A B
A B C
A B C D
Enter·the·first·character:·C
Enter·the·second·character:·c
Enter·the·third·character:·C
Not·Equal
Write a python function Count_Freq(A) which take a dictionary containing numbers. The function will return a dictionary containing key as a number and value as frequency defining how many times the number is repeating in the dictionary.
Example-1
Example-2
Input:
{'V': 10, 'VI': 10, 'VII': 40, 'VIII': 20, 'IX': 70, 'X': 80, 'XI': 40, 'XII': 20}
Output:
({10: 2, 40: 2, 20: 2, 70: 1, 80: 1})
Input:
{'V': 10, 'VI': 10, 'VII': 10, 'VIII': 10, 'IX': 20, 'X': 30, 'XI': 40, 'XII': 20}
Output:
({10: 4, 20: 2, 30: 1, 40: 1})
by CodeChum Admin
One good implementation of computing infix expressions is to transform them to postfix and then evaluate via the postfix expression.
Infix expressions is the common way of writing arithmetic expressions. The binary operator come between them as shown below:
More info here, Important!
https://pastebin.com/6qLXQ9Md