Army strength based on level and modifiers Right so I was doing a quick project, and sought a quick way to finish one section of my Python code. I handed it in, but I'm well aware that it's bad code, but I was wondering if there was a good way to condense this code into fewer lines. 

def nGen_army(level, strength, weakness):
    if weakness == 1:
        if level == 0:
            army = round(random.randint(1000,5000),4)
            return army
        if level == 1:
            army = round(random.randint(10000,25000),4)
            return army
        if level == 2:
            army = round(random.randint(50000,75000),4)
            return army
        if level == 3:
            army = round(random.randint(100000,200000),4)
            return army
        if level == 4:
            army = round(random.randint(200000,500000),4)
            return army
    if strength == 1:
        if level == 0:
            army = round(random.randint(10000,25000),4)
            return army
        if level == 1:
            army = round(random.randint(50000,100000),4)
            return army
        if level == 2:
            army = round(random.randint(100000,300000),4)
            return army
        if level == 3:
            army = round(random.randint(300000,800000),4)
            return army
        if level == 4:
            army = round(random.randint(800000,1100000),4)
            return army
    else:
        if level == 0:
            army = round(random.randint(5000,10000),4)
            return army
        if level == 1:
            army = round(random.randint(25000,50000),4)
            return army
        if level == 2:
            army = round(random.randint(75000,150000),4)
            return army
        if level == 3:
            army = round(random.randint(150000,250000),4)
            return army
        if level == 4:
            army = round(random.randint(300000,900000),4)
            return army
Here's one way to do it:

from random import randint

def n_gen_army(level, strength, weakness, params=dict_of_dicts):
    """Returns random floats according to ranges specified by params."""
    if strength:
        key = 'strength'
    if weakness:
        key = 'weakness'
    else:
        key = 'default'

    lower_bound, upper_bound = params[key][level]

    return round(randint(lower_bound, upper_bound), 4)




weakness_dict = {
                0: (1000, 5000),
                1: (10000, 50000),
                2: (50000, 75000),
                3: (100000, 200000),
                4: (200000, 500000),
                }

strength_dict = {
                0: (10000, 25000),
                1: (50000, 100000),
                2: (100000, 300000),
                3: (100000, 300000),
                4: (800000, 1100000),
                }

default_dict = {
               0: (5000, 10000),
               1: (25000, 50000),
               2: (75000, 150000),
               3: (150000, 250000),
               4: (300000, 900000),
               }

dict_of_dicts = {'weakness': weakness_dict, 
                 'strength': strength_dict, 
                 'default': default_dict
                }

&gt;&gt;&gt; n_gen_army(2, 0, 0)
115061.0


Some other notes:


In your original code, if strength and weakness are both 1, then only the setting for weakness matters.  My code preserves that, but is that behavior really what is intended?  Or did you want elif instead of your second top-level if?
Why are you using round?  Do you really want floats returned instead of integers?  If you want integers, don't use round.  If you want integers rounded to the nearest 10 or 100, why not generate random integers in a 10-fold (or 100-fold) reduced range and then multiply be 10 (or 100)?
Avoid capitalization in function names if you can.  PEP8 and all that.  All-lowercase (for functions) is good python style.
You're only using one function from random, so from random import randint is better than loading in the whole module with import random.
You seem to be using weakness and strength as boolean variables so if weakness: is better than if weakness == 1.