Hai there,
I am a robotic student and very new in python programming. Here, I have a project to classify the type of robot. For example, a customer would like to buy a robot arm for their company. So, this project will aid them to select robot of their choices. First there will be a question such as " Hi sir, welcome to XXX Robot Factory""please choose the robot type for their specification" "a)arc welding b)grinding c)welding and d)laser cutting. Then, the customer will enter one key like (a) and the specification for the robot such as its price,load capacity and life will come out to show to the customer.Only these are my project and I have to use rule-base system [if..else statement] to meets its criteria. Can help me with this??

Dani AI

Generated

Nice start, — and good scaffold from . His menu + loop is exactly the kind of interactive shell you need. For clarity and future changes, keep the decision logic separate from the data (the robot specs). That avoids long if/else chains and makes it easy to add new types later.

A compact, maintainable pattern is to store specs in a dictionary and write a small lookup function:

robots = {
  'a': {'name': 'Arc welding',   'price': 12000, 'load_kg': 80,  'life_yrs': 8},
  'b': {'name': 'Grinding',      'price': 9000,  'load_kg': 60,  'life_yrs': 6},
  'c': {'name': 'Welding',       'price': 15000, 'load_kg': 100, 'life_yrs': 10},
  'd': {'name': 'Laser cutting', 'price': 20000, 'load_kg': 50,  'life_yrs': 7},
}

def get_specs(key):
    return robots.get(key.lower())

spec = get_specs('a')
if spec:
    print("Type:", spec['name'])
    print("Price: ${}".format(spec['price']))

If the assignment insists on a rule-base implemented with if/else, keep rules modular: write one function per rule and call them from your main loop. That satisfies the "if/else" requirement while keeping code readable.

Practical tips: normalize input with .strip().lower(); validate numbers and show units (kg, years, currency); keep data in JSON or CSV so non-programmers can update specs without editing code (use json.load() to read). Add tests for edge cases (invalid key, missing fields). Combining 's loop with a data-driven lookup gives a robust, easy-to-maintain solution for your project.

Recommended Answers

All 2 Replies

I am a robotic student and very new in python programming. Here, I have a project to classify the type of robot. For example, a customer would like to buy a robot arm for their company. So, this project will aid them to select robot of their choices. First there will be a question such as " Hi sir, welcome to XXX Robot Factory""please choose the robot type for their specification" "a)arc welding b)grinding c)welding and d)laser cutting. Then, the customer will enter one key like (a) and the specification for the robot such as its price,load capacity and life will come out to show to the customer.Only these are my project and I have to use rule-base system [if..else statement] to meets its criteria. Can help me with this??

Python lends itself to just 'jumping in' and to start coding:

# print greeting ...
greeting = "Hi sir, welcome to XXX Robot Factory"
print( greeting )

# now do a main loop where you show menu
# get choice ... and then 'process' choice

menu = "a) arc welding\n" \
       "b) grinding   \n" \
       "c) welding    \n" \
       "d) laser cutting\n" \
       "x) exit this loop\n"

def doProcessA(): # dummies for now
    print( 'A' )

def doProcessB():
    print( 'B' )

while( True ): # start main loop
    print( menu )
    choice = input( "Your choice: " )
    if choice == "a":
        doProcessA()
    elif choice == "b":
        doProcessB() 

    # Note:these process functions
    # are to be yet 
    # 'defined' (by you) above
    # like this:
    # def doProcessA():
        # ....
        #...
        # and MAY return values
        #     if need to
        # x = y = z = 0 # 'dummy' line for now
        # return x, y, z


    # etc ...


    # etc ...

    elif choice == "x":
        break;


    # ....
    else:
        print( "That choice is NOT valid here." )

This may get you started

Really appreciates it. really help me a lot..thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.