Python Forum

Full Version: I have a simple problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello
please help me
Condition 1 (if the result is between 3 and 5)
Condition 2 (and has been in contact with an infected person),

print(he/she must
Self-isolate for 14 days and get tested for covid-19.)
Condition 1 The problem in condition 2 is not fulfilled, meaning if a vertex by entering 0 is met, all conditions are not fulfilled, even if a vertex is entered by 1 all the conditions are met.
-----------------------------------------------------------------------------
a = input("name:")
y = input("Age:")
z = input("Sex:")
x = open("c19.txt", "w")
print("**Notice 1 mean yes, 0 mean no.** ")
def sum(Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9):
    q = (Q1 + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9)
    if (q >= 3) or (q <= 5) and (Q1 == 1): # Highligted in red
        x = open("c19.txt", "w")
        x.write("name: " + a + "\n" + "Age: " + y + "\n""Sex: " + z + "\n")
        x.write("Result:\t"+"he/she must isolate him/her self for 14 days and do covid-19 test.")
        x.close()
    elif q > 5:
        x = open("c19.txt", "w")
        x.write("name: " + a + "\n" + "Age: " + y + "\n""Sex: " + z + "\n")
        x.write("Result:\t"+"he/she must do covid-19 test, Mybe he/she infected by covid-19.")
        x.close()
    elif q < 3:
        x = open("c19.txt", "w")
        x.write("name: " + a + "\n" + "Age: " + y + "\n""Sex: " + z + "\n")
        x.write("Result:\t"+"he/she must isolate him/her self for 5 days if no more symptoms show,then he/she are not infected.")
        x.close()

n3 = (int)(input("if was in contact with an infected person:"))
n4 = (int)(input("Do you have a fever:"))
n5 = (int)(input("Do you have a cough:"))
n6 = (int)(input("Do you have shortness of breath or difficulty breathing:"))
n7 = (int)(input("Do you have Fatigue:"))
n8 = (int)(input("Do you have muscle or body aches:"))
n9 = (int)(input("Do you have a headache:"))
n10 = (int)(input("Do you have a loss of taste or smell:"))
n11 = (int)(input("Do you have a sore throat:"))

sum(n3, n4, n5, n6, n7, n8, n9, n10, n11)
n3 = (int)(input("if was in contact with an infected person:"))
The above won't work, to use the function int it must be called with a argument.
Example
int('1')
Can you add it to the code above and republish it to make it clear to me? Thank you
What's with the really poor variable names (pretty much all of them)? Use names that are meaningful - for example, if a variable is going to store a name, why not just call it name? Good names make it easier to read and understand code.
It's your homework you should try and change the code yourself based on the hint of how int works, that way you will learn more.
Another hint: you want to turn the result returned by input into an int
The condition is half fulfilled, but the result of m3 must be 1 or not all of the condition are met

Notice ** It's not homework