Question

In: Computer Science

1) Create a "Can I be President?" program. The program determines if the user meets the...

1) Create a "Can I be President?" program. The program determines if the user meets the minimum requirements for becoming the President of the United States. Use user input. The rules for being president of the U.S. are:

  1. Older than 35

  2. Resident of US for 14 Years

  3. Natural born citizen

Print True if the person could be president and False if they can't be president. 2) Alter one line of that program to be a "I can't be President?" game. Print True if the user cannot be President and False if they can be President.

print('How old are you?')
age = int(input())

if age >= 35:
print('you qualify')
else:
print('you do not qualify')

print('How long have you lived in the U.S.?')
resident = int(input())

if resident >= 14:
print('You qualify')

else:
print('You do not qualify')
  
print('Are you a born citizen?')
citizen = str(input())

if citizen == "Yes":
print('You qualify')
else:
print('You do not qualify')
  

  if age >= 35 and resident >= 14 and citizen == "Yes":
print("True")
else:
print("False")

Hello, I did the program, but does this look correct? How do I answer question 2? Feel free to edit, but please keep my variables

Solutions

Expert Solution

(1.) Yes, your code is working fine, and it generates the correct output for the question asked in part 1, the screenshot of your python code for the part 1 run on an online compiler is as follows:-

(2.) The part 2 is asking the opposite of part 1, the code will remain same except the last if condition in which we will check whether the person meets any of the criteria of "I can't be president", if he meets then print True otherwise print False, please note that here I am editing your code given in the question so that it will help you to understand, the python code is as follows:-

print('How old are you?')
age = int(input())
if age >= 35:
print('you qualify')
else:
print('you do not qualify')
print('How long have you lived in the U.S.?')
resident = int(input())
if resident >= 14:
print('You qualify')
else:
print('You do not qualify')
print('Are you a born citizen?')
citizen = str(input())
if citizen == "Yes":
print('You qualify')
else:
print('You do not qualify')
if age < 35 or resident < 14 or citizen != "Yes": # only this line will change
print("True")
else:
print("False")

The output of the above code is as follows:-

How old are you?
34
you do not qualify
How long have you lived in the U.S.?
12
You do not qualify
Are you a born citizen?
Yes
You qualify
True

The screenshot of the above code is as follows:-


Related Solutions

I have to create a program in C++ where a user can enter as many numbers...
I have to create a program in C++ where a user can enter as many numbers as they want (they predetermine the number of values to be inputted) and then the program can echo that input back to the user and then determine if the numbers were even, odd, or a zero and it outputs how many of each were found. This is to be down with four void functions and no arrays. The program initializes the variables zero, odds,...
Create a PYTHON program that lets a user guess a number from 1 to 1,000: -i...
Create a PYTHON program that lets a user guess a number from 1 to 1,000: -i used random.randint(1,1000) -must give hints like (pick a lower/higher number) which i already did -tell the user when he has repeated a number (help) -the game only ends when you guess the number (help) -you loose $50 every failed attempt (done) ****I did it as a while loop -
create a program that will allow the user to enter a start value from 1 to...
create a program that will allow the user to enter a start value from 1 to 5, a stop value from 10 to 12 and a multiplier from 1 to 4. the program must display a multiplication table from the values entered. for example if the user enters: start 2, stop 10 and multiplier 3, the table should appear as follows: 3*2=6 3*3=9 3*4=12 . . . 3*10=30
Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to...
Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to Zion's Pizza Restaurant and ask the user how many people are in their dinner group. If the answer is more than eight (8), print a message saying they'll have to wait for a table. Otherwise, report that their table is ready and take their order. Assume the client orders one pizza, and ask what he/she would like on their pizza, include a loop that...
Design c++ program so that it correctly meets the program specifications given below.   Specifications: Create a...
Design c++ program so that it correctly meets the program specifications given below.   Specifications: Create a menu-driven program that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- square 2 -- circle 3 -- right triangle 4 -- quit If the user selects choice 1, the program should find the area of a square. If the user selects choice 2, the program should find the area of a circle. If the...
Hello, #1 I am asked to create a Windows user account that is a non-admin user...
Hello, #1 I am asked to create a Windows user account that is a non-admin user using a.ps1 file. At first, I used the New-LocalUser cmdlet, but this cmdlet does not show up as a user on the start menu of my computer and I cannot use it to log in as another user on my computer. So, instead of using that cmdlet, what could I use to create a Windows user account that I can also log into? #2...
(JAVA) Create a program that prompts the user for an age input. The program defines the...
(JAVA) Create a program that prompts the user for an age input. The program defines the age group of the user. Follow the table below to construct the output for your program. Age Age Group 0 Baby 1-3 Toddler 4-11 Child 12-17 Teenager 18-21 Young Adult 22-64 Adult 65+ Senior Negative Number Invalid Input Sample Input Enter an age: 18 Sample Output: You are a young adult. Sample Input Enter an age: 29 Sample Output: You are an adult. Sample...
Create in Java a program that will prompt the user to enter aweight for a...
Create in Java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates both bolus and infusion rates based on weight of patient in an interactive GUI application, label it AMI Calculator. The patients weight will be the only entry from the user. Use 3999 as a standard for calculating BOLUS: To calculate the BOLUS you will multiply 60 times the weight of the patient for a total number. IF the...
Create in java a program that will prompt the user to enter a weight for a...
Create in java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates infusion rates based on weight of patient in an interactive GUI application, label it HEPCALC. The patients’ weight will be the only entry from the user. To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number....
I want to create an app which a user can talk to and get emotional feedback...
I want to create an app which a user can talk to and get emotional feedback in a form of a conversation. So, a user can talk about how stressful their day was, and my app should reply accordingly so that the user feels better. I want to know what methods(pyschologically) I can apply on my bot so that the user feels satisfied. In short, is there any psychological therapy term which deals with such conversations? Also, what all illnesses...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT