Question

use an infinite loop to enter your homework grades of float data type and append them...

use an infinite loop to enter your homework grades of float data type and append them into a list. break the loop when the user enters a grade smaller than 0. create a NUMPY array out of the grades list; create a panda series out of the numpy array and rename the indices to begin from 1 instead of 0(create the new list using list comprehension that begins from 1).

in python

Homework Answers

Answer #1
import numpy as np
import pandas as pd
arr=[]
while True:
    grade=float(input("Enter: "))
    if grade<0:
        break
    else:
        arr.append(grade)

arr=np.array(arr)
ser=pd.Series(arr)
idx=[i for i in range(1,len(arr)+1)]
ser.index=idx
print(ser)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions