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

2. Cubes and Squares

by CodeChum Admin


Instructions:

  1. An array containing 40 integer elements is already provided for you in the code editor below.
  2. Using loops and conditions, print out the cube of the array element if it is a positive number, and print out the square of the number if it is negative. Each result must be printed out separately by each line.



Output

The squares and cubes of the elements in the array.

4
1
1
8
27
.
.
.

Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is


where: h=(q+²⁶(m+I)/10 + k/4 + i/4 + 5i)%7



• h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday).


• q is the day of the month


• m is the month (3: March, 4: April, …, 12: December). January and February are counted as months 13 and 14 of the previous year.


• j is the century (i.e., Year/100).


• k is the year of the century (i.e., year%100)



Note that the division in the formula performs an integer division. Write a program that prompts the user to enter a year, month, and day of the month, and displays the name of the day of the


week. Here are some sample runs:



(Hint: January and February are counted as 13 and 14 in the formula, so you need to convert the user input 1 to 13 and 2 to 14 for the month and change the year to the previous year.)

Create a program that will accept number of students and number of quizzes of students. Based on this input the program will accept the name of the student and the quiz grades of the student. The input will be stored to a dictionary. The name of the student will be the key and the quizzes will be the value in list format (e.g., {“Jose S. Uy”: [87,90,97,80,95], “Rowena M. Evangelista”: [88,87,90,97,83].


The program will output the list of quizzes per student, the lowest quiz, the highest quiz, and the average quiz grade.




Write a program to calculate the average of

all scores entered between 0 and 100. Use a

sentinel-controlled loop variable to terminate the

loop. After values are entered and the average

calculated, test the average to determine whether

an A, B, C, D, or F should be recorded.




lat = [40.59, 40.52, 40.621, 40.519, 40.56, 41.265, 40.61, 40.806, 41.259, 41.265, 41.264, 41.264, 41.259, 41.262, 41.263]
lon = [69.532, 69.419, 69.354, 69.263, 69.478, 70.805, 69.706, 70.331, 70.815, 70.823, 70.815, 70.81, 70.824, 70.811, 70.811]

The lat list indicates how far north and south Gracie the seal has traveled, and the long list represents how far east and west she has traveled. The larger the latitude value, the further north the seal was located, and for this area of the world, the larger the longitude value, the further west the seal is located.

Write a program to calculate the farthest in each direction that Gracie was located throughout her travels. Add four print statements to the lines of code above that output the following, where the number signs are replaced with the correct values from the correct list:

Farthest north = #
Farthest west = #
Farthest south = #
Farthest east = #








The possible denominations of currency notes are 100,50,20 and 10. The amount A to be withdrawn is given as input.




Write a program to break the amount into minimum number of bank notes.

Program to calculate the average of all score entered between 0 to 100. Use sentinel- controlled loop variable


an ecommerce company plans to give their customers a discount for the new year. the discount will be calculated on the basis of the bill amount is the product of the sum of all odd digits and the sum of even digits of the customer's total bill. if no odd-even digit is represented in the bill amount then 0 will be returned?

6. The Big One

by CodeChum Admin

Remember that time when we've tried identifying the largest digit among the given integer? Well, let's take it to the next level, and figure out the same thing on arrays/lists!


Let's do this one more time!


Instructions:

  1. Create a variable that accepts a positive integer.
  2. Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted positive integer given in the first instruction.
  3. Print out the largest integer among all the elements on the list, by any means necessary.

Input

The first line contains the size of the array/list.

The next lines contains an integer on each.

5
5
34
3
23
10

Output

A line containing an integer.

34

5. Groupings

by CodeChum Admin

Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.


Instructions:

  1. Create a variable that accepts a positive odd integer.
  2. Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
  3. Reverse the order of the list. Then, print out the list's new order in this manner:
  4. [first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.

Input

The first line contains an odd positive integer.

The next lines contains an integer.

5
1
3
4
5
2

Output

A line containing a list.

[2,5]-[4]-[3,1]
LATEST TUTORIALS
APPROVED BY CLIENTS