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
MA_775_DIABLO [31]
3 years ago
5

PYTHON

Computers and Technology
1 answer:
Korvikt [17]3 years ago
6 0

Answer:

import random

print("Hello! I have a random number from 1 to 100! It is your job to try and guess it!")

number = random.randint(1,101)

guess = int(input("start to guess: "))

num_guesses = 1

while guess != number:

   if guess > number:

       print("lower")

       guess = int(input("try again: "))

       num_guesses +=1

   elif guess < number:

       print ("higher")

       guess = int(input("start to guess: "))

       num_guesses +=1

print("congrats it took you", num_guesses, "tries")

Explanation:

You might be interested in
1. Write a method isMultiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The
zhannawk [14.2K]

Answer:

see explaination for code

Explanation:

Implement using JAVA

import java.util.Scanner;

public class Multiples {

public static boolean isMultiple(int first, int second){

if(second%first == 0)

return true;

else

return false;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){

System.out.print("Enter one number: ");

int first = sc.nextInt();

System.out.print("Enter a second number: ");

int second = sc.nextInt();

if(isMultiple(first, second))

System.out.println(second+" is multiple of "+first);

else

System.out.println(second+" is not multiple of "+first);

System.out.print("Do you want to enter another pair(y/n)? ");

char c = sc.next().charAt(0);

if('y' != Character.toLowerCase(c))

break;

}

}

}

/*

Sample run:

Enter one number: 7

Enter a second number: 28

28 is multiple of 7

Do you want to enter another pair(y/n)? y

Enter one number: 8

Enter a second number: 24

24 is multiple of 8

Do you want to enter another pair(y/n)? y

Enter one number: 4

Enter a second number: 2

2 is not multiple of 4

Do you want to enter another pair(y/n)? n

*/

8 0
3 years ago
Write a java program to find the average of any three numbers.​
nikklg [1K]

import java.util.Scanner;

public class JavaExample {

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

System.out.print("Enter the first number: ");

double num1 = scan.nextDouble();

System.out.print("Enter the second number: ");

double num2 = scan.nextDouble();

System.out.print("Enter the third number: ");

double num3 = scan.nextDouble();

scan.close();

System.out.print("The average of entered numbers is:" + avr(num1, num2, num3) );

}

public static double avr(double a, double b, double c)

{

return (a + b + c) / 3;

}

}

<em>The </em><em>output </em><em>is </em><em>attached </em><em>to </em><em>the </em><em>answer. </em><em> </em><em>You </em><em>can </em><em>also </em><em>check </em><em>it.</em><em>. </em>

7 0
1 year ago
Ray has to type an invoice using the QWERTY keyboard. Along with letters and numbers, he also has to insert the dollar sign. Whi
olganol [36]

Answer:

Shift and 4 at the same time, or hold shift and press 4.

4 0
3 years ago
Please help me with this question. I don’t get it
Lelechka [254]
A - they all use microprocessors to compute and store data.
3 0
3 years ago
Read 2 more answers
What units can be used to express density?
Sav [38]

Answer: Density is the mass of an object divided by its volume. Density often has units of grams per cubic centimeter (g/cm3). Remember, grams is a mass and cubic centimeters is a volume (the same volume as 1 milliliter).

Explanation:

8 0
3 years ago
Other questions:
  • What is a type of destructive program?
    8·2 answers
  • The term “computer literacy” dates back to what decade? <br> 1960s<br> 1970s<br> 1980s<br> 1990s
    5·1 answer
  • Meg[] elements = {new Lois(), new Stewie(), new Meg(), new Brian()}; for (int i =0; i
    15·1 answer
  • What are three attributes of the input tag
    5·1 answer
  • The page-replacement policy means that pages are not placed to make more space. A. True B. False
    6·1 answer
  • Write the code (from to )using for loop andif elseif statementto accept themobile phone numbersof200 residents of Dubaiasstringa
    15·1 answer
  • What does ADAC mean <br> pls answer quickly i will mrk brainliest
    14·2 answers
  • 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 a function called add_tuples that takes three tuples, each with two values, and returns a single tuple with two values con
    7·1 answer
  • Is hp pavilion pc a digital or analog computer
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!