Write a program in python to fetch state of residence and marital status of 5 users

write a python program that prints (displays) your name, address, and telephone number.
write a program that asks the user for his name and greets him with his name in python
python program to print student details
w3resource python
write a program that takes a first name as the input and outputs a welcome message to that name
python programs
print name in reverse order in python
write a python program to print the following string in a specific format

I have been trying to write a program in python that puts the status of 5 people and states which region that person resides in. I wrote part of my code and wanted to test out married status with one of the 3 regions, West, East, and South. The problem is even when I put the state as "NY" it is still counting it towards West, instead of East, and I don't know how to fix it. Here's my code:

West = 0
East = 0
South = 0
Married = married = 0
MarriedW = 0
MarriedE = 0
MarriedS = 0
NY = ny = FL = fl = MA = ma = East
TX = tx = AL = al = GA = ga = Southern
CA = ca = NV = nv = AR = ar = WA = wa = West
state1 = int(input("please enter the state where the first person resides :"))
status1 = int(input("Please enter your marital status of first person :"))
if (state1==West):
    West = West + 1
    if (status1=='Married' or 'married'):
        MarriedW = MarriedW + 1
elif (state1==East):
    East = East + 1
    if (status1=='Married' or 'married'):
        MarriedE = MarriedE + 1
elif (state1==South):
    South = South + 1
    if (status1=='Married' or 'married'):
        MarriedS = MarriedS + 1
else:
    print("The person is not counted towards Any of the following states. TX, Al, GA, NY, MA, FL, CA, NV, AR or WA")
print("The number of people who belong to Western region is :" +str(West))
print("The number of people who are married in Western region is :" +str(MarriedW))
print("The number of people who belong to the Eastern region is :" +str(East))
print("The number of people who are married in Eastern region is :" +str(MarriedE))
print("The number of people who belong to Southern region is :" +str(South))
print("The number of people who are married in Southern region is:" +str(MarriedS))

The issue is that you're assigning the states as values equaling values you already defined (East West South) which are set to 0. In other words- you're making everything equal 0 (so the first conditional checking for West will always get hit).

The code is messy but to make it work with minimal changes- set the variables of the states equal to string values and check against the string value in your conditionals like so:

West = 0
East = 0
South = 0
Married = married = 0
MarriedW = 0
MarriedE = 0
MarriedS = 0
NY = ny = FL = fl = MA = ma = 'East' #changed this to a string
TX = tx = AL = al = GA = ga = 'South' #changed this to a string
CA = ca = NV = nv = AR = ar = WA = wa = 'West' #changed this to a string
state1 = input("please enter the state where the first person resides :") #removed int cast
print(state1)
status1 = input("Please enter your marital status of first person :")
if (state1=='West'): #changed to check against string
    West = West + 1
    if (status1=='Married' or 'married'):
        MarriedW = MarriedW + 1
elif (state1=='East'):#changed to check against string
    East = East + 1
    if (status1=='Married' or 'married'):
        MarriedE = MarriedE + 1
elif (state1=='South'): #changed to check against string
    South = South + 1
    if (status1=='Married' or 'married'):
        MarriedS = MarriedS + 1
else:
    print("The person is not counted towards Any of the following states. TX, Al, GA, NY, MA, FL, CA, NV, AR or WA")
print("The number of people who belong to Western region is :" +str(West))
print("The number of people who are married in Western region is :" +str(MarriedW))
print("The number of people who belong to the Eastern region is :" +str(East))
print("The number of people who are married in Eastern region is :" +str(MarriedE))
print("The number of people who belong to Southern region is :" +str(South))
print("The number of people who are married in Southern region is:" +str(MarriedS))

Write a program in python to fetch state of residence and marital I have been trying to write a program in python that puts the status of 5 people and states If you wanted to check if the input from a user (in your case a stateĀ  Question: Write A Program To Fetch State And Marital Status Of 5 Users. Use NESTED SELECT..CASE To Find Out The Number Of People Who Belong To Each Of The Regions Below. Use NESTED SELECT..CASE To Find Out The Number Of People Who Belong To Each Of The Regions Below.

Instead of using:

 if (status1=='Married' or 'married')

Use:

 if (status1=='Married' or status1 == 'married')

You could also remove redundant paranthesis:

 if status1 == 'Married' or status1 == 'married'

More better to use:

if status1.lower() == 'married'

Write A Program To Fetch State Of Residence And Marital Status Of 5 Users Use Python please "WA, count them towards westernregion Within this region, count the number of people who are married, single, divorced and separated. Using basic language, write a program to fetch state and marital status of 5 users. Use NESTED SELECT..CASE to find out the number of people who belong to each of the regions below. If the user is

If you wanted to check if the input from a user (in your case a state code) was fitting any of the mentioned states I think that a practical and slightly more elegant solution to this problem would be creating a list of strings for the states, e.g:

East_states = ['NY', 'ny', 'FL', 'fl', 'MA', 'ma']

And later check if user input, which in Python3 is a string by default, can be found in the list:

    state1 = input("please enter the state where the first person resides :")
    status1 = input("Please enter your marital status of first person :")
if (state1 in West_states):
    West = West + 1
    if (status1 == 'married'):
        MarriedW = MarriedW + 1'

5. Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them. Go to theĀ  Question: IN PYTHONWrite A Basic Python Program Where The Main Part Of The Program Collects The Data Such As Employee Hours, Hourly Rate, State Of Residence, And Marital Status.It Then Calls The Function Calculatewages() Function And Sends Employee Hours And Hourly Rate.The Calculatewages Function Would Calculate The Wages And Sends It Back To The Main.The

Python Exercises, Practice and Solution: Write a Python program to display your details like name, age, address in three different lines. Design a program that gives simple math quizzes. The program should display two random numbers that are to be added, such as: 247 129. The program ( Write a program to fetch state of residence and marital status of 5 users. Use if..elif: to find out the number of people who belong to each of

to make another request to the server to get the data at the file cuteKitten.jpg in order to fully render the page for the user. Keep in mind that our Python script. Write a Python program that will display a message to ask the user to input the type of residency. The program then reads the residency (I for in-state, O for out-of-state, and G for graduate). Based on the residency, the program will use the respective current tuition. The program will then enter a loop and calculate the new tuition for every year for five years.

Oracle Database 11gR2, with a user "pythonhol" and password (case sensitive) Database Resident Connection Pooling is a new feature of Oracle Database 11g. used by new or existing applications without writing or changing any application logic. There are a number of ways to fetch data from an Oracle database. BASIC/PYTHON programming language.<br/> this is basic class not. c++.Please submit basic. Write a program to fetch state and marital status of 5 users. Use NESTED SELECT..CASE to find out the number of people who belong to each of the regions below.

Comments
  • This is some pretty wet and wild coding, I would suggest structuring your variables into some sort of containers like dictionaries or lists to make this more manageable
  • Whatever NY = ny = FL = fl = MA = ma = East is, it should be something else. This code doesn't run as-is
  • Or, to further simplify, why not if status1.lower()=='married' and get rid of the secondary condition altogether
  • or if status1 in {'married', 'Married'}:.
  • This is a good catch to further help OP with their code but it doesn't answer the original question OP asked- which is why passing NY maps to west instead of east.