0
import math
import colorama
from colorama import Fore
colorama.init(autoreset=True)

#while y == 'y':

#True Position callout
truePosition = float(input("Enter True position callout: "))

#Nominal size
nominal_Diameter = float(input("Enter Nominal Diameter: "))

#Tol positive / negative
Tol = float(input("Enter Tolerance: "))

#Actual Diameter size
actual_Diameter = float(input("Enter Actual Diameter size: "))

#common distance of "x"
x_com = float(input("Enter X distance: "))

#common distance of "y"
y_com = float(input("Enter Y distance: "))

# X distance value
x = float(input("Enter actual X distance value: "))

# Y distance value
y = float(input("Enter actual Y distance value: "))

#deviation x
x_1 = x_com - x

#deviation y
y_1 = y_com - y

#true position formula
sqrt = math.sqrt(x_1**2 + y_1**2)

#true positon formula
true_position = 2 * (sqrt)

if true_position < truePosition:
    print('Result: ', round(true_position, 3), Fore.GREEN + '(Accept)',)
else:
    print('Reject')

#MMC or LMC
choiceOne = str(input("Enter MMC or LMC: "))

#show results for mmc or lmc based on user selection
if choiceOne == 'mmc' or 'MMC':
    d_Mmc = nominal_Diameter - Tol
    result1 = actual_Diameter - d_Mmc + truePosition
    round2 = round(result1, 3)
    if choiceOne == 'lmc' or 'LMC':
        d_Mmc1 = nominal_Diameter + Tol
        result2 = actual_Diameter - d_Mmc1 + truePosition
        round3 = round(result2, 3)
else:
    print('')

mmc_lmc = ''
mmc_lmc_Reject = ''

if choiceOne == 'mmc' or 'MMC':
    mmc_lmc += 'MMC: '
elif choiceOne == 'lmc' or 'LMC':
    mmc_lmc += 'LMC: '

if choiceOne == 'mmc' or 'MMC':
    mmc_lmc_Reject += 'MMC reject: '
elif choiceOne == 'lmc' or 'LMC':
    mmc_lmc_Reject += 'LMC reject: '

#display results for mmc or lmc with accept or reject
if 'mmc' or 'MMC' == true_position <= result1:
    print(mmc_lmc, round2, '(accept)')
elif 'lmc' or 'LMC' == true_position <= result2:
    print(mmc_lmc, round3, '(accept)')
else:
    print('mmc_lmc_Reject')

**I need help, i can't solve when user type in mmc or lmc, then it will calculate base on what they type, because when i type in MMC it work well then i tried typing lmc it print out MMC results.

i tried different way to solve this, but i can't solve it and im new to python, mostly all the codes i do are quite basic, when i code more, that where i get connfuse and thinking what goes wrong in my codes, i tried solving it two days back but cant find solution to my codes and ask pro's here to help so i can learn what goes wrong.**

noel
  • 31
  • 5
  • 2
    Does this answer your question? [How to test multiple variables for equality against a single value?](https://stackoverflow.com/questions/15112125/how-to-test-multiple-variables-for-equality-against-a-single-value) – ewokx Jul 22 '22 at 00:02
  • Your nested if statement should be an elif and over to the left one tab. Your `if 'mmc' or 'MMC' == ...result1` test is just returning the first value in that statement. Not sure how that statement is supposed to work because you have two strings on the left of the true_position variable and then a less than equal to test on the right. Can you give a description of what the code is supposed to be doing? – user85779 Jul 22 '22 at 00:11
  • 1
    Try `if choiceOne in ['mmc' or 'MMC']:` or `if choiceOne.lower() == 'mmc':` – CodeMonkey Jul 22 '22 at 00:11
  • i want to show actual true position results with accept (e.g result: value (accept), then it will ask user to enter mmc or lmc, after typing lmc or mmc it will show the result format in MMC: mmc result(accept). – noel Jul 22 '22 at 02:07

0 Answers0