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
1 month ago
14

Need 2.5 Code Practice Answers

Computers and Technology
2 answers:
Natasha_Volkova [897]1 month ago
4 1

Answer:

import random

random.seed(1,10) # Note: seed takes one argument, so this line has an error

a = random.randint(1, 10)

b = random.randint(1, 10)

print("Calculate: " + str(a) + " X " + str(b) + "?")

ans = int(input("Your answer: "))

if ans == a * b:

print("Well done!")

else:

print("That's wrong!")

Explanation:

amid [800]1 month ago
3 1

Answer:

import random

#random.seed() should not be used here as this method will produce same number again and again

a = random.randint(1,11) #this method will generate random number between 1 and 10

b = random.randint(1,11)

print("What is: " + str(a) + " X " + str(b) + "?")

ans = int(input("Your answer: "))

if (a * b == ans):

   print("Correct!")

else:

   print("Incorrect!")

Output :

What is: 8 X 5?

Your answer: 40

Correct!

Explanation:

  • First, the random module needs to be imported to generate random values.
  • The random.seed() function creates repeatable sequences, so it's avoided here to ensure different numbers each time.
  • The randint() method from the random module produces numbers within a specified range, inclusive of the lower bound and exclusive of the upper. Therefore, to get numbers from 1 to 10, the call is <code>randint(1,11)</code>.

You might be interested in
Q2 - Square Everything (0.25 points) Write a function called square_all that takes an input called collection that you assume to
zubka84 [942]
Refer to the explanation Define the function square_all() that receives a list of integers. This function should return a new list containing the square values of all integers found within the provided list. def square_all(num_list): #Initiate an empty list to store results. sq_list = [] #Iterate through the length of the list. for index in range(0, len(num_list)): #Calculate the square of the current value and add it to the result list sq_list. sq_list.append(num_list[index] * num_list[index]) #Return the squared values of all integers in num_list. return sq_list #Declare and initialize a list of integers. intList = [2, 4] #Invoke the square_all() function and pass the above list as an argument. Show the returned list. print(square_all(intList))
4 0
20 days ago
java methods Write a program whose input is a character and a string, and whose output indicates the number of times the charact
oksian1 [797]

Answer:

This is the JAVA code:

import java.util.Scanner; // to obtain user input

//class designed to count occurrences of a character within a string

public class CharacterCounter

//method that calculates how many times a character appears within a string

{ public static int CountCharacter(String userString, char character)

   {  

       int counter = 0;   //keeps track of the number of times the character appears in the string

for (int i=0; i<userString.length(); i++) //iterates over every character in the string

       { // if the character aligns with the one sought in the string

           if (userString.charAt(i) == character)

           counter++;  // increments the character count variable

       }  

       return counter;     } // returns the count of the character found in the string

public static void main(String[] args) {

    Scanner scanner = new Scanner(System. in);// accepts user input

    String string;

    char character;

       System.out.println("Enter a string"); // prompts the user for a string

       string = scanner.nextLine(); //captures the input string

       System.out.println("Enter a character");

       // requests the character input from the user

       character = scanner.next().charAt(0); //captures and reads the character

       System.out.println("number of times character "+character + " appears in the string " + string +": " + CountCharacter(string, character));  }  }

// calls CountCharacter method to display the frequency of a character in the input string

Explanation:

The CountCharacter() method contains a loop where index variable i traverses through each character of the string, incrementing the counter variable by 1 each time the sought character matches. This indicates that the counter maintains the tally of occurrences of the character in the string. The loop terminates when i exceeds the string length, which means the full string has been scanned for the specified character. Finally, the count variable yields the number of times the character was found in the string. The main() function receives user inputs for a string and a character to search for within that string. It subsequently invokes the CountCharacter() function to determine how many times the designated character appears in the specified string, displaying the result on the screen.

The program's output is provided in the attached screenshot.

5 0
1 month ago
Explain how abstraction is used in a GPS system
ivann1987 [930]

Answer

Abstraction in GPS technology allows the system to use clearly defined interfaces while enabling the integration of additional, more complex functionalities.

Explanation

The GPS system employs abstraction to organize layers of complexity for user interaction. It connects satellite-based positioning and timing systems to enable a radio receiver to acquire signals across four dimensions—latitude, longitude, altitude, and time—after synchronizing this data.


7 0
1 month ago
Read 2 more answers
In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2)
Harlamova29_29 [932]

Answer:

SyntaxError.

Explanation:

https://www.quora.com/In-Python-what-kind-of-error-is-returned-by-the-following-code-e-g-NameError-ValueError-IOError-etc-def-my_func-n1-n2-return-n1-n2-my_func-1-2-3          original source

brainlest plz

6 0
1 month ago
Use the following data definitions data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE" What will
Natasha_Volkova [897]

Answer:

Given Data:

myBytes BYTE 10h, 20h, 30h, 40h

myWords WORD 3 DUP(?), 2000h

myString BYTE "ABCDE"

From the supplied information, we can derive that:

(a).     a. EAX = 1

         b. EAX = 4

         c. EAX = 4

         d. EAX = 2

         e. EAX = 4

         f. EAX = 8

         g. EAX = 5

8 0
18 days ago
Other questions:
  • The part of the computer that contains the brain, or central processing unit, is also known as the A.monitor B.modem C.keyboard
    10·1 answer
  • Susan is assisting a web designer to create a promotional web page on eco-friendly classroom designs. She uses color combination
    5·1 answer
  • SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
    9·1 answer
  • Imagine you were using some of our pixelation tools to create an image and you posted it online for your friends to see - but, a
    11·1 answer
  • Charlie has a large book collection. He was keeping track of it in a spreadsheet, but it has grown big enough that he wants to c
    10·1 answer
  • Sarah works in a coffee house where she is responsible for keying in customer orders. A customer orders snacks and coffee, but l
    13·2 answers
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • What are the set of rules to move data from one computer to another?
    11·1 answer
  • Write an expression that will cause the following code to print "18 or less" if the value of user_age is 18 or less. Write only
    9·2 answers
  • The engineering firm you work for is submitting a proposal to create an amphitheater at a state park. Proposals must be submitte
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!