SIZE = 1 All the numbers... [0] All the numbers... [10] Min: 10 Max: 10 Total: 10 Average: 10 SIZE = 2 All the numbers... [0 0] All the numbers... [10 20] Min: 10 Max: 20 Total: 30 Average: 15 SIZE = 100 All the numbers... All the numbers... [ 10 20 30 40 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990 1000] Min: Max: Total: 50500 Average: 505 10 1000
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
Hello there:
I must complete the following lesson as exactly as the instructions are given in the Python code. After I have completed the lesson, I must test it by changing SIZE to any number between 1 and 'whatever' and your whole
Please can you help me with this lesson? Thanks in advance!
The instructions are in the code:
import numpy as np
# SIZE is a global constant, use this throughout your program.
# you should be able to change this to any int and your
# whole program will still work correctly. TEST THIS!
SIZE = 10
# creates a numpy array of size SIZE filled with 0s.
numbers = np.array([0] * SIZE, dtype=int)
# show the array
print("All the numbers...")
print(numbers)
print()
# now fill it with 10,20,30, etc ***using a loop***
#########################
# code here
#########################
# show the array again
print("All the numbers...")
print(numbers)
print()
# now make an integer array of size 4 to hold stats, call it stats
# calculate four basic stats and put them in the size 4 array in this order:
# min, max, total, average
# min and max will just be the first and last numbers from the numbers array
# average may calculate as a float, make it an int to store it in the stats array
# you should use a simple print(stats) to see your array as you code, then erase
# that print statement and uncomment the print statements below to see your stats
#########################
# code here
#########################
# When you have your stats array working, uncomment this code to display the stats.
#
#print("Min: ", stats[0])
#print("Max: ", stats[1])
#print("Total: ", stats[2])
#print("Average: ", stats[3])
print()
The output must be as the following examples:
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images