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
Mandarinka [93]
2 years ago
7

In python, how would I randomize numbers and insert them into a file?

Engineering
1 answer:
BabaBlast [244]2 years ago
7 0
Random integer values can be generated with the randint() function. This function takes two arguments: the start and the end of the range for the generated integer values. Random integers are generated within and including the start and end of range values, specifically in the interval [start, end].
You might be interested in
1. Which of the following will cause a spark knock?
zlopas [31]

Answer:

I couldn't find options for your question online, but I can give you an explanation so you can choose the correct option.

Explanation:

A spark knock is a form of unpredictable behavior that occurs in combustion, that is, in the chemical reaction that occurs between oxygen and an oxidizable material. Such combustion is usually manifested by incandescence or flame.

The spark knock is a detonation that occurs when there is a lot of pressure in the fuel.

<u>Some situations in which this can happen are: </u>

  • Engine overloaded.
  • Maximum pressure in the cylinders.
  • Engine overheated.
  • Overheated air.
  • Long and excessive engine ignition timing.
  • Spark plug at high temperatures.
5 0
3 years ago
computer language C++ (Connect 4 game)( this is all the info that was givin no input or solution) I used the most recent version
Mariana [72]

Answer:

C++ code explained below

Explanation:

#include "hw6.h"

//---------------------------------------------------

// Constructor function

//---------------------------------------------------

Connect4::Connect4()

{

ClearBoard();

}

//---------------------------------------------------

// Destructor function

//---------------------------------------------------

Connect4::~Connect4()

{

// Intentionally empty

}

//---------------------------------------------------

// Clear the Connect4 board

//---------------------------------------------------

void Connect4::ClearBoard()

{

// Initialize Connect4 board

for (int c = 0; c < COLS; c++)

for (int r = 0; r < ROWS; r++)

board[r][c] = ' ';

// Initialize column counters

for (int c = 0; c < COLS; c++)

count[c] = 0;

}

//---------------------------------------------------

// Add player's piece to specified column in board

//---------------------------------------------------

bool Connect4::MakeMove(int col, char player)

{

// Error checking

if ((col < 0) || (col >= COLS) || (count[col] >= ROWS))

return false;

// Make move

int row = count[col];

board[row][col] = player;

count[col]++;

return true;

}

//---------------------------------------------------

// Check to see if player has won the game

//---------------------------------------------------

bool Connect4::CheckWin(char player)

{

// Loop over all starting positions

for (int c = 0; c < COLS; c++)

for (int r = 0; r < ROWS; r++)

if (board[r][c] == player)

{

// Check row

int count = 0;

for (int d = 0; d < WIN; d++)

if ((r+d < ROWS) &&

(board[r+d][c] == player)) count++;

if (count == WIN) return true;

 

// Check column

count = 0;

for (int d = 0; d < WIN; d++)

if ((c+d < COLS) &&

(board[r][c+d] == player)) count++;

if (count == WIN) return true;

 

// Check first diagonal

count = 0;

for (int d = 0; d < WIN; d++)

if ((r+d < ROWS) && (c+d < COLS) &&

(board[r+d][c+d] == player)) count++;

if (count == WIN) return true;

 

// Check second diagonal

count = 0;

for (int d = 0; d < WIN; d++)

if ((r-d >= 0) && (c+d < COLS) &&

(board[r-d][c+d] == player)) count++;

if (count == WIN) return true;

}

return false;

}

//---------------------------------------------------

// Print the Connect4 board

//---------------------------------------------------

void Connect4::PrintBoard()

{

// Print the Connect4 board

for (int r = ROWS-1; r >= 0; r--)

{

// Draw dashed line

cout << "+";

for (int c = 0; c < COLS; c++)

cout << "---+";

cout << "\n";

// Draw board contents

cout << "| ";

for (int c = 0; c < COLS; c++)

cout << board[r][c] << " | ";

cout << "\n";

}

// Draw dashed line

cout << "+";

for (int c = 0; c < COLS; c++)

cout << "---+";

cout << "\n";

// Draw column numbers

cout << " ";

for (int c = 0; c < COLS; c++)

cout << c << " ";

cout << "\n\n";

}

//---------------------------------------------------

// Main program to play Connect4 game

//---------------------------------------------------

int main()

{

  int choice;

  int counter = 0;

  srand (time(NULL));

  Connect4 board;

  cout << "Welcome to Connect 4!" << endl << "Your Pieces will be labeled 'H' for human. While the computer's will be labeled 'C'" << endl;

  board.PrintBoard();

  cout << "Where would you like to make your first move? (0-6)";

  cin >> choice;

  while (board.MakeMove(choice,'H') == false){

  cin >> choice;

  }

  counter++;

  while (board.CheckWin('C') == false && board.CheckWin('H') == false && counter != 21){

  while (board.MakeMove(rand() % 7, 'C') == false){}

  board.PrintBoard();

  cout << "Where would you like to make your next move?" << endl;

  cin >> choice;

  board.MakeMove(choice,'H');

  while (board.MakeMove(choice,'H') == false){

  cin >> choice;

  }

  counter++;

  }

 

  if (board.CheckWin('C')){

  cout << "Computer Wins!" << endl;}

  else if (counter == 21){cout << "Tie Game!" << endl;}

  else {cout << "Human Wins!" << endl;}

  board.PrintBoard();

}

4 0
2 years ago
Situation: Peter is designing a new hybrid car that functions on solar power. He is currently working on sketches of his design
givi [52]

Answer:

whats the question?

Explanation:

8 0
2 years ago
To find the reactance XLXLX_L of an inductor, imagine that a current I(t)=I0sin(ωt)I(t)=I0sin⁡(ωt) , is flowing through the indu
Sophie [7]

Answer:

V(t) = XLI₀sin(π/2 - ωt)

Explanation:

According to Maxwell's equation which is expressed as;

V(t) = dФ/dt ........(1)

Magnetic flux Ф can also be expressed as;

Ф = LI(t)

Where

L = inductance of the inductor

I = current in Ampere

We can therefore Express Maxwell equation as:

V(t) = dLI(t)/dt ....... (2)

Since the inductance is constant then voltage remains

V(t) = LdI(t)/dt

In an AC circuit, the current is time varying and it is given in the form of

I(t) = I₀sin(ωt)

Substitutes the current I(t) into equation (2)

Then the voltage across inductor will be expressed as

V(t) = Ld(I₀sin(ωt))/dt

V(t) = LI₀ωcos(ωt)

Where cos(ωt) = sin(π/2 - ωt)

Then

V(t) = ωLI₀sin(π/2 - ωt) .....(3)

Because the voltage and current are out of phase with the phase difference of π/2 or 90°

The inductive reactance XL = ωL

Substitute ωL for XL in equation (3)

Therefore, the voltage across inductor is can be expressed as;

V(t) = XLI₀sin(π/2 - ωt)

3 0
3 years ago
A tool used to put a concave edge on a plane iron is
tigry1 [53]

Answer:

C) grinder

Explanation:

7 0
2 years ago
Read 2 more answers
Other questions:
  • A flat-plate solar collector is used to heat water by having water flow through tubes attached at the back of the thin solar abs
    8·1 answer
  • You are given that kc = 10-1 kg eq-1 min-1, ku = 10-3 kg2 eq-2 min-1 and [A]0 = 10 eq kg-1, where kc is the rate constant for a
    15·1 answer
  • A. Derive linear density expressions for BCC [110] and [111] directions in terms of the atomic radius R.
    7·1 answer
  • Complete the following sentence.
    13·1 answer
  • The specific gravity of a fluid with a weight density of 31.2 lb/ft is a. 2.00 b. 0.969 c. 0.500 d. 1.03
    10·1 answer
  • Your study space does not need to be quiet as long as you can ignore any noise coming from the space true or false?
    9·2 answers
  • Why do organisms differ in their methods of reproduction?
    5·2 answers
  • Why do you suppose a value of 5 is used? Do you think other values might work?
    6·1 answer
  • What is mechanical engineer​
    14·1 answer
  • The most important reason to wear your seat belt is to protect you from:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!