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
____ [38]
2 years ago
11

Write a function called play_round that simulates two people drawing cards and comparing their values. High card wins. In the ca

se of a tie, draw more cards. Repeat until someone wins the round. The function has two parameters: the name of player 1 and the name of player 2. It returns a string with format ' wins!'. For instance, if the winning player is named Rocket, return 'Rocket wins!'.
Computers and Technology
1 answer:
elena-s [515]2 years ago
8 0

Answer:

Here you go, Change it however you'd like :)

Explanation:

import random as r

def play_round(p1, p2):

   cards = [1,2,3,4,5,6,7,8,9,10,"J","Q","K","A"]

   play1 = r.choice(cards)

   play2 = r.choice(cards)

   

   while play1 == play2:

       play1 = r.choice(cards)

       play2 = r.choice(cards)

   

   if cards.index(play1) > cards.index(play2):

       return f"{p1}'s Card: {play1}\n{p2}'s Card: {play2}\nThe Winner is {p1}"

   else:

       return f"{p1}'s Card: {play1}\n{p2}'s Card: {play2}\nThe Winner is {p2}"

print(play_round("Bob","Joe"))

You might be interested in
Which tool do you think would be the most useful if you were designing a logo for a business?
Maurinko [17]

Answer:

maybe a computer would be helpful

6 0
3 years ago
Read 2 more answers
Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Read in each account number an
Zanzabum

Answer:

See explaination

Explanation:

/File: ValidateCheckDigits.java

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Scanner;

public class ValidateCheckDigits {

public static void main(String[] args) {

String fileName = "numbers.txt"; //input file name

String validFileName = "valid_numbers.txt"; // file name of the output file

//Open the input file for reading and output file for writing

try(Scanner fileScanner = new Scanner( new File(fileName));

BufferedWriter fileWriter = new BufferedWriter( new FileWriter(validFileName))) {

//Until we have lines to be read in the input file

while(fileScanner.hasNextLine()) {

//Read each line

String line = fileScanner.nextLine().trim();

//calculate the sum of first 5 digits

int sum = 0;

for(int i = 0; i < 5; i++) {

sum += Integer.parseInt( line.charAt(i) + "");

}

//Get the last digit

int lastDigit = Integer.parseInt(line.charAt(5)+"");

//Check if the remainder of the sum when divided by 10 is equal to last digit

if(sum%10 == lastDigit) {

//write the number in each line

fileWriter.write(line);

fileWriter.newLine();

System.out.println("Writing valid number to file: " + line);

}

}

System.out.println("Verifying valid numbers completed.");

} catch(IOException ex ) {

System.err.println("Error: Unable to read or write to the file. Check if the input file exists in the same directory.");

}

}

}

Check attachment for output and screenshot

4 0
3 years ago
5.
larisa86 [58]

Answer:

Explanation:

5 is correct answer

3 0
2 years ago
If a computer reboots itself on its own the computer might have a(n)
MissTica

Answer:

D. Software Problem

Explanation:

It could be that the software is bootlooping which will power on and off until its fixed.

4 0
3 years ago
How to call a void method with no parameters IN JAVA?
natka813 [3]

Explanation:

SanfoundryMenu

Java Program to Illustrate a Method without Parameters and Without Return Type

« PrevNext »

This is a Java Program to Illustrate a Method without Parameters and Without Return Type.

We have made the method to calculate area. We call this method from main method and then enter the radius of the circle as input. Now we calculate area and print the output.

Here is the source code of the Java Program to Illustrate a Method without Parameters and Without Return Type. The Java program is successfully compiled and run on a Windows system. The program output is also shown below

6 0
2 years ago
Other questions:
  • Company A is setting up a network of mostly Windows machines. Which networking file system protocol would you recommend for maxi
    5·1 answer
  • Assume that the 100,000 element integer array that you allocated starts at address 0x50000000 in memory, the size of an integer
    6·1 answer
  • You need to delegate AD RMS responsibilities to a junior administrator. You don't want to give the administrator more permission
    14·1 answer
  • Software as a Service (SaaS) refers to the use of computing resources, including software and data storage, on the Internet rath
    13·1 answer
  • In a study on software license infringement, those from United States were significantly more permissive than those from the Net
    15·1 answer
  • Im bored anyone up for a convo? lets talk.. =D
    7·2 answers
  • Compound conditions require a computer to sense whether multiple conditions are true or false.
    9·1 answer
  • You are the IT Administrator for a small corporate network. Until now, the network has consisted only of workstations accessing
    6·1 answer
  • Every workplace should have an emergency plan of action.
    15·2 answers
  • Which tools can help you gather information about the processes running on a windows operating system?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!