Answer to Question #177773 in Python for knotaima

Question #177773

Write a python program that asks the user for a string input. This input corresponds to an attachment that changes the stats of your gun.


Attachments!

 monolithic suppressor: +5 damage, -5 mobility

 owc_skeleton_stock : +5 mobility, -8 Accuracy

 owc_laser_tactical : +5 accuracy, +5 control

 operator_foregrip : +10 control, -2 mobility


Inputs are case-insensitive. E.G. OWC Compensator == owc compensator.

P.S. No imports.


Users can be able to input multiple gun attachments by adding a semicolon; in between the attachments. There must be no whitespace present in the inputs. You might need loops to answer this question.



Print out the final stats of the gun in this format:


Man-O-War Updated Stats!

Damage: {damage}

Fire Rate: {fire rate}

Accuracy: {accuracy}

Mobility: {mobility}

Range: {shooting range}

Control: {control}


Example

User input: owc skeleton stock;owc laser tactical


Output:

Man-O-War Updated Stats!

Damage: 49

Fire Rate: 50

Accuracy: 66

Mobility: 64

Range: 56

Control: 58


1
Expert's answer
2021-04-04T14:39:46-0400
print('monolithic_suppressor: +5 damage, -5 mobility')
print('owc_skeleton_stock : +5 mobility, -8 Accuracy')
print('owc_laser_tactical : +5 accuracy, +5 control')
print('operator_foregrip : +10 control, -2 mobility')

str1=str(input("Enter input string"))
print(str1);


def monolithic_suppressor():
    return "monolithic_suppressor"


def owc_skeleton_stock():
    return "owc_skeleton_stock"


def owc_laser_tactical():
    st1=print('Damage: 49')
    st2=print('Fire Rate: 50')
    st3=print('Accuracy: 66')
    st4=print('Mobility: 64')
    st5=print('Range: 56')
    st6=print('Control: 58')


def operator_foregrip():
    return "operator_foregrip"


def stringMonth(str1):
    switcher = {
        1: monolithic_suppressor() ,
        2: owc_skeleton_stock(),
        3: owc_laser_tactical(),
        4: operator_foregrip()

    }
    # Get the function from switcher dictionary
    func = switcher.get(str1, lambda: "string")
    # Execute the function
    print(func())

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS