Write a method called isMagicSquare that accepts a two-dimensional array of integers as a parameter and returns true if it is a magic square. A square matrix is a magic square if it is square in shape (same number of rows as columns, and every row the same length), and all of its row, column, and diagonal sums are equal. For example, [[2, 7, 6], [9, 5, 1], [4, 3, 8]] is a magic square because all eight of the sums are exactly 15.

Answers

Answer 1

Answer:

def isMagicSquare(myArray: list) -> bool :

   row_num = len(myArray)

   cols_num = [len(x) for x in myArray]

   count =0

   for x in cols_num:

       if row_num == x:

           count += 1

   if count == len(cols_num):

       return True

   else:

       return False

print(isMagicSquare([[1,2,3,1],[3,34,2,4],[43,5,7,5],[2,3,4,5]]))

Explanation:

In object-oriented programming, a method is a function defined in a class. Methods are actions that can be taken or executed in a class or to a class object.

The "isMagicSquare" is a python function or method in a class that returns true if a two array or list is a perfect square (same column and row length).


Related Questions

Create a Java program that takes input of a list of integers from the user, stores them into an array and then finally uses the array contents to output the list of integers in reverse. The user's input begins with the number of integers to be stored in the array. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers.

Answers

Answer:

This question is answered using Java

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 System.out.print("Length of array: ");

 int len = input.nextInt();

 int[] intArray = new int[len];

 for(int i = 0; i<len;i++){

     intArray[i] = input.nextInt();

 }

 for(int i = len-1; i>=0;i--){

     System.out.print(intArray[i]+" ");

 }

}

}

Explanation:

This line prompts user for length of array

 System.out.print("Length of array: ");

This gets the length of the arrau

 int len = input.nextInt();

This declares the array as integer

 int[] intArray = new int[len];

The following iteration gets input to the array

 for(int i = 0; i<len;i++){

     intArray[i] = input.nextInt();

 }

The following iteration prints the array in reversed order

 for(int i = len-1; i>=0;i--){

     System.out.print(intArray[i]+" ");

 }

In python, Write a function (name: identi Substring) that, given a string S, returns an integer that represents the numbers of ways in which we can select a non-empty substring of S where all of the characters of the substring are identical. Two substrings with the same letters but different in locations are still considered different. For example, the string "zzzyz" contains 8 such substrings. Four instances of "z", two of "zz", one of "zzz" and one instance of "y". String "k" contains only one such substring:"k". The length of S will be between 1 and 100, inclusive. Each character in S will be a lowercase letter (a-z).

Answers

Answer:

def identiSubstring(S):

    n = len(S)

    inst = ""

    count= 0

    for Len in range(1,n+1):

         for i in range(n-Len+1):

              for k in range(i,i + Len):

                   inst =inst+S[k]

              if(len(set(inst)) == 1):

                   count = count + 1

              inst = ""

    return count

           

S = input("Enter a string: ")

if(len(S)>=1 and len(S)<=100):

    print("There are "+str(identiSubstring(S.lower()))+" possible occurrences")

else:

   print("Length is invalid")

Explanation:

This line defines the required function

def identiSubstring(S):

This calculates the length of string S

    n = len(S)

This initializes an instance of the required string to an empty string

    inst = ""

This initializes count to 0

    count= 0

This following iterations iterate through the length of the string

    for Len in range(1,n+1):

         for i in range(n-Len+1):

              for k in range(i,i + Len):

This gets an instance of string S

                   inst =inst+S[k]

This checks if the characters of the instance are identical

              if(len(set(inst)) == 1):

If yes, the counter is incremented by 1

                   count = count + 1

This instance is reset back to an empty string

              inst = ""

This returns the number of instances of the substring

    return count

           

The main begins here

This prompt user for a string

S = input("Enter a string: ")

This checks for valid length

if(len(S)>=1 and len(S)<=100):

If length is between 1 and 100 (inclusive), this calls the identiSubstring function

    print("There are "+str(identiSubstring(S.lower()))+" possible occurrences")

If otherwise

else:

This prints invalid length

   print("Length is invalid")

See attachment

Krista needs to configure the default paste options in PowerPoint 2016. Which area of the Options dialog box will she need to use to configure these options?

Proofing
General
Save
Advanced

Answers

Answer:

[tex]\red{\underline{\underline{\sf{Answer :-}}}} [/tex]

Advanced

Answer: General

Explanation:

g Create a Java program that takes input of a list of integers from the user, stores them into an array and then finally uses the array contents to output the list of integers in reverse. The user's input begins with the number of integers to be stored in the array. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers.Create a Java program Ex: If the input is: 8 5 2 3 4 10 6 8 9

Answers

Answer:

import java.util.Scanner;

public class Main{

public static void main(String[] args) {

int arraylent;

Scanner input = new Scanner(System.in);

System.out.print("Array Length: ");

 arraylent= input.nextInt();

int[] myarray = new int[arraylent];

for(int i = 0; i<arraylent;i++)

    myarray[i] = input.nextInt();

for(int i = arraylent-1; i>=0;i--)

System.out.println(myarray[i]);

}

}

Explanation:

This declares the length of the array

int arraylent;

This next two lines prompt and get the array length i.e. number of input

System.out.print("Array Length: ");

 arraylent= input.nextInt();

This declares the array as type integer. And the length of the array is gotten from the user input

int[] myarray = new int[arraylent];

This gets the items of the array

for(int i = 0; i<arraylent;i++)

    myarray[i] = input.nextInt();

This reverse and prints the array

for(int i = arraylent-1; i>=0;i--)

System.out.println(myarray[i]);

PLS HELP ASAP- Select the correct text in the passage.
Which concept explained in the paragraph below means that data always remains consistent?

Specific programs have some tasks that a computer must perform in parallel with others. These tasks (such as the performance of the same set of operations on different data sets) often work in parallel clusters. In such cases, a separate thread of execution handles each separate task. You can think of a thread as a sequence of instructions that computers can manage independently.
It is possible for different threads to access the same data elements and change their values, and this can lead to an inconsistent state of information. For instance, if multiple programs access a shared variable x and change its value, the variable will not contain the correct value at the end of the programs. We can prevent such inconsistencies by using locks. A thread puts a lock on shared data, and releases this lock only after completing its operations.

Answers

Answer:

reread the text

Explanation:

I do it it helps

Answer:

A thread puts a lock on shared data, and releases this lock only after completing its operations.

The last sentance

Explanation: TRUST ME ISTG THATS THE ANSWER

Show the dynamic and speculation execution for the following code

Add F2,F3,F4
Loop : Lw F2,0(R1)
Subi R1,R1,8
Div F9,F10,F11
Sw F9,5(R2)
Bne R1,Loop




- 1 Fp & 1 Int operation can issue at the same cycle
- 3 execution stage
- 2 commit stage
- FP : 2 cycle
- Lw : 2 cycle
- ALU : 3 cycle
- Two iteration

Answers

Answerf9,f10,fll

Explanation:

Which tab should you use to change the text font color in your presentation?

Answers

Answer:

The Home Tab

Explanation:

2. When You buy 4 GB memory unit (pendrive) you
will get memory less than 4 GB?​

Answers

Answer:

Yes.

Explanation:

I believe so, because the pendrive takes some storage for it to actually function. If they wanted it to have exactly 4 GB of memory, they would have to add extra memory.

Having too much b-roll footage is often a problem for editors

True
False

Answers

verdade pois tem muita filmagem e é dificil escolher a melhor imagem

Select the correct answer. Which type of computer application is Apple Keynote? OA. word processor O B. spreadsheet O C. presentation OD. database O E. multimedia

Answers

Answer:

Apple Keynote is presentation Software

The correct option is C

Explanation:

Now let explain each option

Word processor:

Word processor is incorrect because it is used to type text, format it add tables and figures, For example MS Word

Spread Sheet:

Spread Sheet is incorrect as it is used for calculation. Like MS Excel

Presentation:

Key tone is a presentation software. it is used to make presentation and add animation and transition to it.

Database

Database is incorrect because databases are used for storing data. Not for presentation.

How can you get access to help? Check all that apply

Answers

Answer:

The answer is "F1"

Explanation:

Please find the complete question in the attachment file.

The F1 key is also known as the function key, which can be used to configure on a device or console key to cause such actions, a form of a soft button, to also be performed by a web browser control parser or software application. The main purpose of the F! key is to open the Help screen for all programs.

dumb question but...for christmas should i get the animal crossing switch or the forrnite one which has a lot and a colored doc? ​

Answers

Answer:

Its your decision but I would go with animal crossing!

Write a program that reads a stream of integers from a file and prints to the screen the range of integers in the file (i.e. [lowest, highest]). You should first prompt the user to provide the file name. You should then read all the integers from the file, keeping track of the lowest and highest values seen in the entire file, and only print out the range of values after the entire file has been read.

Answers

Answer:

This question is answered using C++ programming language

#include <fstream>

#include<iostream>

using namespace std;

int main() {

  string fname;

  cout<<"Enter Filename: ";

  cin>>fname;

  int lowest = 0;

int highest = 0;

  ifstream ifs(fname);

  int x;

  while (ifs >> x){

  if(x < lowest){

   lowest= x;

  }

  if(x > highest) {

   highest = x;

  }

  }

  ifs.close();    

  for(int i = lowest; i<=highest;i++)

  {

   cout<<i<<" ";

  }

     

}

Explanation:

This line declares fname as string  

string fname;

This prompts user for filename

  cout<<"Enter Filename: ";

This gets filename

  cin>>fname;

This declares and initializes lowest to 0

      int lowest = 0;

This declares and initializes highest to 0

int highest = 0;

This defines the file using ifstream

  ifstream ifs(fname+".txt");

This declares x as integer. x is used to read integers in the file

  int x;

The following iteration will be repeated until there is no other integer to be read from the file

  while (ifs >> x){

This checks for lowest

  if(x < lowest){

   lowest= x;

  }

This checks for highest

  if(x > highest) {

   highest = x;

  }

  }

This closes the file. i.e. the file has been read

  ifs.close();    

The following iteration prints the range of values from lowest to highest

  for(int i = lowest; i<=highest;i++)  {

   cout<<i<<" ";

  }  

Please note that the filename must be entered with its extension

A value chosen by the responder to identify a unique IKE SA is a _________.
A. Initiator SPI
B. Responder SPI
C. Flag
D. Message identifier

Answers

Answer:

Responder SPI

Explanation:

Responder SPI : Cookie of an individual referring to an application from the SA organization, a message from the SA, or a delete from the SA.

Helen is working on her colleague’s photos. She came across this particular photo and was confused about which effect the photographer had used in the photo. Can you help her figure out the effect?
The effect used in the photo is

Answers

Answer:

it could be Tilt-shift - Tilt-shift effect - or Miniature faking.

Explanation:

Fill in the blank are always hard when the system has a set answer. But photographers commonly use the tilt-shift effect to focus on a certain part of the image while blurring the rest of the photograph. They refer to this as selective focus. You can use the tilt-shift effect and selective focus for miniature faking. This is where the subjects in the photograph appear miniaturized. Hope this helps

Answer: tilt-shift

Explanation:

What does Stand for in web design

Answers

Answer:

g

Explanation:

h

Course Aggregation Many times, departments are only interested with how students have done in courses relative to a specific major when considering applicants for admission purposes.
For this problem you are given a dictionary where the keys are strings representing student ids and the values are dictionaries where the keys represent a course code and the value represents a grade. Your task is to write a function that given a dictionary of the described format and a prefix for course codes, return a dictionary where each key is a student id and the corresponding value is the average grade of the student only in courses that start with the given prefix.
def course_grader (student_to_grades, course_prefix): ({str, {str, float}}) -> {str, float} I: a dictionary containing the grades of students (as described above) and a course code prefix P: compute and store the average grade of all students only for courses that start with the given course prefix 0: a dictionary of student ids to average grades as described in the Processing step pass

Answers

Answer:

def course_grader(student_to_grades, course_prefix):

   student_grades = dict()

   for key, value in student_to_grades.items():

       grade_score = 0

       for course,grade in value.items():  

           if course_prefix == course:  

               grade_score += grade

                student_grades[key] = grade_score / len(value.keys())

   return student_grades

Explanation:

The course_grader function is a python program that accepts two arguments, the student dictionary and the course prefix. The function returns a dictionary of the student id as the key and the average grade of the student as the value.

Which feature should be used prior to finalizing a presentation to ensure that audience members with disabilities will be able to understand the message that a presenter is trying to get across?

Compatibility Checker
Accessibility Checker
Insights
AutoCorrect

Answers

Answer:

Accessibility Checker

Answer:

answer is accessibility checker or B on edge

The material inspection and recieving report the multi-purpose document that serves as evidence of inspection and acceptance, shipping document, receiving document, and contractor invoice is designated as the:________.

Answers

Answer:

DD Form 250

Explanation:

DD Form 250 which is an acronym for Department of Defense Form 250.

It is the Material Inspection and Receiving Report that is used for contracts supplies and services including acquiring noncommercial commodities such as:

1. Acknowledgment of equipment by the Government

2. Contractor's invoice for expense.

3. loading record for hauling and acquiring.

4. Proof of Government Quality assessment.

Hence, in this case, the correct answer is DD Form 250.

hurry i need help swear to god i will give brainliest not lying

Answers

Answer:

finding area of a circle

def area(radius):

   int(radius)

   formula = radius * radius * 3.14

   print(formula)

radius_input = int(input('Insert the radius of your circle: '))

area(radius_input)

hope this helped :D

How much data can a flash drive store?​

Answers

Answer:

depends on which flash drive

Explanation:

32GB-1000 photos

Well, It just depends on which size you get. You could get a 512 MB or 10 GB. I prefer somewhere in the middle because I don't need to store a lot of stuff in my Flash drive.

explain the major innavotions made from the establishment of abacus​

Answers

Answer:

The summary of that same question would be described throughout the following section.

Explanation:

Specification of simple or rough arithmetic has been accomplished through imaginative technologies with stone blocks, developers have always used computer systems again for the past decades. The varying forms of technology of the 5th generation were indeed desktops, notebooks, or laptops, and they can look at images of pieces of machinery that have been pioneered before today's computer systems.

The type of device which is 3 ½ inch floppy drive is​

Answers

Answer:

That would be known as a floppy disk(literally)

Explanation:

It is a removable magnetic storage medium. They are used for moving information between computers, laptops or other devices.

cutting of trees is bad or not bad​

Answers

It is bad cutting tree :(

Answer:

bad

Explanation:

it gives out air and oxygen

The OpenMP critical-section compiler directive is generally considered easier to use than standard mutex locks, because

Answers

Complete question

A) management of entry and exit code is managed by OpenMP library reducing the possibility of programming errors.

B) programmers don't need to worry about race conditions.

C) a thread cannot block inside a critical section.

D) deadlock cannot occur.

Answer:

A. Management of entry and exit code is managed by OpenMP library reducing the possibility of programming errors

Explanation:

This is a multiple choice question and this is the answer because:

1. OpenMp is inclusive of an APL/compiler directives:

2. any code which follows #pragma omp parallel is a parallel region and it is performed by large number of threads that are same as the number of processing cores that are in the system.

3. The critical-section compiler directive acts more like a binary semaphore or mutex lock,it makes sure that only one thread is active in the critical section at the same time.

In a text messaging system, data is sent from one device to another. Devices are recognized by a unique device ID. The format of the message is sent as a string with information about the number of characters in the device ID, the device ID itself, the number of characters in the text message and the text message that is being sent with each part being separated by a space. The system uses this information to send the message to the correct device and the receiving device displays only the text message. The number of words in the text message is also useful. A word is defined by strings separated by spaces.
Here is a sample VALID message:
04 1234 05 hello
The first two digits in the string represent the length of the device ID to follow.
The device ID is the number of characters following the length. Note that the device ID may not be limited to number values.
Following the device ID is the length of the text message and then the text message itself. The text message may be any combination of characters (such as letters, numbers or symbols) and may include spaces.
This message contains one word.
Here is a sample INVALID message:
06 a2b10 09 I’m ready
The first two values 06 indicate the device ID length. The device ID is a2b10 which has a length of 5. This does not match the specified length 06. Thus, this is NOT a valid message.
This message contains two words.
The Message class represents messages in this system. A Message must have a device ID, the length of the ID, the length of the message and the text message being sent in order to be a valid message sent through the system. The Message class must determine if a message is valid in order to send a message. A valid message is one where the device ID length matches the given length in the message string and the text message length matches the length of the supplied text message. The text message consists of one or more words where the length of the text message string is at least one character.
Consider the code below:
Message msg1 = new Message("08 abc123xy 16 Computer Science"); //creates a new message object
boolean msg1Valid = msg1.isValid(); // returns true for a valid message
String text = "11 radio11a287 14";
Message msg2 = new Message(text);
boolean msg2Valid = msg2.isValid(); // returns false for an invalid message
Message msg3 = new Message("04 92a1 16 Computer Science");
Message msg4 = new Message("03 x8r 21 Today is a great day!");
int numWords = msg4.wordCount(); //returns 5, the number of words in the
//text message
Complete the Message class by writing the isValid() and wordcount() methods.
public class Message{
private int idLength;
private String deviceID;
private int msgLength;
private String textMsg;
public Message(String msg){
//implementation not shown
}
public boolean isValid(){
//to be written
}
public int wordCount(){
//to be written
}

Answers

Answer:

public int wordCount() {

       String[] arr = textMsg.split(" ", 0);

       return arr.length();

   }

public boolean isValid() {

       if (idLength == deviceID.length()) {

           if (msgLength == textMsg.length()) {

               return true;

           } else {

               return false;

           }

       return false;

   }

Explanation:

The Java source code defines two methods in a class named Message namely; isValid() and wordCount(). The isValid() method evaluates the validity of a message sent to return a boolean value while the wordCount() counts and returns the number of words in the message.

Write a program with a method called passwordCheck to return if the string is a valid password. The method should have the signature shown in the starter code.
The password must be at least 8 characters long and may only consist of letters and digits. To pass the autograder, you will need to print the boolean return value from the passwordCheck method.
Hint: Consider creating a String that contains all the letters in the alphabet and a String that contains all digits. If the password has a character that isn’t in one of those Strings, then it’s an illegitimate password!
Coding portion:
public class Password
{
public static void main(String[] args)
{
// Prompt the user to enter their password and pass their string
// to the passwordCheck method to determine if it is valid.
}
public static boolean passwordCheck(String password)
{
// Create this method so that it checks to see that the password
// is at least 8 characters long and only contains letters
// and numbers.
}
}

Answers

Answer:

import java.util.regex.*;

import java.util.Scanner;

public class Password

{

  public static void main(String[] args) {

  Scanner input = new Scanner(System.in);

  System.out.println("Please enter the Password. \n");

  String passwordString = input.next();

  System.out.println(passwordCheck(passwordString));

  }

  public static boolean passwordCheck(String password){

  if(password.length()>=8 && password.matches("[a-z0-9A-Z]+")){

  return true;

  }

  else{

  return false;

  }

  }

}

Explanation:

The Java class "Password" is used by the program to make an instance of the password object and check its validity with the passwordChecker method defined within the Password class. The passwordChecker method only matches alphanumeric passwords, that is, passwords with alphabets and numbers. If a non-alphanumeric character is encountered, the boolean value false is returned.

how do you evaluate the use of the navigational aids and technology

Answers

Explanation:

A navigational aid or AtoN or navaid is any sort of marker that guides to mark safe waters and also help mariners in determining their position with respect to land or any navigational hazard or hidden danger. Traditionally aids to navigation have been physical aids such as lighthouses, buoys and beacons

8. T/F: At the bottom of a slide you are working on you can enter notes to indicate what yo
True
False
« BACK
LESSON 8.1 - INTRO TO PRESENTATIONS

Answers

Answer: True. Hope it helps!

if resistors were 10 times larger what would happen to output voltage

Answers

Answer:

is there a picture to go w the question?

Other Questions
Which statement best summarizes how human lifestyles are currently affecting the sustainability of resources on Earth? What is UNTRUE of the Red Scare of the 1950s?A.The Hollywood Ten refused to testify in front of HUACb. House Un-American Activities Committee pursued communistsSenator McCarthy claimed to have a list of communistsd. Eisenhower & Truman supported the communist hunts spoilage bacterial can be identified easiest by Asian practice various types of farming True or False Olive, the owner of Olives Orchard, contracts to sell its harvest to Pure Foods, Inc. Later Olive refuses to perform. Pure Foods files a suit to enforce the contract. Olive and Pure Foods are in a state that does not recognize the doctrine of unconscionability. To defend successfully against enforcement of the contract on similar grounds, Olive might rely on traditional notions of a.materiality. b.mistake. c.value. d.fraud. What happens to an animal that does not volunteer to do extra work on Sunday in animal farm What does "consent of the governed" mean?A.) The representatives give power to the government through elections.B.) The government gives rights to the people through laws.C.) The people give power to the government through their representatives. What is mABC?A. mABC = 60B. mABC = 67C. mABC = 120D. mABC = 127Brainlist for the correct answer 5.Correct answer I will put as brainiest discuss what influenced the supreme court decisions? Which of the following is the MOST COMMONsign of possible EMOTIONAL abuse of a child?A) Knowledge or interest in sexual acts.B) Frequent injuries or unexplained bruises.C) Wearing inappropriate clothing.D) Lack of attachment to a parent or caregiver. Evaluate. 8/1253 How is reception different than transduction? What is the constant variation of 2x+y=-4? matching math game help! Find the midpoint. Help pleaseeee is there anybody taking the algebra test in texas i would really appreciate the answeres 2x+4x -17y I need the answer please a car dealer so 32 cars their first month The next month they sell 54 cars What is the percentage of change in the number of sold cars Which word group contains coordinate adjectives for the noun "library"?A. expansive respectedB. largest monasteryC. oldest scholarlyp. smallest public