total =[]
for i in range(len(classvals)):
total.append(classvals[0])
print(total)
//////////////////////////////////////////////////////////////////////////
result:
[array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0]), array([0])]
I want ot only print the zeros (numbers) :
for example 0 and array([0])
total = [] for i in range(len(classvals)): total.append(classvals[0][0]) print(total)
total =[] for i in range(len(classvals)): total.append(classvals[0]) print(total) ////////////////////////////////////////////////////////////////////////// result: [array([0]), array([0]), array([0]), array([0]), array([0]), array([0]),...
// use "for i in range():
//use len.
//basic python
//discrete mathematics
Write a program in Python (in a .py file) that: Makes two lists of 50 numbers each, where the first list is multiples of 5, and the second list is the first 50 squares: 1, 4, 9, 16, 25, 36, ....up to 2500. then I want you to make a third list by multiplying each individual pair in the two lists, so for example: 5 times 1 is...
identify the code that sorts the numbers in descending order. def selection_sort(numbers): for i in range(len(numbers) - 1): index = i XXX temp = numbers[i] numbers[i] = numbers[index] numbers[index] temp for j in range(i + 1, len(numbers): if numbers[j] > numbers[index]: index اله for j in range(i - 1, len(numbers): if numbers[j] > numbers[index]: index j for j in range(i + 1, len(numbers)): if numbers[j] < numbers[index]: index j for j in range(i 1, len(numbers): if numbers [j] < numbers[index]:...
Recreate the one hundred element arrays of sin and cos you
created in Exercise 3.10. Print these arrays out to a file in the
form of a table. The first line of the table should contain the first
element of both arrays, the second line the second element, an so
on. Keep the file as we will use it later.
Exercise 3.10:
My solution to 3.10:
import math
from numpy import zeros
array1 = zeros(100, float)
for x in range(100):...
Please help, Array does not print properly. I need to print out the 8 class numbers entered by the user ! Java only using J option pane, you cannot use ulti or anything else only J option pane Program compiles but does not print the array correctly! import javax.swing.JOptionPane; public class programtrial { public static void main(String[] args) { int newclass = 0; int countclass = 0; final int class_Max = 8; int[] classarray =...
How to rewrite the following functions using only numpy array operations (universal functions, aggregations, boolean indexing) without using loops def mean_squared_error (v , p ): n = len ( v [0]) result = 0 for i in range ( n ): result += ( v [0][ i ] - p [0])**2 + ( v [1][ i ] - p [1])**2 result = result / n return result I tried doing it like this but nothing printed out def mean_squared_error2 (v,...
Fix the code to print the result[] array properly:
1 #include <iostream> 2 3 using namespace std; 4 5 void printArray(int array 7 for(inti= 0: i < 2;i++) cout くく array[i] << " ". 10 12 int mainO 13 14 int firstArray[2]10,20}; 16 int resultr21 17 int x; 18 19 II take input for second array 20 cin >>x 21 secondArray[0]-x; 22 secondarrayL1」-X+15 ; // Add elements 23 24 result0]- firstArray[0] + secondArray [0]; 25 result [1]- firstArray[1] + secondArray[1];...
Consider a non-empty int array ints. A contiguous subarray ints[ start .. start + len -1 ] (with starting index start and length len) is called a flat if all elements of that subarray are equal. Furthermore, such a subarray is called a plateau if it is flat and each of the elements ints[start -1] and ints[start + len] that immediately proceed/succeed the subarray are either nonexistent (i.e., out of array’s index range) or are strictly smaller than the elements...
In C++ please. Thank you!! #include <iostream> #include <cstring> // print an array backwards, where 'first' is the first index // of the array, and 'last' is the last index void writeArrayBackward(const char anArray[], int first, int last) { int i = 0; for (i = last; i >= first; i--) { std::cout << anArray[i]; } std::cout << std::endl; } // test driver int main() { const char *s = "abc123"; writeArrayBackward(s, 0, strlen(s) - 1); } // Using the...
print(" |",end=' ')
for i in range(1,10):
print(i,end=' ')
print()
for i in range(0,11):
print('-',end=' ')
print()
for i in range(1,10):
for j in range(0,11):
if j==0:
print(i,end=' ')
elif j==1:
print('|',end=' ')
elif i==9 and j==10:
print(i*(j-1),end=' ')
elif i>=4 and j>=4:
print('*',end=' ')
else:
print(i*(j-1),end=' ')
print()
This code is not working I need help
1 2 3 4 5 6 7 8 9 --- --- -------------------- -------------------- 5 10 15 X 6 12 18 X 7 8...
code that I started:
# THIS IS NEEDED TO USE ARRAYS IN PYTHON:
from array import *
# THIS IS NEEDED TO MAKE PLOTS IN PYTHON:
import matplotlib.pyplot as plt
# IMPORT A ROUTINE FROM NUMPY USEFUL FOR CREATING AN
# ARRAY FILLED WITH ZEROS
from numpy import zeros
# THIS COMMAND CREATES AN ARRAY OF ZEROS WITH DESIRED SHAPE:
V=zeros([31,21])
newV=zeros([31,21])
# SET UP THE BOUNDARY VALUES: V=8 ON TOP OF BOX
iy=20
for ix in range(0,31):
V[ix,iy]=8.0
#...