Inserting Python inputs into an array

Asked 2 years ago, Updated 2 years ago, 14 views

print("***Liquid Limit Test***")
print("[Welcome to CAULab]")
samples = eval(input("Enter the number of test samples...:"))
for i in range(samples):
    print('data', i + 1, '...', (input(":")), float(input(":")))

# # Assign lab test data (blowCount, waterContent)
blowCount = np.array([55, 30, 17, 10])
waterContent = np.array([31.28, 36.30, 40.49, 46.03])

I want to put the values that I entered in the flowCound and water content like in the picture What should I do?

python

2022-09-21 11:10

1 Answers

import numpy as np

print("Liquid Limit Test")
print("[Welcome to CAULab]")
samples = int(input("1. Enter the number of test samples... : "))
blowCount, waterContent = [], []
print('2. Enter the test data : ')
for i in range(1, samples+1):
    blow, water = input(f'data {i} ... ').split(', ')
    blow = int(blow)
    water = float(water)
    blowCount.append(blow)
    waterContent.append(water)
blowCount = np.array(blowCount)
waterContent = np.array(waterContent)
print(blowCount)
print(waterContent)

Gauguin, there's something to be careful about.
When entering test data, you must separate the flowCount and waterContent with and (comma spacing).
Thank you.


2022-09-21 11:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.