Statistics and Linear Algebra 1

Source: Internet
Author: User

1. Add a value to each element in a list:

Degrees_zero = [F + 459.67 for F in Fahrenheit_degrees]

2. Assign the index of a list into the list:

 Survey_responses = ["None", "some", "a lot", "none", "a few", "none", "none"]

Survey_scale = ["None", "a few", "some", "a lot"]

Survey_numbers = [Survey_scale.index (response) for response in Survey_responses]

average_smoking = SUM (smoke_dic)/len (smoke_dic)

3. Categorize Scales:here We need to filter gender list into categorizes and find the Corresponse saving.  

gender = ["Male", "female", "female", "male", "male", "female"]
Savings = [1200, 5000, 3400, 2400, 2800, 4100]

Solutions one////////////////////////////////////////

Male_saving_list = []

For I in range (Len (gender)):
If gender[i] = = "Male":
Male_saving_list.append (Savings[i])
male_savings = SUM (male_savings_list)/len (male_savings_list)

Solutions two////////////////////////////////////////

Female_saving_list = [Savings[i] for I in range (Len (gender)) if gender[i] = = "female"] # Here we use square bracket to Replace append function. Savings[i] is the value of we want, if conditions has to follow the as loop like solution one.
female_savings = SUM (female_saving_list)/len (female_saving_list)


Statistics and Linear Algebra 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.