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

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]

4. What's in There?

by CodeChum Admin

Let's try defining the size of the list and create the contents of it on our own! And then, to give off a sense of excitement, let's try accessing the value of a list element in a random index position!

Let's do this fast!

Input

The first line contains an integer n which is the size of the array.

The next n lines contains a string on each.

The last line contains an integer which is the index to be accessed and printed.

6
Learning
Programming
made
easy
with
Cody!
5

Output

A line containing a string.

Cody!




3. Decimal Count-off

by CodeChum Admin

Counting off a list of decimal numbers is hard when you speak it, but not when you code it! Don't believe me? Then let's try coding just that!


Instructions

  1. A list containing 10 predefined float values are already provided for you in the code editor. Print each of the element out in separate lines, starting from the last list element down to the first.

Output

Multiple lines containing a decimal number.

5.1
5.5
4.00001
4.024
3.0
3.66
2.5
2.2
1.2054
1.4

2. Cubes and Squares

by CodeChum Admin

You can also make a list of numbers, ey? Let's go and have some fun in tweaking the values of each element, but let's give it some twist to add on some fun to the code.


Let's have a go at it!


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.

Instructions

  1. A list containing 5 integer elements is already provided for you in the code editor below.
  2. Using loops and conditions, print out the cube of the list 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
.
.
.

1. String Replacement

by CodeChum Admin

Lists are fun to make, but it's even better to add or remove things from it when it's not usable anymore, right? Let's do just that in this problem now!


Instructions

  1. Create two variables that will accept string values.
  2. A list containing three string values is already given to you in the code editor on the side. First, insert the first inputted string to the end of the list.
  3. Then, insert the second inputted string into the beginning of the list.
  4. There are now 5 elements on the given list. Now, remove the 3rd element of the list. Apply the concept of index positions in order to access the 3rd string element and successfully remove it from the list.
  5. Print out the remaining contents on the list, each separated by a new line, using loops.

Input

Two lines containing a string.

fun
Python

Output

A line containing a string.

Python·is·really·fun

Using any loop of your choice create a program that will prompts the user for two numbers and do calculations as follows, starting from the smallest number add the next number if its even or subtract it if its odd, repeat this until you get to the last number. i.e. if you start at 2 to 4, then 2 – 3 + 4( - because 3 is odd and + because 4 is even)


Parents of the pupils of the Park Primary School must pay an amount for outfits for the annual

play. All pupils take part in the play, except the Grade 0 pupils. The amount that the parents have

to pay is calculated as follows:

 The cost of the outfits for Grade 1 and 2 pupils is R45.

 The cost of the outfits for Grades 3 to 5 is R65.

 Grade 6 and 7 pupils may play one or two roles. If they play a lead role, they may only play

one role. The cost of the outfits is R70 if they play one role. If this role is a lead role, the

cost is R100. If they play two roles, the cost is R130

Use a switch statement and write down ONLY the necessary C++ statements to

calculate and display the amount to be paid or display an appropriate error message if

required.

Do NOT write a complete program. Use the following

variables:

int grade;

int fee;

bool leadrole; //true if a child plays a lead role

bool roles2; //true if a child plays 2 roles


Parents of the pupils of the Park Primary School must pay an amount for outfits for the annual

play. All pupils take part in the play, except the Grade 0 pupils. The amount that the parents have

to pay is calculated as follows:

 The cost of the outfits for Grade 1 and 2 pupils is R45.

 The cost of the outfits for Grades 3 to 5 is R65.

 Grade 6 and 7 pupils may play one or two roles. If they play a lead role, they may only play

one role. The cost of the outfits is R70 if they play one role. If this role is a lead role, the

cost is R100. If they play two roles, the cost is R130.


Create a program that takes in a student first name and average mark obtained, the system should the group the students using the first letter in their name modulus 10 [ Remember that characters are considered as numeric values, hence à ƒ ƒ ¢ € ˜Jà ƒ ƒ ¢ € ™%10 is a valid calculation ]. For example if the student name is Cena, then the student belongs to group 7 because à ƒ ƒ ¢ € ˜Cà ƒ ƒ ¢ € ™%10 = 7 and if the name was Jack then the student belongs to group 4. The program should further use the group number to get the group lecturer and class date as follows: [Hint: If the result is 0 then the student belongs to group 10]
LATEST TUTORIALS
APPROVED BY CLIENTS