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

shift numbers -2






given a string, write a program to move all the numbers in it to its start.






input






the input will contain a string A.






output






the output should contain a string after moving all the numbers in it to its start.






explanation






for example, if the given string A is "1good23morning456",the output should be "123456goodmorning",as it contains numbers at the start.






sample input 1






1good23morning456






sample output 2






123456goodmorning






sample input 2






com876binat25ion






sample output 2






87625combination

sum prime numbers in the input



given a list of integers, write a program to print the sum of all prime numbers in the list of integers.


note.one is either prime nor composite number.



input



the input will be a single line containing space separated integers..



output



the output should be a single line containing the sum of all prime numbers from 1 to N



explanation



for example, if the given list of integers are



2 4 5 6 7 3 8



as 2,3,5 and 7 are prime numbers,your code should print the sum of these numbers. so the output should be 17



sample input 1



2 4 5 6 7 3 8



sample output 1



17



sample input 2



65 87 96 31 32 86 57 69 20 42



sample output 2



31



given a four digit number N as input. write a program to print first and last digit of the number




Find latitude and longitude of utmost 20 countries, ordered by population, with a population greater or equal to the population limit given below and have atleast one currency exclusively for themselves. (countries like Madagascar, Sri Lanka but not India, USA). Use the country details from this dataset.





Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.





Assume radius of earth: 6371 km





Round length of each line and final result to 2 decimal points





If co-ordinates are missing for any country use 0.000 N 0.000 E






Population limit: 84497





Note: Population limit will change at random intervals. So please make sure answer is computed for the correct population limit before submitting.






Find latitude and longitude of utmost 20 countries, ordered by population, with a population greater or equal to the population limit given below and have atleast one currency exclusively for themselves. (countries like Madagascar, Sri Lanka but not India, USA). Use the country details from this dataset.






Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.






Assume radius of earth: 6371 km






Round length of each line and final result to 2 decimal points






If co-ordinates are missing for any country use 0.000 N 0.000 E







Population limit: 84497






Note: Population limit will change at random intervals. So please make sure answer is computed for the correct population limit before submitting.

  1. Develop a flowchart to calculate the tuition fee for a student at an University. The program should prompt for and accept the idnumber and the total number of credits for which he/she has enrolled. The bill outputted should contain the idnumber and tuition fee.

Calculate the tuition fee as follows:

  • Total credits of 15 or more indicates that the student is full-time. Full-time students pay a flat rate of $35,000 for tuition. 
  • Total credits of less than 15 indicate that the student is part-time. Part-time students pay $850 per credit for tuition.   

After printing the tuition fee, ask the user if s/he wants to calculate the tuition fee for another student – “Y” for yes and “N” for no. (This question is asked each time the tuition fee is printed). If s/he does, allow him/her to enter another student’s idnumber and total number of credits and find the tuition fee again. If the answer is no, the flowchart must be terminated with an appropriate message.



Riya took part in a maths quiz competition. To win the prize money she has to solve a tricky question at the end.For a given list of integers, write a program where all the integers in a given index range to be added.
She will be given M multiple ranges, where she should print the sum of numbers for each corresponding range.

Note: The limits in the range are both inclusive.

Input
The first line f input is space-separated integers.
The second line of input is a positive integer M denoting the number of index ranges.
The next M lines contain two space-separated integers of the range.

Output
The output should be M lines.
Each line contains an integer that represents the sum for the corresponding ranges.

Sample Input1
1 3 4 5 6
5
3 5
Sample Output1
12


[Please test the sample test cases and send the screenshots].

Create a program that will allow the user to easily manage a list of names.


You should display a menu that will allow them to add a name to the list, change a


name in the list, delete a name from the list or view all the names in the list.



There should also be a menu option to allow the user to end the program. If they


select an option that is not relevant, then it should display a suitable message.


After they made a selection to either add a name, change a name, delete a name or


view all the names, they should see the menu again without having to restart the


program. The program should be made as easy to use as possible.

 Your younger brother is studying in school. His computer teacher gives homework to make a calculator for six operations: addition, subtraction, multiplication, division, power, and modulo on two integers. As you are about to become an engineer, so he expected help from your side to develop the program. Therefore, write Calc.py module that define a separate function for implementing all the above-mentioned operations. Then import Calc.py in your RollNo_W12A_1.py file. In RollNo_W12A_1.py, define a function Arithmatic(a, b, op) which calls the respected function defined in Calc.py to perform the required operation. Also handle the possible exceptions and display the

Example-1

Example-2

Example-3

Example-4

Input:

5

6

+

Output:

11

Input:

15

9

*

Output:

135Input:

15

9

&

Output:

Invalid operation

Input:

2

4

^

Output:

16


Sanjay identifies that for compiler designing he need to implement tokenization of a specific line of program. As a friend of Sanjay, your task is to help him to write a python function Tokenize_Line(fname, n) which reads nth line from prime.py file and returns a list containing all tokens of that line as shown in the example. Also, handle the possible exception and provide proper message.

 

Contents of prime.py file will be like:

from math import sqrt

n = 1

prime_flag = 0

if(n > 1):

   for i in range(2, int(sqrt(n)) + 1):

       if (n % i == 0):

prime_flag = 1

           break

   if (prime_flag == 0):

       print("true")

   else:

       print("false")

else:

   print("false")


Input:

prime.py

10

 Output:

['print("true")

']Input:

prime1.py

8

Output:

File Doesn't Exist


Input:

prime.py

6

Output:

['if', '(n', '%', 'i', '==', '0):']


Input:

prime.py

100

Output:

Invalid Line no.


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS