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

def indexing(arg_1, arg_2):

# Complete this function


word = input()

index = int(input())

# Call the indexing function


how to complete this code to get desired output by using above code


input:

chocolate

2


output:

o


input:

google

4

output:

l


Using the Fare Matrix above, create a Python program (using any of the selection structures) that will accept distance in kilometer/s as input, and student or elderly passengers will pay the discounted rate, disabled passengers will get an additional 10% discount with the original discounted rate, otherwise the regular fare will be used as basis for the computation of fare. The output will be the total fare for the passenger.

1Using the np.array function create an np array from the data given above.

2Generate a scatter plot for the data.

3Plot dendrogram to visualize the clustering linkage


Data:[[5,3], [10,15], [15,12], [24,10], [30,30], [85,70], [71,80], [60,78], [70,55], [80,91],]


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


Write a program with a loop that repeatedly reads a string as input, where the string is either "duck" or "goose". The loop terminates when "goose" is entered. After the loop, your code should print out the number of "duck" strings that were read.


NOTE: When reading the input, do not display a prompt for the user. Use the input()function with no prompt string. Here is an example:


bird = input()


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


Add two polynomials

Given two polynomials A and B, write a program that adds the give

two polynomials A and B.




Output


Print the addition of polynomials A and B.


If the term with highest degree is negative, the term should be represented as -Cix^ ^ Pi .


For the term where power is 1 represent it as C1x instead of Cl*^ ^ 1 .


If the degree of polynomial is zero and the constant term is also ero, then just print 0 to represent the polynomial. For Lerm Cix^ ^ p i if the coefficient of the term Ci is 1, simply print x ^ P * i


instead of 7x p1


Explanation


If M = 4 and for polynomial A

For power 0, co-efficient is 5

For power 1, co-efficient is 0

For power 2, co-efficient is 10

For power 3, co-efficient is 6.


If N = 3 and for polynomial B

For power 0, co-efficient is 1

For power 1, co-efficient is 2

For power 2, co-efficient is 4.


And if result is zero print 0.


And if result has 1x solution it only x.





  1. Count and display the number of cities per country.
  2. Count and display the country which is a member of the EU (EU = yes) and not a member of the EU (EU = no).
  3. Find and display the country with the highest and lowest total population.
  4. Count and display the country with a coastline (coastline = yes) and without a coastline (coastline = no)

Difficult Addition


Arjun is trying to add two numbers. Since he has learned addition recently, an addition which requires a carry is difficult for him. Your task is to print Easy if the addition does not involve a carry, Otherwise print Hard.


Input

The first line of input contains two space separated integers A and B.


Output

If the addition does not involve a carry,print Easy, otherwise print Hard.


Explanation

When calculating 229 + 390, we have a carry from the tens digit to the hundreds digit, so the answer is Hard.


Sample Input1

229 390

Sample Output1

Hard


Sample Input2

123456789 9876543218

Sample Output2

Easy


Write a python function Write_String(fanme, *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.


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

 



LATEST TUTORIALS
APPROVED BY CLIENTS