Question: Python How to convert a given function to camel case in python? for example def sum_two_digits(a, b): return a + b print(sum_two_digits(10, 20)) THE potential

Python

How to convert a given function to camel case in python? for example

def sum_two_digits(a, b): return a + b print(sum_two_digits(10, 20))

THE potential function should process the above function and return it in camel case like below:

def SumTwoDigit(a, b): return a + b print(SumTwoDigit(10, 20))

the nested dictionary is

The nested dictionary is given by d = {'sum_two_digits': {'hash':-9214996652071026704, 'camelcase':'SumTwoDigits', 'allcaps':'SUM_TWO_DIGITS'} }

If the function name starts with _ like

_sum_digits(a,b)

it should be converted to _SumDigits(a,b)

if the function name is already in camel case leave it as its.

function needs to return the tuple (d, newcode): d is a nested dictionary where each key corresponds to the original function name. The value is a nested dictionary that has the following items: o hash: hash code of the original function name (tip: use Python's hash function) o camelcase: camel case version of original function name o allcaps: all caps version of original function name newcode is a string containing the code wherein all function names have been renamed by their camel case versions. Note that you need to change the function name and also all other locations where the function name is used (e.g. function calls). You should not change anything else in the code (e.g. the contents of any strings).

WITH EXPLAINTATION PLEASE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!