To make this code more efficient do not use NOT and AND operation instead of this use nested if to make it more efficient. Element last else part from code because this program will never come in this else part at any of the situation.
Program:
numb = int(input("What is your favourite number? "))
name = str(input("What is your name? "))
if numb == 7:
if name==("David"):
print ("got'em both!")
else:
print ("correct number, wrong name! you silly bean!!!!")
elif name==("David"):
if numb == 7:
print ("got'em both!")
else:
print ("Right name, wrong number")
else:
print ("neither")
Output:
...What is your favourite number? 4 What is your name? David Right name, wrong number
Q: Write a program (or modify the one written for Lab 2) that displays the following menu and prompts t...
A: Create a main method and declare all required variables (two variables for operations (+, -, *, /) a...
Q: in python 1. Write a program named filemaker.py that will be used to store the first name and age of...
A: Program code:
Q: in the program Python Write a program that the owner of Chica Chic could use to store data about he...
A: A python program is created to store the inventory details in a text file named as inventory.txt. Th...
Q: Draw a decision tree and find the number of key comparisons in the worst and average cases for the t...
A: Decision tree (enhanced bubble sort):
Q: A palindromic prime is any prime number that is also a palindrome. For example, 131 is a palindromic...
A: · Create a main class and required variable to solve the problem of palindromic prime.· ...
Q: In the discussion of ARQ protocol in Section 3.3.3, a scenario was outlined that resulted in the rec...
A: “Yes”, it is possible to allow the receiver to receive multiple copies of the same frame when the me...
Q: Find the truth table that describes the following circuit.
A: The diagram shown below is taken from the given question-
Q: PLEASE EXPLAIN ALL STEPSCreate a truth table of the equation:((((Y AND (NOT Z)) OR ((NOT Y) AND Z)) ...
A: Note: In the given equation, the number of opening and closing brackets is not equal. The following ...
Q: 1.Write a program in C++ , to count the number of people in each of the following age groups: 0-16 (...
A: Following is the approach of the program to count the number of persons of different age groups:Decl...