(Place your answer to this problem in the “count_largest.py”
file)
Complete the count_largest() function, which takes a single
positive (non-zero) integer as its argument. This function
identifies the largest digit in the argument/parameter and returns
an integer value that represents the total number of occurrences of
that digit. For example, the largest digit in 4234 is 4, and it
appears twice.
Thereareseveralwaystosolvethisproblem,mostofwhichinvolvePythonfunctionsorconceptsthatwehaven’tcoveredin
class yet, but it’s definitely possible to solve it using only what
we know right now. In particular, we can use a while loop and the
modulo (%) operator to process the input value from right to left,
removing one digit at a time for examination
ANSWER :
def count_largest(num):
if (num < 0):
num = num * -1
val = num
maxVal = -1
count = 1
while(val != 0):
rem = val % 10
if(rem == maxVal):
count += 1
else:
if (rem > maxVal):
maxVal = rem
count = 1
val = val // 10
return count
#Testing
print(count_largest(4234))

(Place your answer to this problem in the “count_largest.py” file) Complete the count_largest() function, which takes...
In C++ 9) (5 pts) Complete the following function that takes 3 arguments of a circle : - radius (input argument) - area (output argument, to be calculated) - circumference (output argument, to be calculated) All arguments are double type. If a radius is negative, the function returns false, otherwise it returns true. The function does only calculation, and does nothing else. Assume that all #include are already there // Fill in your Function prototype bool circleAreaAndCircumference ( _______,...
1.Write a function called high_point that takes a list of integers and returns True if there exists a value in the list that is bigger than the values immediately before and after it in the list. Your function must return False if no such value exists. The values in the beginning and the end of the list cannot be high points. (20 points) Test Cases: print(high_point([2,5,8,9,7,9])) True print(high_point([2,5,6,6,3])) False print(high_point([2,5,8,21,22])) False 2. Write a while loop to repeatedly ask for...
Write a python function score_formatter() that takes one parameter, which is a formatted string that contains information about the score received by a student in a particular subject. The function analyzes the string and returns a reformatted string for the score. You will need to use the function re.sub that is discussed in the lecture notes. If the string does not match the pattern, the function returns the string "error". The input string is always given in the format specified...
Problem 1 (Factorial with loops) Complete the function factorial_loop(num) that takes an integer num and returns the value of num!, i.e., num! = num * (num-1) * (num-2) * ... * 1. This function must use a loop (iteration) to compute the value of num!. (in python)
USE PYTHON PLEASE
Write a function called is prime which takes a single integer argument and returns a single Boolean value representing whether the given argument is prime (True) or not (False). After writing the function, test it by using a loop to print out all the prime numbers from 1-100. To check your results, the prime numbers from 1-100 are: 2, 3, 5, 7, 11. 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,...
1. Implement a tostring() member function. This function will return a string representation of the LargeInteger. You should probably used string streams to implement this function. Note that the digits of the large integer are stored in reverse of their display order, e.g. the 1's place (100 ) is in index 0 of digits, the 10's place (101 ) is in index 1, etc. 2. Implement a second constructor for the LargeInteger. This constructor will be used to construct a...
Must use the Scheme language to solve the problem. Thanks! Write a function deep-mult which takes a list as a parameter and computes the product of all numbers which appear anywhere in the list or in sublists. We will follow the usual mathematical convention that a product of no numbers is 1 (the multiplicative identity). You may find it useful to know that Scheme has a function number? which returns #t if its argument is numeric atom and #f otherwise....
This code should be in C please!! Your file should meet the following criteria: • Function prototype and implementation for a calculateDivisors function that takes in an integer parameter, calculates the sum of its divisors, and returns that sum (as an integer value) • A structure that represents what is represented on each line of output, e.g., o Line number o Sum of the divisors for that line number o Character array containing “Perfect”, “Deficient”, or “Abundant” • Pointer declared...
C++
Project Overview
The 18th season of the reality series Hell's Kitchen
began airing on Sep 28th, 2018 on Fox. Suppose you are
working for the boss, Chef Gordon Ramsay, your job is to create an
efficient system that generates a menu. Since in Hell's Kitchen,
menu changes every day, your system should easily add items to the
menu. Therefore, dynamically allocated arrays would be an excellent
solution.
The Dish Class (Header File)
You need to create a struct called...
Edit, compile, and run the following programs on the UNIX shell: Write a program that takes in six commandline arguments and has four functions (described below) that use bitwise operators. The user should enter six space-separated commandline arguments: four characters (any ASCII character) followed by two integers. Anything else should print an error message telling the user what the correct input is and end the program. Convert the commandline input into "unsigned char" and "unsigned int" datatypes. Be careful with...