Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions