Starting from:

$30

HSMW Exercise -Solved

1. 
Develop the function sum_loop( start , end) where it return the sum of all integers between 
“start” up to “end” using a loop. Develop the function sum_recursion( start , end) where it 
return the sum of all integers between “start” up to “end” using recursion. In both cases, 
check that “start” is less than or equal to “end” otherwise return None. 
2. 
Develop the function sumDigits_loop( number ) where it return the sum of all the digits of 
the integer stored in “number” using a loop. Develop the function 
sumDigits_recursion( number ) where it return the sum of all the digits of the integer stored 
in “number” using recursion. In both cases, check that “number” is a valid positive integers. 
In case of error, return None. 
3. 
Develop the function isPrime( number ) where it return true if number s prime otherwise 
return false. Using module “sympy”, implement the function isPrime_sympy with same 
functionality. 
4. 
Develop the function sumDivisible( start, end, divisor ) where it return the sum of all 
integers between “start” up to “end” which are divisible by “divisor”. Implement the same 
functionality using recursion. 
5. 
Develop the function reverse( number ) which reverse the digits of a number, so 123 
becomes 321. check that it is only positive integer otherwise return None. 
6. 
Develop the function clock( hours,minutes,seconds ) which return time in seconds only. 
Check that the hours,minutes and seconds are within range otherwise return None. 
7. 
Develop the function decimalToBinary( number ) which return number in binary. Return 
None if negative number. Implement the opposite from BinaryToDecimal. 
8. 
Develop the function averageMinMax() which asks the user if he wants to enter a new 
number or not. If the user choose not, then the program prints the average of all the numbers 
entered by the user. Also the maximum and minimum number among them. If the user says 
yes, then you should read a new number. Keep looping forever until the user enters not. 
Make the same function but this time the input comes from a file containing numbers, each 
umber on a separate line. (HINT: use the function int() to change from a string to integer). 
9. 
Develop a function which take a filename and print these information about the text inside: 
1. 
Count all upper alphabets 
2. 
Count all lower alphabets 
3. 
Count all vowels 
4. 
Count all digits 
5. 
Count all spaces 
6. 
Count all commas. 
7. 
In that text replace every "math" by "the best science ever" without case distinction 
10. 
Write a function which answer the following questions: 
1. 
In the English language, what is the most used alphabet and the least used alphabet. 
2. 
Group the number of words in English language by its length. And tell us which word 
length is used the most and which is used the least. 
3. 
(HINT: this program needs alt of trails! Use the file of the words of the English 
language)

More products