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

4. What's in There?

by CodeChum Admin



Instructions:

  1. Create a variable that accepts a positive integer.
  2. Create an empty list. Then, using loops, add string values to your list using the input() function. The number of string values to be added are dependent on the inputted value on the first inputted integer.
  3. Create another variable that accepts a non-negative integer. The number must only range from 0 until the value of the first inputted integer.
  4. Using your understanding on accessing list elements, access and print out the list element having the index position of the second inputted integer.

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.

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 4th element of the list. Apply the concept of index positions in order to access the 4th 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






5. Decimal Galore


We've been dealing with integers too much, it's time for decimals to shine!


Instructions:

  1. Input five decimal numbers in one line.
  2. Print out the decimal numbers in one line, separated by spaces, and make sure you only print up to 1 decimal place.
  3. Add the first four decimal numbers and check if their sum is greater than the fifth decimal number. Print out "Yes" if they are.

Input

A line containing five decimal numbers separated by a space.

1.1·1.2·1.3·1.4·1.1

Output

The first line contains all the inputted decimal numbers separated by a space.

The second line contains a string which is the result.

1.1·1.2·1.3·1.4·1.1
Yes

First Prime Number

You are given N inputs. Write a program to print the first prime number in the given inputs.

Input

The first line of input is an integer N. The next N lines each contain an integer. Explanation

In the given example of

5 integers

1

10

4

3

2


The output should be

3.

Sample Input 1

5

1

10

4

3

2

Sample Output 1

3

Sample Input 2

4

2

3

5

7

Sample Output 2

2


Average of Given Numbers


You are given space-separated integers as input. Write a program to print the average of the given numbers.


Input


The first line of input contains space-separated integers.


Output


The output should be a float value rounded up to two decimal places.


Explanation


In the example, input is


1, 0, 2, 5, 9, 8. The sum of all numbers present in the list is 25, and their average is 25/6.


So, the output should be


4.17.


Sample Input 1

1 0 2 5 9 8

Sample Output 1

4.17

Sample Input 2

1 2 3 4 5

Sample Output 2

3.0


Reverse the sentence


your are given a string S as input , write a program to print the string after reversing words of the given sentence.


the first line of input is S.


in the given example the sentence "This is Python" contain 3 words ,when reversing the word "Python" comes to the starting of the sentence and "This" goes to the last of the sentence ,the word "is" remains in the same position.


so the output should be Python is This.



SAMPLE INPUT 1

This is Python

OUTPUT :- Python is This

SAMPLE INPUT 2

Hi! World Hello

OUTPUT:- Hello World Hi!



You are given a square matrix A of dimensions NxN and an integer X which means is an element of A, write a program to find P by performing the following table


(Use Big O to calculate the following time complexity)

Q 1  

def printPairs(array):

    for i in array:

        for j in array:

            print(str(i)+","+str(j))



Q2

def printUnorderedPairs(array):

    for i in range(0,len(array)):

        for j in range(i+1,len(array)):

            print(array[i] + "," + array[j])



#Question3

def printUnorderedPairs(arrayA, arrayB):

    for i in range(len(arrayA)):

        for j in range(len(arrayB)):

            if arrayA[i] < arrayB[j]:

                print(str(arrayA[i]) + "," + str(arrayB[j]))


arrayA = [1,2,3,4,5]

arrayB = [2,6,7,8]


LATEST TUTORIALS
APPROVED BY CLIENTS