1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natita [175]
2 years ago
7

What's wrong with my program? Here is my code , if the user wants a 3rd card dealt they, have to select yes and the total will b

e for 3 cards. If they don't, then the total is for 2 cards.? I also need to print the total for both the dealer and the user and determine the winner of the game?
# import random
import random
def main():
# greet the user
print("Hello! Welcome to my card game!")
# deal the user a random card between 1 and 10
num1 = random.randint(1,10)
print("You drew a", num1)
# deal the user another random card (between 1 and two)
num2 = random.randint(1,10)
print("You drew a", num2)
num3 = random.randint(1,10)

# deal the user a third card?
again = input("Would you like to draw a 3rd card? Y or N? ")
d_total = random.randint(10,21)
u_total = (num1) + (num2) + (num3)
u_total1 = (num1) + (num2)
if again == "Y" or "y":

print("You drew a", num3)


if (u_total > d_total) and (u_total < 21):
# the user wins
print("Congratulations! You won!")
print("You drew a",num1,",", "a",num2,"," "and a",num3, "for a total of",u_total)
if again == "N" or "n":
print("You drew a", num1,"and a",num2, "for a total of",u_total1)


if (u_total > d_total) and (u_total < 21):


print("The dealer's total is", d_total)




else:

print("Sorry! You lose.")

main()
Computers and Technology
1 answer:
Mashcka [7]2 years ago
4 0

Your issue is on line 19 in your if statement. In python, if you have more than one condition in an if statement, you have to explicitly mention it after the or.

Your if statement is

if again == "Y" or "y":

However, this will always return true because the second statement simply asks "y".

To correct this, simply change the if statement to:

if again == "Y" or again == "y":

This will correct your code.

Another thing to consider is to always convert a userinput (whenever possible) to one version, this can be accomplished in your code by converting "again" into one version by using the .lower function.

again = input("Would you like to draw a 3rd card? Y or N? ")

again = again.lower()

Hope this helps!

You might be interested in
In any *NIX system, after saving a script named "script_name," you need to make it executable so that you can run it. Which comm
REY [17]

Answer/Explanation:

chmod +x script_name

Cheers

4 0
4 years ago
On the Attendance worksheet, in cell L5, enter an IF function to determine if the percentage in cell K5 is greater than or equal
Ad libitum [116K]

Answer:

=IF(K5>=H18,"Goal Met", "Review")

Explanation:

The syntax of if the statement is as below:

=If( logic test, if true then this, if false then this)

And hence, and as in question logic test is k5>=H18, and on true the output should be Goal met, and on false the output should be review. And hence, we get the above formula, and which is the required answer.

8 0
3 years ago
Use the Web to search for different ways to share an Access database, such as the one for Colonial Adventure Tours, with others
stellarik [79]

Answer:

Check the explanation

Explanation:

There are certainly many ways through which we can access and share database. The different ways to share an access database are as follows:  

1. By using Sharepoint site: To utilize the SharePoint you should have windows SharePoint services server enabled on your system. Sharepoint assists in making database accessing very convenient by using methods like linking to list and publishing a database.  

2. By using database server: This technique split a database that the tables are stored on the network in which each user has a copy of an access database file. The database file comprises of tables which contain queries, reports, forms, and other database objects.  

3. By using split database: This technique is utilized when a database server product or a SharePoint site is unavailable. The tables then gains access into one access file and everything goes to other access files.  

4. Network Folder: In this technique database file is stored on a shared network device and users can use the file simultaneously.  

Below is the table for necessary hardware and software:

                                                   Sharepoint  database     split       Network

                                                         site          server    database    Folder

Need for database server software?No             Yes       No        No

Need for windows server?                Yes              No        No        No

6 0
4 years ago
Which technology do environmental scientists use to photograph and report poaching activities
Svetach [21]
Thermal imaging techniques are used to track any illegal entry into a restricted area, and for photographing ad reporting poaching activities. They send automatic alerts to the Rangers, whenever they sense poachers in the area. The sensors are able to differentiate between natural movements of animals and human motions.
3 0
4 years ago
Read 2 more answers
Explain the history of computing of mechanical era
OLga [1]

Answer:The Mechanical Era

Created a machine that could add and subtract numbers. Dials were used to enter the numbers. ... Designed a machine called the Analytical Engine. The design had all the basic components of a modern day computer. In addition, it was designed to be programmable using punched cards.

Explanation:Hope this helped

4 0
3 years ago
Read 2 more answers
Other questions:
  • Fill in the missing statements or expressions in the following code that checks to ensure that a user enters an integer value at
    11·1 answer
  • A number used to encrypt data is called a(n ________. signature key cookie escrow
    10·1 answer
  • What makes us see continuously moving images when still images appear in rapid succession
    11·1 answer
  • How many times will the while loop that follows be executed? var months = 5; var i = 1; while (i &lt; months) { futureValue = fu
    12·1 answer
  • Who want a rap song if yes try to rap too this Can you move it like this? I can shake it like that
    10·2 answers
  • Which language paradigm interacts well with database systems in business environments that use SQL? (I WILL GIVE BRAINLIEST TO T
    11·1 answer
  • Columns, margins and orientation can all be found on what tab?
    15·1 answer
  • What is table,form,query and report ?short ans​
    13·1 answer
  • You are going to visit a national park, and have never been there before. You are using a map to try and make the distance trave
    11·1 answer
  • Write an Algorithm to print only numbers from 10 to n times using iteration structure
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!