Python Answers

Questions answered by Experts: 5 288

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

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.


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


Write a Python program that takes a String as input from the user, removes the characters at even index and prints the resulting String in uppercase without using the built-in function upper().


Sample Input 1:

String

Sample Output 1:

TIG


 Filter out movies which are released in more than 1 languages using movies dataset


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


LATEST TUTORIALS
APPROVED BY CLIENTS