Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Using array-like vector of unknowns for the ode equation at time t, classes, and the integrate.odeint function, find dependence of the period of a pendulum's motion as a function of its initial amplitude.


And use scipy.interpolate.interp1d() to plot a graph of period as a function of amplitude and find the period of oscillation.


After your program has prompted the user for how many values should be in the array, generated those values, and printed the whole list, create and call a new function named sumArray. In this method, accept the array as the parameter. Inside, you should sum together all values and then return that value back to the original method call. Finally, print that sum of values.

Sample Run

How many values to add to the array: 
8
[17, 99, 54, 88, 55, 47, 11, 97]
Total 468

Task Description

 

You are to present your findings in the form of a problem based report. This report should describe how you implemented the program (source code and screen shots).

 

Assignment Task

 

  1. How many seconds are in an hour? Use the interactive interpreter as a calculator and multiply the number of seconds in a minute (60) by the number of minutes in an

hour (also 60).

 

  1. Assign the result from the previous task (seconds in an hour) to a variable called seconds_per_hour.

 

  1. How many seconds are in a day? Use your seconds_per_hour variable.

 

  1. Calculate seconds per day again, but this time save the result in a variable called seconds_per_day.

 

  1. Divide seconds_per_day by seconds_per_hour. Use floating-point (/) division.

 

  1. Divide seconds_per_day by seconds_per_hour, using integer (//) division. Did

this number agree with the floating-point value from the previous question, aside from the final .0?


  1. Create a list called years_list, starting with the year of your birth, and each year thereafter until the year of your fifth birthday. For example, if you were born in 1980 the list would be years_list = [1980, 1981, 1982, 1983, 1984, 1985].

 

  1. In which year in years_list was your third birthday? Remember, you were 0 years of age for your first year.

 

  1. In which year in years_list were you the oldest?

Time Converter

In this assignment, let's build a Time Converter by applying the concepts we learned till now.

Refer to the below image.


https://assets.ccbp.in/frontend/content/dynamic-webapps/time-converter-output.gif


Instructions:

  • The HTML input element for entering the number of hours should have the id hoursInput
  • The HTML input element for entering the number of minutes should have the id minutesInput
  • Add HTML label elements for HTML input elements with ids hoursInput and minutesInput
  • The HTML button element should have the id convertBtn
  • The HTML p element to display the converted time in seconds should have the id timeInSeconds
  • The HTML p element to display the error message should have the id errorMsg

By following the above instructions, achieve the given functionality.

  • When values are entered in HTML input elements with ids hoursInput and minutesInput, the HTML button with id convertBtn is clicked
  • The converted time in seconds should be displayed in the HTML p element with id timeInSeconds
  • The HTML p element with id errorMsg should be empty
  • The HTML p element with id errorMsg should display an error message in the following cases
  • When the HTML input element with id hoursInput is empty and convertBtn is clicked
  • When the HTML input element with id minutesInput is empty and convertBtn is clicked
  • When both the HTML input elements hoursInput and minutesInput are empty and convertBtn is clicked

Quick Tip

  • timeInSeconds = ((hours) *60 + minutes) * 60

Note

  • The values given for the HTML input elements with ids hoursInput and minutesInput should be positive integers.

Resources

Use this Background image:

  • https://assets.ccbp.in/frontend/dynamic-webapps/time-converter-bg.png

CSS Colors used:

Text colors Hex code values used:

#f5f7fa

#000000

#ffffff


CSS Font families used:

  • Open Sans

 Given product code, name, and price for n=7 products as shown in the code snippet

below.

prod = [11, 22, 32, 44, 55, 66, 77]

name = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg'] price = [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7]

Generate a discounted price report given the below discounts:

20% discount if price is more than $400.00

15% discount if price is between $300.00 and $400.00 (both inclusive) 10% discount if price is less than $300.00

Your output should resemble as follows:

      Discounted Price List

No.   Code    Name    Price

1 xxx xxx xxx

2 xxx xxx xxx

...

New Price xxx

xxx


Tic-Tac-Toe game
Abhinav and Anjali are playing the Tic-Tac-Toe game. Tic-Tac-Toe is a game played on a grid that's three squares by three squares. Abhinav is O, and Anjali is X. Players take turns putting their marks in empty squares. The first player to get 3 of her marks in a diagonal or horizontal, or vertical row is the winner. When all nine squares are complete, the game is over. If no player has three marks in a row, the game ends in a tie. Write a program to decide the winner in the Tic-Tac-Toe game.
Input

The input will be three lines contain O's and X's separated by space.
Output

The output should be a single line containing either "Abhinav Wins" or "Anjali Wins" or "Tie".
Explanation

For example, if the input is 

O X O
O X X
O O X 

 
as three of O's are in vertical row print "Abhinav Wins".
Sample Input 1
O X O
O X X
O O X
Sample Output 1
Abhinav Wins

Sample Input 2
O O X
X X O
X O O
Sample Output 2
Anjali Wins
Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0 format.
Input

The first line contains a single integer N. 
Next N lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes coefficient of Pi.
Output

Print the polynomial in the format Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is coefficient, and C0 is constant. There will be space before and after the plus or minus sign. 
If the coefficient is zero, then don't print the term. 
If the term with the highest degree is negative, the term should represent  -Cix^Pi. 
For the term where power is 1, represent it as C1x instead of C1x^1. 
If the polynomial degree is zero and the constant term is also zero, then print 0 to represent the polynomial.
For term Cix^Pi, if the coefficient of the term Ci is 1, print x^Pi instead of 1x^Pi.
Explanation

If N = 4
For power 0, the coefficient is 5
For power 1, the coefficient is 0
For power 2, the coefficient is 10
For power 3, the coefficient is 6.
Then polynomial represents "6x^3 + 10x^2 + 5"
Constraints

N <= 100
0 <= Pi < 1000
-1000 <= Ci <= 1000
Sample Input 
4
0 5
1 0
2 10
3 6
Sample Output 
6x^3 + 10x^2 + 5
Given a sentence S, write a program to print the frequency of each word in S. The output order should correspond with the word's input order of appearance.
Input

The input will be a single line containing a sentence S.
Output

The output contains multiple lines, with each line containing a word and its count separated by ": " with the order of appearance in the given sentence.
Explanation

For example, if the given sentence is "Hello world, welcome to python world", the output should be 
Hello: 1
world: 2
welcome: 1
to: 1
python: 1
Sample Input 1
Hello world welcome to python world
Sample Output 1
Hello: 1
world: 2
welcome: 1
to: 1
python: 1

Sample Input 2
This is my book
Sample Output 2
This: 1
is: 1
my: 1
book: 1
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. 
Input

The first line contains a single integer N.
Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).
Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).
-1 will represent the end of input.
Output

For each Query operation print the element present at row index K and colum index L of the matrix in its current state.
Explanation

For Input:
2
1 2
3 4
R 90
Q 0 0
Q 0 1
R 90
Q 0 0
U 0 0 6
Q 1 1
-1

Initial Matrix
1 2
3 4

For R 90, clockwise rotation by 90 degrees, the matrix will become
3 1
4 2

For Q 0 0, print the element at row index 0 and column index 0 of A, which is 3. 
For Q 0 1, print the element at row index 0 and column index 1 of A, which is 1. 

Again for R 90, clockwise rotation by 90 degrees, the matrix will become
4 3
2 1

For Q 0 0, print the element at row index 0 and column index 0 of A, which is 4. 

For U 0 0 6, update the value at row index 0 and column index 1 in the initial matrix to 6. So the updated matrix will be,
6 2
3 4
After updating, we need to rotate the matrix by sum of all rotation angles applied till now(i.e. R 90 and R 90 => 90 + 90 => 180 degrees in clockwise direction).
After rotation the matrix will now become
4 3
2 6

Next for Q 1 1, print the element at row index 1 and column index 1 of A, which is 6. 
output 
3
1
4
6
Sample Input 1
2
1 2
3 4
R 90
Q 0 0
Q 0 1
R 90
Q 0 0
U 0 0 6
Q 1 1
-1
Sample Output 1
3
1
4
6

Sample Input 2
2
5 6
7 8
R 90
Q 0 1
R 270
Q 1 1
R 180
U 0 0 4
Q 0 0
-1
Sample Output 2
5
8
8

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. Input


The first line contains a single integer N.

Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).

Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).

-1 will represent the end of input.Output


For each Query operation print the element present at row index K and colum index L of the matrix in its current state.Explanation


For Input:

2

1 2

3 4

R 90

Q 0 0

Q 0 1

R 90

Q 0 0

U 0 0 6

Q 1 1

-1


Initial Matrix

1 2

3 4


For R 90, clockwise rotation by 90 degrees, the matrix will become

3 1

4 2


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 3.

For Q 0 1, print the element at row index 0 and column index 1 of A, which is 1.


Again for R 90, clockwise rotation by 90 degrees, the matrix will become

4 3

2 1


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 4.


For U 0 0 6, update the value at row index 0 and column index 1 in the initial matrix to 6. So the updated matrix will be,

6 2

3 4

After updating, we need to rotate the matrix by sum of all rotation angles applied till now(i.e. R 90 and R 90 => 90 + 90 => 180 degrees in clockwise direction).

After rotation the matrix will now become

4 3

2 6


Next for Q 1 1, print the element at row index 1 and column index 1 of A, which is 6.

output

3

1

4

6

Sample Input 1

2

1 2

3 4

R 90

Q 0 0

Q 0 1

R 90

Q 0 0

U 0 0 6

Q 1 1

-1

Sample Output 1

3

1

4

6

Sample Input 2

2

5 6

7 8

R 90

Q 0 1

R 270

Q 1 1

R 180

U 0 0 4

Q 0 0

-1

Sample Output 2

5

8

8


please give me the best solution.


LATEST TUTORIALS
APPROVED BY CLIENTS