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

Instructions: Create a Java program that reads a string entered by the user and then determines...
Instructions: Create a Java program that reads a string entered by the user and then determines and prints how many of each lowercase vowel (a, e, i, o, and u) appear in the entire string. Have a separate counter for each vowel. Also, count and print the number of non-vowel characters. Example: User enters: "This house is beautiful." a: 1 e: 2 i: 3 o: 1 u: 2 non-vowel:10
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 (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will first enter a password, then enters the same password again; If the second input is the same as first one, the user successfully creates the password. Print “Well done.”; Otherwise, the user will be directed to repeat the whole process (go to step 1.)
Write a program that prompts the user enter a word, and determines the first half and...
Write a program that prompts the user enter a word, and determines the first half and second half of the word. Print the first and second half of the word on different lines. Sample runs of the program are shown below. Note: If the word is an odd number of letters, the first half should contain fewer letters (as shown in sample run #2) SAMPLE PROGRAM RUN #1                     Enter a word: carrot First half: car Second half: rot SAMPLE PROGRAM...
Write a program that will read user input, and do the following: 1. The user can...
Write a program that will read user input, and do the following: 1. The user can input letters [A-Z] as much as he wants (ignore case). 2. If the user input other than letters or two characters, stop the input process and start to print unduplicated sorted pairs such as the below examples: User input: A a e b d d D E a B 1 Output: AB AD AE BD BE DE User Input: a q w e dd...
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...
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
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...
Create a program that will take the user through an attempted dungeon escape. The user will...
Create a program that will take the user through an attempted dungeon escape. The user will represent a player and the player will have a variable to represent the HP (Hit Points) which will default to 50. Menu The program will start with the following menu: Welcome to dungeon escape. 1) Play the game 2) Exit the game If option 1 is chosen, the game is played, if not the program will end. First Set of Doors If option 1...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT