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

You are given an array of N non-negative integers: A1A2, ..., AN. An alternating subsequence is a subsequence in which the indices of any two consecutive elements differ by exactly two in the original array. That is, if Ai1Ai2, ..., Aik is some subsequence, then for it to be an alternating subsequence, (i2 - i1 = 2), (i3 - i2 = 2), and so on should all hold true. Among all alternating subsequences, find the one which has maximum sum of elements, and output that sum.


Write a python program that splits a given string on a given split character. The first input is a String and the second input is the character that will be used to split the first String.



[You cannot use the built-in split function for this task]



=====================================================================



Sample Input 1:


This-is-CSE110


-



Sample Output 1:


This


is


CSE110



Explanation: The second input which is the character '-', is used to split or divide the first input String 'This-is-CSE110' into 'This', 'is' and 'CSE110' which are printed individually in separate lines.


1. Open and read the countrycities.csv file.

2. Count and display the number of cities per country.

3. Count and display the country which is a member of the EU (EU = yes) and not a member of the EU (EU = no).

4. Find and display the country with the highest and lowest total population.

5. Count and display the country with a coastline (coastline = yes) and without a coastline (coastline = no).


THIS IS THE LINK OF countrycities if you can help me with this i badly need this, i am just a student : https://drive.google.com/drive/folders/1dFoUHbPrBo3hiOJY_PTccdlQXSM4YJ4s?usp=sharing


Write a python function Write_String(fname, *list)  which take a list containing string elements and write them in a file myfile.txt until the string “finish” (not case sensitive) occur. The function then returns the contents written in file as a string. Before writing list elements in file, you also need to make a separate python function to check whether input list contains "Finish" or not. If not, then it should return error as shown in example.


Write the program in function definition?


myfile.txt:

Python

Java

C

C++

Ruby

.Net


 

Example-1

Example-2

Example-3

Input:

myfile.txt

["Python", "Java", "C", "C++", "Finish"]

 

Output:

PythonJavaCC++

Input:

myfile.txt

["Python", "Java", "C", "C++", "Finish",".Net", "Rubby"]

Output:

PythonJavaCC++Input:

myfile.txt

["Python", "Java", "C", "C++"]

Output:

Error: List does not contain Finish

 


 Write a python function Read_Prime(fname, list)  which takes a list of numbers as an input, use this number to write them in a file "primes.txt" . The function then read the file and return a list containing only prime numbers as shown in the example. Also, write the exception handling code to show the proper message.


def Read_Prime(fname, list_1):

    #write your code here

 

    return

#Call your function from main

list_1=[1,2,3,4,5,6,7]

fname = "primes.txt"

res = Read_Prime(fname, list_1)

print(res)


Example-1

Example-2

Example-2

Input:

primes.txt

[1,2,3,4,5,6,7]

 

Output:

[1,2,3,5,7]

Input:

primes.txt

[3,6,5,13,18,21]

 

Output:

[3,5,13]

Input:

primes.txt

[2,4,6,8,10]

 

Output:

[2]



Write a code on even and odd numbers


Read the Input into a variable.

Now using the loop iterate in range 1 to input.

Again read the second input into the variable.

Now take the count to assign the value 0 to it.

Using loop condition iterate from range 1 to second input.

using the if condition checks the condition that the second input is divisible by number then increment the count.

If the count is equal to 2

print the number and break from the loop.



Example:


2


4


7


5


the output will be 2 it is the first prime number.


Write a program that accepts a list of numbers separated by space. Use any() function


Sample output 1:

Enter numbers separated by space: 0 0 0 0 0 0

All input are zero


Sample output 2:

Enter numbers separated by space: 0 0 0 0 0 0 1

Not all inputs are zero


At one college, the tuition for a full-time student is $8,000 per semester. It has been announced that the tuition will increase by percent each year for the next 5 years. Write a program with a loop that displays the projected semester tuition amount for the next 5 years. 


The program should print out the result in the form


In 1 year, the tuition will be $8002.3.

In 2 years, the tuition will be $8103.2.

In 3 years, …

In 4 years, …

In 5 years, …


(If, for example, the tuition would cost 8002.3dollars in one year, etc.)


Sample Run


In 1 year, the tuition will be $8240.0.↵ 

In 2 years, the tuition will be $8487.2.↵ 

In 3 years, the tuition will be $8741.816.↵ 

In 4 years, the tuition will be $9004.07048.↵ 

In 5 years, the tuition will be $9274.192594400001.


Take input of age of 3 people by user and determine oldest and youngest among them, using if-else statement

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS