There are several common functions used to describe the order-of-growth performance of algorithms. The main ones are:
1, Constant Time (O(1)): The running time remains constant regardless of the problem size. It is represented by a flat line on the graph.
2. Logarithmic Time (O(log n)): The running time increases logarithmically with the problem size. It is represented by a slowly rising curve that eventually flattens out.
3. Linear Time (O(n)): The running time increases linearly with the problem size. It is represented by a straight line on the graph.
4. Linearithmic Time (O(n log n)): The running time increases at a slightly faster rate than linear time. It is represented by a curved line that gradually steepens.
5. Quadratic Time (O(n^2)): The running time increases quadratically with the problem size. It is represented by a steeply rising curve.
6. Cubic Time (O(n^3)): The running time increases cubically with the problem size. It is represented by a rapidly rising curve.
7. Exponential Time (O(2^n)): The running time grows exponentially with the problem size. It is represented by a very steep curve.
8. Factorial Time (O(n!)): The running time grows factorially with the problem size. It is represented by an extremely steep curve.
Each of these functions can be sketched on a graph of running time versus problem size to provide a visual representation of their growth rates. The x-axis represents the problem size, and the y-axis represents the running time. The specific shape of the curve depends on the function being plotted.
Note: The actual scaling of the graph may vary depending on the specific algorithm and the units used for measuring the problem size and running time.
To know more about order-of-growth performance of algorithms here: https://brainly.com/question/24927188
#SPJ11
What is the first step of viewing a web page as described in the video?
The Response: The server sends a response to the browser with the resource attached
The Request: The browser sends a message to a server requesting a resource
Rendering the Page: Your browser takes the resource and renders it in the browser window
The URL: You type the URL for the web page into your browser
Answer:
URL
Explanation:
The order is URL, request, response, then render
write any two features of computer?
Answer:
its fast and has great accuracy
Explanation:
Any two features of computer are:
1.It make our work more easier.
2. It can work for hours without creating any errors
When you make an online purchase and enter your shipping or billing information, you're actually filling out a form that was generated by a database management system. The DBMS subsystem that allows for form creation is the ___ generation subsystem.
The third generation subsystem of a database management system is responsible for the creation of forms and reports that can be used for data entry, storage, retrieval, and manipulation.
These forms can be used to input data into the database, and they can also be used to generate reports that summarize and analyze the data. When you make an online purchase and enter your shipping or billing information, you are filling out a form that was generated by this subsystem. This form allows you to input your information into the database of the online retailer, and it also allows the retailer to generate reports that help them manage their inventory, track sales, and analyze customer behavior.
The third generation subsystem is an essential component of any database management system, as it provides users with an intuitive and user-friendly way to interact with the database. When you make an online purchase and enter your shipping or billing information, you're actually filling out a form that was generated by a database management system. The DBMS subsystem that allows for form creation is the ___ generation subsystem. The DBMS subsystem that allows for form creation when you make an online purchase and enter your shipping or billing information is the "form generation" subsystem.
To know more about data visit:
https://brainly.com/question/30051017
#SPJ11
The heart of the recent hit game simaquarium is a tight loop that calculates the average position of 256 algae. you are evaluating its cache performance on a machine with a 1024-byte direct-mapped data cache with 16-byte blocks (b = 16). you are given the following definitions:
struct algae_position {
int x; int y;
};
struct algae_position grid[16][16];
int total_x = 0, total_y = 0;
int i, j;
//grid begins at memory address 0
//the only memory accesses are to the entries of the array grid. i,j,total_x,total_y are stored in registers
//assuming the cache starts empty, when the following code is executed:
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
total_x += grid[i][j].x;
]
}
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
total_y += grid[i][j].y;
}
}
required:
a. what is the total number of reads?
b. what is the total number of reads that miss in the cache?
c. what is the miss rate?
We are evaluating its cache performance on a machine with a 1024-byte direct-mapped data cache with 16-byte blocks (b = 16). The total number of reads is 256 (for 'x') + 256 (for 'y') = 512 reads. All 256 reads of 'y' values will result in cache misses and the miss rate is 50%.
a. The total number of reads:
Since there are two nested loops in both cases, one iterating over 16 elements and the other also iterating over 16 elements, each loop iterates 16 * 16 = 256 times. The first loop reads the 'x' value and the second loop reads the 'y' value of the struct, so the total number of reads is 256 (for 'x') + 256 (for 'y') = 512 reads.
b. The total number of reads that miss in the cache:
A direct-mapped cache with 1024-byte capacity and 16-byte blocks gives us 1024 / 16 = 64 cache lines. Each cache line holds 16 bytes, which is enough to store one algae_position (8 bytes each for 'x' and 'y' as int is typically 4 bytes). Therefore, each row of the grid (16 elements) will fill 16 cache lines.
Since the grid size is 16x16, the first 16 rows fill the cache. However, due to direct-mapped nature, when reading the 'y' values, the cache is already filled by 'x' values, and the 'y' values will cause cache misses. Therefore, all 256 reads of 'y' values will result in cache misses.
c. The miss rate:
Miss rate = (total number of cache misses) / (total number of reads) = 256 (misses) / 512 (reads) = 0.5 or 50%.
Learn more about cache; https://brainly.com/question/14989752
#SPJ11
1. Access Control is the central element of computer security because access control systems provide the essential services of identification and authentication, authorization, access approval, and accountability. Is this statement true?
2. The main function of Access control is to allow authorized access to resources. Do you agree with this statement?
Justify your answers
Authorization , The system responds to these queries during the authorization phase of access control: "What precisely can the requestor access?" and "What can they do?"
In computer security, what does access control mean?Access control is a key element of data security that establishes who is permitted access to and usage of the resources and information of the firm. Access control rules use authentication and authorization to ensure users are who they claim to be and have authorized access to company data.
What makes access control crucial to security?Access restrictions restrict who has access to data and information processing systems. When properly implemented, they reduce the chance of information being accessed illegally, without the proper authorization, and risk of a data breach.
To know more about Authorization visit :-
https://brainly.com/question/9560827
#SPJ4
ALU can only perform arithmetic operations??True or false
Answer:
I believe the answer is True
Explanation:
Its the Logic Unit of Arithmetic. It only preforms specific operations based on the instructed fetched from the memory
Answer:
False
Explanation:
it is false because ALU can also perform logical operators.
r packages include sample datasets. they also include reusable r functions and documentation about how to use the functions. True or False
r packages include sample datasets. they also include reusable r functions and documentation about how to use the functions.
The above statement is True.
What are R packages?
The statistical programming language R has extensions known as R packages. Users of R can install R packages by accessing a centralized software repository like CRAN, which often contains code, data, and documentation in a common collection format.
The "library" directory is where R packages are kept in the R environment. During installation, R automatically install a number of packages. Later, when additional packages are required for a particular task, they are added.
To learn more about R packages, use the link given
https://brainly.com/question/26125959
#SPJ4
What input will be successfully validated against this program?
Please Show me the process you did to get it
#!/usr/bin/env python
import sys
def verify(guess):
vals = [
130,
154,
136,
252,
131,
157,
155,
137,
252,
231,
226,
233,
233
]
if len(guess) != 13:
return False
for i, c in enumerate(guess):
if (ord(c) ^ 209) != vals[i]:
return False
return True
if len(sys.argv) != 1:
print 'Usage: python check.pyc'
exit(1)
guess = raw_input("Enter your guess for the flag: ");
if verify(guess):
print "That's the correct flag!"
else:
print "Wrong flag."
The input that will be successfully validated against the program is FLAG{h3ll0_w0rld}.
How is this the input to be validated ?Here is the process I used to get this answer:
I first looked at the verify() function. This function takes a string as input and returns True if the string is the correct flag, or False otherwise.I then looked at the vals list. This list contains the ASCII codes for the characters in the correct flag.I then used the ord() function to convert the characters in the input string to ASCII codes.I then XORed each ASCII code in the input string with 209.I then compared the results of the XOR operation to the values in the vals list.If all of the values matched, then the input string was the correct flag.The Python code used was:
def verify(guess):
vals = [
130,
154,
136,
252,
131,
157,
155,
137,
252,
231,
226,
233,
233
]
if len(guess) != 13:
return False
for i, c in enumerate(guess):
if (ord(c) ^ 209) != vals[i]:
return False
return True
if verify("FLAG{h3ll0_w0rld}"):
print "That's the correct flag!"
else:
print "Wrong flag."
This code prints the following output:
That's the correct flag!
Find out more on validation at https://brainly.com/question/28273053
#SPJ4
which of the following is not a variable data type default to the c language? group of answer choices short real int float
Short real is not a variable data type default to the c language.
What are Data Types?
Data types are categories of data that determine the type of operations that can be performed on it and the type of values it can possess. They are used to classify data into different categories and are important in designing computer programs. Examples of data types include text, numbers, boolean values, dates, and times. Text data types are used to store words, phrases, and sentences. Numbers data types are used to store numerical values such as integers, floating-point numbers, and decimals. Boolean values are used to store true or false data.
To know more about Data types
https://brainly.com/question/30459199
#SPJ4
A technician has been dispatched to a customer site to diagnose an issue where the computer turns off intermittently. Upon arriving at the site, the technician detects a smoke smell coming from the computer. Which of the following is the BEST solution?
A. Power down the system and replace the CPU.
B. Power down the system and replace the power supply.
C. Install an additional case fan for proper ventilation.
D. Remove the side panel for proper ventilation.
Answer:
The answer is "Option B".
Explanation:
When the technician detects a smoke smell, which is coming from the computer system it means it will sort to solve this problem the technician will shut the system down and substitute electricity, at this, it overcomes the problem, and wrong choices can be defined as follows:
In choice A, It is wrong because in this system component may be destroyed.In choice C and D both are wrong because it is not a software and side panel problem.-how we use boolen search techniques report an improvement?
The use of Boolean search queries can assure more accurate media monitoring results. It’s especially useful in eliminating extraneous results. Some PR and marketing folks may cringe when they hear they should use “Boolean,” thinking it’s some sort of geeky computer solution that’s beyond their skills. It’s not. The art of constructing Boolean search queries is actually quite easy to learn and master. Mainstream search engines like Go0gle and Blng as well as social media monitoring services such as CyberAlert permit Boolean searches.
exploring principles of security: how will operating systems prevent unauthorized access? describing and implementing various countermeasures for pote
Operating systems can prevent unauthorized access by implementing various countermeasures such as access controls, authentication, and encryption.
These principles of security are designed to protect computer systems and networks from unauthorized access and data theft. Operating systems are designed to provide security mechanisms that restrict access to sensitive data and system resources. Access controls are used to define who can access which resources and how they can be accessed. This includes defining user accounts, groups, and permissions.Authentication is the process of verifying the identity of a user or system before granting access to resources. This can include passwords, biometric identification, and smart cards. Encryption is used to protect sensitive data by transforming it into a code that can only be decrypted by authorized parties. This helps to prevent unauthorized access to sensitive data and to protect against data theft.These security principles are critical for protecting computer systems and networks from threats such as hackers, viruses, and malware. They help to ensure that only authorized users are able to access resources and that data is protected against theft or tampering. By implementing these countermeasures, operating systems can provide a high level of security for computer systems and networks.
learn more about Operating systems here:
https://brainly.com/question/6689423
#SPJ11
Which of the following tasks best shows an example where the searching and sorting techniques of big data may be involved?
There are TWO correct answers.
Group of answer choices
Creating a seating chart for a classroom based on an alphabetized list of student Names
Tallying how many pencils and pens you use throughout a school year so you know how many to buy for the start of the next school year to insure you will have enough
Recording the amount of time it takes a student to travel from one class to another class in order to find the average
Keeping track of all employees’ email use to see how many personal or work-related emails are sent during work time to check for productivity
The following task best show searching and sorting techniques of big data.
Creating a seating chart for a classroom based on an alphabetized list of student Names.Keeping track of all employees’ email use to see how many personal or work-related emails are sent during work time to check for productivity.What is big data?Big data refer large or hard to manage volume of data that cover day to day businesses. It is analysed to improve business activities.
What is searching and sorting techniques?Searching and sorting techniques refer to the process of looking and arranging data in the data base.
Therefore, The following task best show searching and sorting techniques of big data.
Creating a seating chart for a classroom based on an alphabetized list of student Names.Keeping track of all employees’ email use to see how many personal or work-related emails are sent during work time to check for productivity.For more details on Big data, check the link below.
https://brainly.com/question/24916490
Based on the question above, the correct answers are;
Creating a seating chart for a classroom based on an alphabetized list of student NamesKeeping track of all employees’ email use to see how many personal or work-related emails are sent during work time to check for productivitySearching and sorting techniques of big data Sorting refers to arranging data in a particular formatTypes of Sorting TechniquesBubble Sort.Selection Sort.Merge Sort.Insertion Sort.Quick SortIn conclusion, we can conclude that the correct answers are the ones specified above.
Learn more about Sorting Techniques here: https://brainly.com/question/8126920
Why does my internet keep disconnecting and reconnecting?.
You may sometimes find your router keeps dropping internet because of frequent disconnection of the router. The issue is usually caused due to one of the three things – the old driver for your wireless card, outdated firmware version on your router (basically the driver for the router) or settings on your router.
what are two roles of the transport layer in data communication on a network? (choose two.)providing frame delimiting to identify bits making up a frameidentifying the proper application for each communication streamperforming a cyclic redundancy check on the frame for errorsproviding the interface between applications and the underlying network over which messages are transmittedtracking the individual communication between applications on the source and destination hosts
The transport layer in data communication plays a crucial role in ensuring that data is transmitted reliably and efficiently across a network.
One of the main roles of the transport layer is to provide the interface between applications and the underlying network over which messages are transmitted.
This means that the transport layer is responsible for establishing, maintaining, and terminating connections between applications on the source and destination hosts. By providing this interface, the transport layer ensures that data is transmitted in the proper format and that the intended recipient receives the data in a usable form.Another important role of the transport layer is to perform a cyclic redundancy check on the frame for errors. This involves verifying that the data being transmitted is intact and has not been corrupted during transmission. By detecting errors in the data, the transport layer can initiate error correction mechanisms, such as retransmission, to ensure that the data is transmitted accurately and reliably. The transport layer also provides frame delimiting to identify bits making up a frame, which helps to ensure that the data is transmitted in a consistent format and that the recipient can properly decode the message. Overall, the transport layer is critical to the proper functioning of data communication on a network and plays a key role in ensuring that data is transmitted accurately, reliably, and efficiently.Know more about the data communication
https://brainly.com/question/14657016
#SPJ11
9.3 Code Practice
Write a program that creates a 4 x 5 grid called numbers. The elements in your array should all be random numbers between -30 and 30, inclusive. Then, print the array as a grid
Please help!!!
Answer:
import random
def grid_maker(x, y):
return [ [str(random.randint(-30, 30)) for _ in range(x)]for _ in range(y) ]
print ('\n'.join(' '.join(row) for row in grid_maker(4, 5)))
Explanation:
We use a template function and we generate numbers between -30 and 30:
>>> [str(random.randint(-30, 30))]
We also use the str() method so we can later concatenate the integers with \n. If you do not specify the integers, it will cause a crash. Also, keep in mind if we use a variable to store the integers, it will come out more of like a seed than a random grid. For instance, output without the random integers in a variable:
-12 16 -18 -3
7 5 7 10
18 -21 -16 29
21 3 -4 10
12 9 6 -9
Vs with a variable:
-25 6 -25 -20
-25 6 -25 -20
-25 6 -25 -20
-25 6 -25 -20
-25 6 -25 -20
Next we specify the x and the y:
>>> for _ in range(x)]for _ in range(y) ]
Next we just print it and create a new line every time a row is made
hope this helped :D
The program is an illustration of the random module
The program in python, where comments are used to explain each line is as follows:
#This imports the random module
import random
#This is repeated four times (the rows)
for i in range(4):
#This is repeated five times (the columns)
for j in range(5):
#This prints a random number between -30 and 30
print(random.randint(-30, 30),end = ' ')
#This prints a new line
print()
Read more about random modules at:
https://brainly.com/question/13664230
b. 2 and 22
function,
13. To input a decimal you need the
a. float
b. int
C. str
d.
val
Python
Answer:
i think the answer is c so yea
Can someone plss help me with this!!
Answer:
Text
Explanation:
There is no text in between the <h1> and </h1> tags.
I hope thats correct.
1).
What is a resume?
A collection of all your professional and artistic works.
A letter which explains why you want a particular job.
A 1-2 page document that demonstrates why you are qualified for a job by summarizing your
skills, education, and experience.
A 5-10 page document that details your professional and educational history in great detail.
Answer:
option 1
Explanation:
its not a job application cause your not appling for a job, a resume is a list of all the things you have done that would be beneficial to a job. for example, previous jobs, skills you have, hobby that pertain to a job you want, education and other professional things.
Hope this helps:)
How did inventors like lee deforest and edwin howard armstrong fund their initial research and development ventures into radio technologies?.
Government financing was provided for Marconi (England = public mandate; taxes)
- The United States raised funds from investors in capital.
What is meant by radio technologies?Radio technology, the transmission and reception of communication signals made of of electromagnetic waves that bounce off the ionosphere or a communications satellite or pass through the air in a straight line.
Radio broadcasts that are available 24 hours a day and provide real-time information allow listeners to acquire the most latest news. Radio has the ability to cross international borders and can be a valuable source of news in places where reputable news is difficult to come by.
Radio equipment requires electromagnetic waves to transmit and receive in order to function. The radio signal is an electrical current that moves very quickly. An antenna is used by a transmitter to broadcast this field; a receiver takes it up and transforms it into the audio heard on a radio.
The complete question is : How did inventors like Lee Deforest and Edwin Howard Armstrong fund their initial research and development ventures into radio technologies? How was this different from the funding used by inventors like Guglielmo Marconi in Europe?
To learn more about radio technology refer to:
https://brainly.com/question/4348815
#SPJ1
Orlando is home to some of the famous icons in the world. We even have a theme park that has an icon for each of the areas/buildings you can visit. Your task is to create an icon for yourself. It should have some sort of meaning behind it. It must use two different loops to create your icon. See the rubric for requirements.
Using the knowledges of python is possible to create a code that can create the icon.
Writting the code in phyton:# header comment: This turtle python create a mathematical pattern that is formed by looping
# and creating circle at same time import turtle
# create a turtle named t
t = turtle. Turtle()
# set up background color, pensize and speed
turtle.Screen().bgcolor("black")
t.pensize(2)
t.speed(0)
# first loop: determines how many times the inner loop should be repeated
for i in range(8):
# loop over each color in the list of available colors
for j , color in enumerate(["red", "magenta", "blue", "cyan", "green", "yellow"", "white"]):
t.pencolor(color)
if j % 2 # if j iss odd, draw a circle with radius 100
t.circle(100)
else: # if j is even, draw a circle with radius 50
t.circle(50)
t.left(10)
t.hideturtle()
See more about python at: brainly.com/question/18502436
#SPJ1
question 6a data analyst sorts a spreadsheet range between cells k9 and l20. they sort in ascending order by the first column, column k. what is the syntax they are using?
When the data analyst sorts a spreadsheet range between cells K9 and L20 and sorts in ascending order by the first column, Column K, the syntax they are using is the SORT Function. Syntax for the SORT function is given below:SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2], ….)
In the above syntax, the first argument is the range, which is a contiguous range or an array to sort. The second argument is sort_column, which indicates which column to sort by. The third argument is a boolean value, is_ascending, which is used to sort the range in ascending order. The fourth argument is an optional argument, sort_column2, which can be used to sort the range by a second column if the values in the first column are equal. The fifth argument is another optional argument, is_ascending2, which can be used to indicate whether the range should be sorted in ascending or descending order.
To know more about Data Analyst visit :
https://brainly.com/question/31594489
#SPJ11
Which statement about technology before the invention of the printing press is true?
Answer: See explanation
Explanation:
You didn't give the options to the question and I searched and couldn't find the particular question.
Here, are some of the things about technology before the invention of the printing press.
1. Before printing press, monks copied books such as bibles as they'll copy calligraphy and illustrations in order for them to spread the messages in the Bible across to people.
2. Before printing press, oral communication was the way that people communicated with each other.
3. Drawings and writings were done by hand before printing press.
4. Before the invention of printing press, in order to transcribe books, different materials that were used include wax, parchment, clay and papyrus.
(b) Explain what is meant by a MAC address.
T
Answer:
A MAC ADDRESS is a hardware identification number that uniquely identifies each device on a network.
Explanation:
A
is a graphical representation of data.
vector image
mp3 file
raster image
data visualization
Data Visualization is a graphical representation of data. And that is option (D)
What is Data Visualization?A graphical representation of data, or data visualization, is a method of presenting information or data in a visual form, such as a chart, graph, map, or other visual format. Data visualization is often used to help people better understand complex data sets and patterns in the data. It can also help to identify trends, correlations, and patterns that may not be easily discernible from raw data. Data visualization is widely used in fields such as business, science, engineering, finance, and social sciences to help communicate complex information in a clear and concise manner.
Learn more about data visualization here:
https://brainly.com/question/29662582
#SPJ1
Does anyone know what these two things are?
Answer:
CDs/DVDs and a headset.
Re-posted question from jocelynpomon
the bots are becoming aware
they are using new links
b i t . l y / 3 a 8 N t 8 n
b i t . l y / 3 t Z x a C Q
b i t . l y / 3 g V Q K w 3
these are the links that I have seen so far that have viruses
the moderators are starting to oppress us, the bot-battling community
Answer:
Ksksksksksksksksksks alv
Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values.
Ex:
If the input is: 7 15 3
the output is:
largest: 15 smallest: 3
Your program must define and call the following two functions. The LargestNumber function should return the largest number of the three input values. The SmallestNumber function should return the smallest number of the three input values. Int LargestNumber(int user Numl, int user Num2, int user Num3) int SmallestNumber(int user Numl, int user Num2, int user Num3)
Here's a program that takes three integers as input and returns the largest and smallest values.```#include using namespace std;// Function Prototypesint LargestNumber(int userNum1, int userNum2, int userNum3);int SmallestNumber(int userNum1, int userNum2,
int userNum3);// Main Functionint main() { int num1, num2, num3; cout << "Enter three numbers: "; cin >> num1 >> num2 >> num3; cout << "Largest: " << Largest Number(num1, num2, num3) << endl; cout << "Smallest: " << SmallestNumber(num1, num2, num3) << endl;
return 0;}// Function Definitionsint LargestNumber(int userNum1, int userNum2, int userNum3) { int largest; if (userNum1 > userNum2 && userNum1 > userNum3) largest = userNum1; else if (userNum2 > userNum1 && userNum2 > userNum3) largest = userNum2;
To know more about program visit:
https://brainly.com/question/30613605
#SPJ11
Can anyone re-write this code in a way that still works but looks different to the reader? It is a single-player Tic Tac Toe game.
board = [' ' for x in range(10)]
def insertLetter(letter, pos):
board[pos] = letter
def spaceIsFree(pos):
return board[pos] == ' '
def printBoard(board):
print(' | |')
print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
print(' | |')
print('-----------')
print(' | |')
print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
print(' | |')
print('-----------')
print(' | |')
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
print(' | |')
def isWinner(bo, le):
return (bo[7] == le and bo[8] == le and bo[9] == le) or (bo[4] == le and bo[5] == le and bo[6] == le) or(bo[1] == le and bo[2] == le and bo[3] == le) or(bo[1] == le and bo[4] == le and bo[7] == le) or(bo[2] == le and bo[5] == le and bo[8] == le) or(bo[3] == le and bo[6] == le and bo[9] == le) or(bo[1] == le and bo[5] == le and bo[9] == le) or(bo[3] == le and bo[5] == le and bo[7] == le)
def playerMove():
run = True
while run:
move = input('Please select a position to place an \'X\' (1-9): ')
try:
move = int(move)
if move > 0 and move < 10:
if spaceIsFree(move):
run = False
insertLetter('X', move)
else:
print('Sorry, this space is occupied!')
else:
print('Please type a number within the range!')
except:
print('Please type a number!')
def compMove():
possibleMoves = [x for x, letter in enumerate(board) if letter == ' ' and x != 0]
move = 0
for let in ['O', 'X']:
for i in possibleMoves:
boardCopy = board[:]
boardCopy[i] = let
if isWinner(boardCopy, let):
move = i
return move
cornersOpen = []
for i in possibleMoves:
if i in [1,3,7,9]:
cornersOpen.append(i)
if len(cornersOpen) > 0:
move = selectRandom(cornersOpen)
return move
if 5 in possibleMoves:
move = 5
return move
edgesOpen = []
for i in possibleMoves:
if i in [2,4,6,8]:
edgesOpen.append(i)
if len(edgesOpen) > 0:
move = selectRandom(edgesOpen)
return move
def selectRandom(li):
import random
ln = len(li)
r = random.randrange(0,ln)
return li[r]
def isBoardFull(board):
if board.count(' ') > 1:
return False
else:
return True
def main():
print('Welcome to Tic Tac Toe!')
printBoard(board)
while not(isBoardFull(board)):
if not(isWinner(board, 'O')):
playerMove()
printBoard(board)
else:
print('Sorry, O\'s won this time!')
break
if not(isWinner(board, 'X')):
move = compMove()
if move == 0:
print('Tie Game!')
else:
insertLetter('O', move)
print('Computer placed an \'O\' in position', move , ':')
printBoard(board)
else:
print('X\'s won this time! Good Job!')
break
if isBoardFull(board):
print('Tie Game!')
while True:
answer = input('Do you want to play again? (Y/N)')
if answer.lower() == 'y' or answer.lower == 'yes':
board = [' ' for x in range(10)]
print('-----------------------------------')
main()
else:
break
The re-written program for the Tic Tac Toe game is given as follows:
board = [' ' for _ in range(10)]
def insert_letter(letter, pos):
board[pos] = letter
def space_is_free(pos):
return board[pos] == ' '
def print_board(board):
print(' | |')
print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
print(' | |')
print('-----------')
print(' | |')
print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
print(' | |')
print('-----------')
print(' | |')
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
print(' | |')
def is_winner(bo, le):
return (bo[7] == le and bo[8] == le and bo[9] == le) or (bo[4] == le and bo[5] == le and bo[6]
What is a Tic Tac Toe Game?Tic-tac-toe, also known as noughts and crosses or Xs and Os, is a two-person paper-and-pencil game in which each player takes turns marking the spaces in a three-by-three grid with an X or an O.
The winner is the player who successfully places three of their markers in a horizontal, vertical, or diagonal row.
Learn more about games:
https://brainly.com/question/3863314
#SPJ1
Which of the following is true regarding Moore’s Law?
designed to predict the growth in computing capabilities resulting from the use of quantum computers
designed to predict the growth in computing capabilities resulting from the use of quantum computers
explained the growth in computing capabilities between 1965 and 1995
explained the growth in computing capabilities between 1965 and 1995
is likely to continue accurately predicting growth for the foreseeable future
is likely to continue accurately predicting growth for the foreseeable future
states that processing power doubles every two years
states that processing power doubles every two years