Given int[] array, return a new int[] that contains every other element of array. for example, if array = {0, 1, 2, 3, 4, 5}, return {0, 2, 4}.

Hint: How big does the new array have to be?

Tip: Write down an example array to help find the pattern between the index from the old array and the index in the new array.

Answers

Answer 1

This is how you do it in python:

Code:

def everyother(array):

   return array[::2]

example_array = [0, 1, 2, 3, 4, 5]

print(everyother(example_array))

Output:

[0, 2, 4]

Explenation:

The key to this problem is "array[::2]".

Array[start : stop : step]

Writing "array[::2]" is the same as writing:

Array[0 : -1 : 2] or Begin at 0, stop at the end and take every 2:nd value


Related Questions

"An email comes from your boss who says his laptop, phone and wallet has been stolen and you need to send some money to an account right away".
what do you think is the type of computer security this type of email come under and what is the name of the specific security attack?​

Answers

Answer: Phishing attack

Explanation:

Phishing attacks are extremely common and involve sending mass amounts of fraudulent emails to unsuspecting users, disguised as coming from a reliable source (in this case, his/her boss seems to be sending the message, which seems like a pretty reliable source.)

Also, if his phone and laptop was stolen, he proably would not be able to send an email, and it seems strange to ask one of his workers for money, instead of contatcing the police, the bank, and/or one of his family members.

The Synonyms submenu offers a list of synonyms for a word. Is it always a good idea to use whatever synonyms are presented on the Synonyms submenu for a given word? Why or why not?

Answers

Answer:

No

Explanation:

Synonyms are sometimes NEARLY the same. Not exactly the same. Therefore the meanings can change a bit. For example a synonym for "bad" is "careless."

"I think corn is bad."

and

"I think corn is careless." - this sentence wouldn't make sense.

That's why, no, you shouldn't ALWAYS use the synonym.

explains why sorting and filtering is so important when using Excel; explains why employers want potential employees to know how to create PivotTables and charts

Answers

The reason why sorting and filtering is so important in Excel is that it help you to analyze your data very well.

Why is sorting so vital when using Excel?

Excel is known to be a software that helps one to sort the full range of data that had been selected.

It is also known to use filter as this helps a person to better work on their data.

The use of  a pivot table is vital to an employer as it will help him or her easily work on the data and come to a fast and accurate decision.

Learn more about sorting from

https://brainly.com/question/15049854

Please help me I don’t know what I’m doing wrong.

Answers

Answer:

Explanation:

I noticed the \n, \n will cause the new line break, delete it.

try code below:

System.out.println(" " + " " + "NO PARKING");

System.out.println("2:00 - 6:00 a.m.");

If you enqueue five elements into an empty queue and then perform the isEmpty operation five times, the queue will be empty again.
a) true
b) false

Answers

False

If you enqueue five elements into an empty queue and then perform the isEmpty operation five times, the queue will be empty again.

For the Pie chart data labels, remove the Value labels
and edit the label options to display Percentage format at
the Center position, and then close the task pane.

Answers

Excel is a spreadsheet that features tools like graphs, tables, charts, calculations, etc. The label options are edited by the percentage tool in the excel sheet.

What are data labels?

Data labels in an excel sheet are information of the data that provides information of the pie chart in the form of numbers and percentages as given in the instructed data.

To display the percentage format in the data label click the graph and select the green plus in the top right corner. Select more options and check the percentage box and uncheck the value labels. Now, check the "inside end" box to exit the settings.

Therefore, the value labels can be replaced by the percentage values in a pie chart.

Learn more about pie chart here:

https://brainly.com/question/15313963

#SPJ1

Question:
Draw flowchart diagram for the following
programs using loop.
A) A program that display number 1 to 202

Answers

a = "203"

b = True

while 203 > a

make the rest of the code

 

.

Create a lottery game application. Generate three random numbers, each between 0 and 9.
• Allow the user to guess three numbers.
• Compare each of the user’s guesses to the three random numbers and display a message that includes the user’s guess, the randomly determined three-digit number, and the amount of money the user has won as follows:
• Make certain that your application accommodates repeating digits. For example, if a user guesses 1, 2, and 3, and the randomly generated digits are 1, 1, and 1, do not give the user credit for three correct guesses—just one.

Answers

I made this file in python:

Since you cant send .py files through brainly, you'll have to convert it first. Or copypaste it into your IDE or whatever.

did anyone know what's the problem here? ​

Answers

Answer:

porbaly an error or bug

Explanation:

Give one advantage of using different types of files as data sources mail merge

Answers

Answer:

The Mail Merge feature makes it easy to send the same letter to a large number of people.

Which of this is not a compatible communicationwith other devices

Answers

Answer:

ice box

Explanation:

1. Imagine you were using Blender to create a cone-shaped mesh and changed the number of
vertices from the default of 32 to just 3. What shape would you end up with?

Answers

Answer:

A triangle

Explanation:

Three vertices make a triangle.

Write a function that receives a StaticArray where the elements are already in sorted order, and returns a new StaticArray with all duplicate values removed. The original array must not be modified. You may assume that the input array will contain at least

Answers

The code that remove duplicate is as follows:

def remove_duplicate(mylist):

    mylist = list(dict.fromkeys(mylist))

    return mylist

print(remove_duplicate([1, 1, 2, 3, 3, 5, 6, 7]))

Code explanation

The code is written in python.

we defined a function named "remove_duplicate" and it accept the parameter "mylist".The variable "mylist" is used to store the new value after the duplicate vallues has been removed.Then, wed returned mylist.Finally, we call the function with the print statement . The function takes the required parameter.

learn more on python here: https://brainly.com/question/21126936

Write a Java Program that asks the user for 12 months worth of rainfall stats. These values should be entered by the user and placed in an array. Once all the values are entered the
program should print out the average rainfall per month, highest rainfall month, and lowest rainfall month. Use the following values: Jan - 1.2", Feb - 2.8", Mar - 4.9". Apr - 11.3", May
12.3", June - 10.1", Jul - 7.9". Aug - 8.1", Sep - 6.7", Oct - 5.3", Nov. - 4.2". Dec - 3.9".
The average is: 6.5583, month with largest - May, month with lowest - Jan.
-
5

Answers

The program is an illustration of conditional statements and loops.

Conditional statements are used to make decisonsLoops are used for iterative purposes

The main program.

The program written in Java, where comments are used to explain each action is as follows:

import java.util.*;

public class Main {

public static void main(String[] args) {

   Scanner input = new Scanner(System.in);

   //This declares the array

   double rainfall[] = new double[12];

   //This initializes the total amount of rainfall

   double total = 0;

   //This gets input for the array

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

       rainfall[i] = input.nextDouble();

       total+=rainfall[i];

   }

   //This initializes the smallest and the largest amount of rainfall

   double largest = 0; double smallest = 0;

   int smallestMonth = 0; int largestMonth = 0;

   for(int i=1; i< 12; i++){

       //This determines the largest amount of rainfall

       if(rainfall[i] > largest){ largestMonth = i; largest = rainfall[i]; }

       //This determines the smallest amount of rainfall

       else if (rainfall[i] < smallest){ smallestMonth = i; smallest = rainfall[i]; }

   }

   //This initializes the months

   String months[] = new String[]{"January","February","March","April","May","June","August","September","October","November","December"};

//This prints the required output

System.out.println("The average is: " + total/12+", month with largest - "+months[largestMonth]+", month with lowest - "+months[smallestMonth]);

}

}

Read more about conditional statements and loops at:

https://brainly.com/question/24833629

Write a program in which the user enters a list of numbers in one line through a space (numbers from 0 to 10). The program must rearrange the last three elements of the list and move the remaining elements to the right.
Python program

Answers

I could have misunderstood your question, but here's a program which does as i interpreted your question.

from random import shuffle

numbers = input("Enter your numbers separated by spaces (ex:'1 6 3 1 4')\n> ")

numbers = [int(n) for n in numbers.split(" ")]

final_numbers = numbers[-3:]

shuffle(final_numbers)

final_numbers += numbers[:-3]

print(final_numbers)

(I have not added any kind of negative feedback if the user decides to missuse the program)

Help!!

def main():

# Initialize variables
numGuesses = 0
userGuess = -1
secretNum = 5

name = input("Hello! What is your name?")

# Fill in the missing LOOP
# This loop will need run until the player has guessed the secret number.

userGuess = int(input("Guess a number between 1 and 20: "))

numGuesses = numGuesses + 1

if (userGuess < secretNum):
print("You guessed " + str(userGuess) + ". Too low.")

if (userGuess > secretNum):
print("You guessed " + str(userGuess) + ". Too high.")

# Fill in missing PRINT statement here.
# Print a single message telling the player:
# That he/she guessed the secret number
# What the secret number was
# How many guesses it took

main()

Answers

There you go:

Please ask if there is anything you dont understand.

Please tell me if any of my code is incorrect.

In which type of interaction does a robot use motion sensors to avoid running into walls? O A. Movement O B. Communication O c. Touch D. Sight​

Answers

The type of interaction that robots use via the infrared sensor (IR sensor) to avoid running into a wall is: D. sight.

What is the Infrared Sensor (IR Sensor)?

The infrared sensor (IR sensor) is a type of motion sensor that has a sight interactive radiation-sensitive optoelectronic component, which are used in robots to detect obstacles and avoid them.

The infrared sensor, enables a robot to avoid running into the wall through sight interaction.

Learn more about the infrared sensor (IR sensor) on:

https://brainly.com/question/25155865

Answer:

D. Sight

Explanation:

Well, sensors detect what's in front of it. And sensors are similar to cameras because they also see things as they are used in security cameras to see faces and motion. Sensors also can detect motion as it is moving. If you have witnessed Roombas automatic vacuums use sensors and cameras to memorize where they can go and not go and would also update their data if a door or something is in the way of the normal root.

Note Users / OP (Original Poster):

I hope this helped at all. If it did please give this answer and explanation a 5-star rating and a thanks button. Or if you would like to provide brainiest.

Note Devs / Moderators:

Please don't delete this like I've said in my other answers I'm trying to help anyone and everyone I can during school hours.

Explain the components that are on the main circuit board the motherboard-of a microcomputer.​

Answers

Answer:

Motherboard The main circuit board of a microcomputer. The motherboard contains the connectors for attaching additional boards. Typically, the motherboard contains the CPU, BIOS, memory, mass storage interfaces, serial and parallel ports, expansion slots, and all the controllers required to control standard peripheral devices, such as the display screen, keyboard, and disk drive. Collectively, all these chips that reside on the motherboard are known as the motherboard's chipset.  On most PCs, it is possible to add memory chips directly to the motherboard. You may also be able to upgrade to a faster PC by replacing the CPU chip. To add additional core features, you may need to replace the motherboard entirely.  The function of the motherboard lies within the name of the part itself: it's a board (specifically, a circuit board) and it's the mother of everything in your computer - all connections have to go through it. Video hardware is plugged into it. The DVD drive is plugged into it. The scanner plugged into your USB hub? That hub is plugged into the motherboard.

Explanation:

Why Is Microsoft software so dominant in the business world?

Answers

Because it's dominant. In other words, once a platform becomes dominant, it tends to stay that way. It's inertia. With millions of applications available for Windows, it makes sense to use Windows. And with everyone using Windows, it makes sense to write new applications for Windows. It's self-perpetuating. The greater the number of Windows computers in the world, the greater the inertia. People think that Microsoft creates this dominance, but that's not true. It just is. Even Microsoft can't influence it much. That's why there are so many people still on Windows XP and Windows 7. And even when this happens, businesses usually tend to get lazy with their products, not keeping them the best working

what is the hierarchical system used by windows?

Answers

Answer: Files are placed in a hierarchical structure. The file system specifies naming conventions for files and the format for specifying the path to a file in the tree structure. Each file system consists of one or more drivers and dynamic-link libraries that define the data formats and features of the file system.

Explanation:

¯\_(ツ)_/¯

Use the _____ to exit Access.

Answers

The true statement is that use the Close button to exit Access.

How to exit the access application?

The Microsoft Access application is a Microsoft application that is used to create, query and edit a database.

To exit the Microsoft Access application,we simply perform the following simple task

There is a close icon or button at the top right of a Microsoft Access application Click this button, and the Microsoft Access application will be closed

Read more about software programs at:

https://brainly.com/question/1538272

The data _____ is where all the user or data traffic flows (for example, the traffic between users on a network).

Answers

Answer:

The data traffic is where all the user or data traffic flows (for example, the traffic between users on a network).

Explanation:

The data traffic is sometimes referred to as a Network traffic. Which in simple terms, is the amount of data moving across a computer network at any given time.

Question:
Draw flowchart diagram for the following
programs using loop.
A) A program that display number 1 to 202

Answers

CLS
C=1
FOR I = 1 TO 202
PRINT C
C=C+1
NEXT I
END

The way we deal with people snooping on internet connections is..
Select one:

a.
We don't send sensitive information over the internet.


b.
We avoid routers and use direct connections.


c.
We depend on the routers to vary routes a lot to confuse listeners.


d.
We secure our communication by encrypting it.

Answers

I’m torn between B and D!
D if we want to prevent snooping
B if we want to have a direct connection — as in one computer to one computer

Maybe go with B?

tools used in organising data in Excel​

Answers

Answer:

Workbook

Also called a spreadsheet, the workbook is a unique file created by Excel XP.

Title bar

The Excel XP Title Bar

The title bar displays both the name of the application and the name of the spreadsheet.

Menu bar

The Excel XP Menu Bar

The menu bar displays all of the menus available for use in Excel XP. The contents of any menu can be displayed by left-clicking the menu name.

Toolbar

Some commands in the menus have pictures or icons associated with them. These pictures may also appear as shortcuts in the toolbar.

The Excel XP Toolbar

Column headings

The Excel XP Column Headings

Each Excel spreadsheet contains 256 columns. Each column is named by a letter or combination of letters.

Row headings

The Excel XP Row Headings

Each spreadsheet contains 65,536 rows. Each row is named by a number.

Name box

The Excel XP Name Box

This shows the address of the current selection or active cell.

Formula bar

The Excel XP Formula Bar

The formula bar isplays information entered—or being entered as you type—in the current or active cell. The contents of a cell can also be edited in the formula bar.

Cell

The Excel XP Cell

A cell is an intersection of a column and row. Each cell has a unique cell address. In the picture above, the cell address of the selected cell is B3. The heavy border around the selected cell is called the cell pointer.

Navigation buttons and sheet tabs

The Excel XP Navigation Buttons

Navigation buttons allow you to move to another worksheet in an Excel workbook. They are used to display the first, previous, next, and last worksheets in the workbook.

Sheet tabs separate a workbook into specific worksheets. A workbook defaults to three worksheets. A workbook must contain at least one worksheet.

Explanation:)

Highlight the rows and/or columns you want sorted.

Navigate to "Data" along the top and select "Sort."

If sorting by column, select the column you want to order your sheet by.

If sorting by row, click "Options" and select "Sort left to right."

Choose what you'd like sorted.

Choose how you'd like to order your sheet.

Click "OK."

what is the extension of ms excel 2007​

Answers

Answer:

XLSX

Explanation:

The XLSX file extension is associated with files saved with Microsoft Excel (2007/2010), one of the most popular and powerful tools you can use to create and format spreadsheets, graphs and much more. The . xlsx files are used in Microsoft Excel (2007/2010) for Workbooks, spreadsheet, and document files.

Excel file formats:

Format                                                                Extension

Excel Workbook -                                            .xlsx

Excel Macro-Enabled Workbook (code)-         .xlsm

Excel Binary Workbook-                                     .xlsb

Template-                                                         .xltx

While multiple objects of the same class can exist, in a given program there can be only one version of each class. a) True b) False

Answers

Answer:

A) True

Explanation:

Select the correct answer.

If you want to develop an Android app, you need to become a registered developer with which platform?

Answers

Answer:

C. Android

Explanation:

C. Android is the answer for your question

Answer:

c it's the only thing, you have to know how to work androids

The software used to provide visual support such as slide show during lectures

Answers

Answer:

microsoft powerpoint

Explanation:

history of computer from difference engine

Answers

Answer:

Charles Babbage (1791-1871), computer pioneer, designed two classes of engine, Difference Engines, and Analytical Engines. Difference engines are so called because of the mathematical principle on which they are based, namely, the method of finite differences.

Explanation:

Difference Engine, an early calculating machine, verging on being the first computer, designed and partially built during the 1820s and '30s by Charles Babbage.

Other Questions
How would I word this sentence? solve for x [tex] \binom{1}{2} ^{3x + 1} = 32[/tex]how do i solve for x what plus 23 equals 180 (LCM) of 28, 42 and 63 Please I need help and an explanation :0 100 PTS HELP PLS To the nearest 50 square feet, what is the area of the actual store?Question 1 options:2,350 square feet2,450 square feet2,500 square feet2,400 square feet why is it important for scientist to be objective when using the design process like the scientific method when doing their investigations why is water a clear liquid? At Central High School, there are 48 football players and 20 cheerleaders. What is the ratio of cheerleaders to football players? helppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp Isometric exercise strengthens muscles without __________. A. contracting muscle fibers B. changing muscle length C. burning calories D. conscious effort Please select the best answer from the choices provided. A B C D Please help worth 15 points HELP10 pointsAnd brainleist 102Given the graph above, choose the coordinate point that is NOT asolution.(6.0)(10,6)(-8,6)(0,0) Given the figure below, find the values of x and z.120(9x + 30). A solution contains 5.2 moles of NaCl in 0.5 L of water. What is the molarity of this solution? (Show your work) What is in a snooks diet. And also the habitat. Question 8The Woodlands Middle School poll results show that about 79.3% ofpeople who prefer pizza are students and about 81% of the peoplewho prefer burgers are students.Which of the following statements is true?PizzaThere is not enough evidence tosupport a relationship between lunchpreference and role at the school.StudentsTeachers79.3%20.7%100%Burgers81.0%19.0%100%TotalThere is evidence to support arelationship between lunch preferenceand role at the school. Please help me Will give brainliest The Muses were divine creatures responsible for entertaining the gods. A. amusement B. muscular C. mustache