answer.
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
ira [324]
2 years ago
14

Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the output is

either heads or tails. Assume the input is a value greater than 0.
Computers and Technology
1 answer:
Nataly [62]2 years ago
7 0

Answer:

import random

decisions = int(input("How many decisions: "))

for i in range(decisions):

   number = random.randint(0, 1)

   if number == 0:

       print("heads")

   else:

       print("tails")

Explanation:

*The code is in Python.

import the random to be able to generate random numbers

Ask the user to enter the number of decisions

Create a for loop that iterates number of decisions times. For each round; generate a number between 0 and 1 using the randint() method. Check the number. If it is equal to 0, print "heads". Otherwise, print "tails"

You might be interested in
2.4: Star Pattern Write a program that displays the following pattern: * *** ***** ******* ***** *** * Output. Seven lines of ou
adelina 88 [10]

Answer:

// here is code in java.

public class NAMES

{

// main method

public static void main(String[] args)

{

int n=4;

// print the upper half

for(int a=1;a<=n;a++)

{

for(int b=1;b<=n-a;b++)

{

// print the spaces

System.out.print(" ");

}

// print the * of upper half

for(int x=1;x<=a*2-1;x++)

{

// print the *

System.out.print("*");

}

// print newline

System.out.println();

}

// print the lower half

for(int y=n-1;y>0;y--)

{

for(int z=1;z<=n-y;z++)

{

// print the spaces

System.out.print(" ");

}

for(int m=1;m<=y*2-1;m++)

{

// print the *

System.out.print("*");

}

// print newline

System.out.println();

}

}

}

Explanation:

Declare a variable "n" and initialize it with 4. First print the spaces (" ") of the upper half with the help of nested for loop.Then print the "*" of the upper half with for loop. Similarly print the lower half in revers order. This will print the required shape.

Output:

  *

 ***

*****

*******

*****

 ***

  *

5 0
2 years ago
What is an icon or animation used to represent a participant in an internet chat referred as?
lesantik [10]
An avatar, is the icon or animation that is used to represent a participant in an internet chat. Avatars are usually customizable to make it more 'you.'
3 0
2 years ago
Read 2 more answers
Most injury crashes in Florida happen in __________ conditions.
ivolga24 [154]

Answer:

Most injury crashes in Florida happen in dusk conditions

Explanation:

Dusk is the time of the day when the sun is setting. At this time of the day, the visibility on the roads is less. This time of the day, the number of cars on the roads is also significantly greater. This indirectly means that the possibility of most injury crashes in Florida in dusk conditions considerably increases.

The amount of tourism happening in the state is also a condition that takes part in injury crashes due to increased traffic on the roads.

7 0
2 years ago
Create a class named Billing that includes four overloaded computeBill() methods for a photo book store. • When computeBill() re
Karo-lina-s [1.5K]

Answer:

The Java code is given below with appropriate comments

Explanation:

<u>Billing.java </u>

//This is a BIlling class

public class Billing {

//Default constructor

public Billing()

{

}

//computeBill() method of having one parameter

public double computeBill(double price)

{

  return price+0.85*price;

}

//computeBill() method of having two parameter

public double computeBill(double price,int quantity)

{

  return price*quantity+0.85*price*quantity;

}

//computeBill() method of having three parameter

public double computeBill(double price,int quantity,double couponValue)

{

  return price*quantity+0.85*price*quantity-couponValue;

}

//computeBill() method of having four parameter

public double computeBill(double price,int quantity,double couponValue,double weeklyDiscount)

{

  return price*quantity+0.85*price*quantity-(couponValue+weeklyDiscount);

}

  public static void main(String[] args) {

     

  //Creating Billing Class Object

  Billing b=new Billing();

 

  //Displaying the cost of one book

System.out.println("Price of one Photo Book : $"+b.computeBill(45));

 

//Displaying the cost of 20 books

System.out.println("Price of 20 Photo Books : $"+b.computeBill(45,20));

 

//Displaying the cost of 20 books and having 50$ coupon

System.out.println("Price of 20 Photo Books and if we are having coupon value 50$ : $"+b.computeBill(45,20,50));

 

//Displaying the cost of 20 books, having 50$ coupon and 10$ discount

System.out.println("Price of 20 Photo Books ,if we are having coupon value 50$ and weekly discount of 10$: $"+b.computeBill(45,20,50,10));

 

  }

}

4 0
2 years ago
A disc you can read but not write on or erase is a:
Artist 52 [7]
I'm thinking it's a CD - ROM
8 0
2 years ago
Read 2 more answers
Other questions:
  • Donna often travels around the world. When she travels, she needs to access her emails from different locations. However, to kee
    6·2 answers
  • Computer hardware without software is useless while computer software without hardware is meaningless. Discuss. Plz provide exam
    15·1 answer
  • A search box does all of the following EXCEPT ________.
    12·2 answers
  • Given six memory partitions of 300 KB, 600 KB, 350 KB, 200 KB, 750 KB, and 125 KB (in order), how would the first-fit, best-fit,
    11·1 answer
  • In the game of $Mindmaster$, secret codes are created by placing pegs of any of seven different colors into four slots. Colors m
    5·1 answer
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    5·1 answer
  • If, instead, charge 3 is located to the left of charge 1 at a point (on the x axis) that satisfies the conditions given in the p
    7·1 answer
  • With respect to the general classes of computers, a ________ is the most expensive and most powerful kind of computer, which is
    7·1 answer
  • 2. BIOS is contained in ROM and not in RAM. Can you guess why?​
    15·1 answer
  • Write a function named shout. The function should accept a string argument and display it in uppercase with an exclamation mark
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!