Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3.7 Question 1 (25 points) Define vector - [3.2, 6, 7.8, 1, 3, 2.5, 100). 1. Write a loop that adds the number 5

Python 3.7
image text in transcribed
Question 1 (25 points) Define vector - [3.2, 6, 7.8, 1, 3, 2.5, 100). 1. Write a loop that adds the number 5 to all values of this vector that are smaller than 4. Do not just add this by hand, I need to see whether you can write a loop. You probably want to use an it statement as well. The resulting vector should look like this 7- [8.2, 6, 7.8, 6, 8, 7.5, 100). 2. Use the original vector and write a loop that replaces all values between 2 and 5 (including 2 and 5) with 1 so that you get 7=(-1, 6, 7.8, 1, -1, -1, 100). 3. Use the original vector and extract the last 3 values using vector slicing and print them on the screen (no loop). 4. Use the original vector and extract the 2nd to 5th element (i.e., 6, 7.8, 1, 3) using slicing from the vector and print the result on the screen (no loop)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis In Microsoft Excel

Authors: Alex Holloway

1st Edition

B0CCCPKTTX, 979-8852388452

More Books

Students also viewed these Databases questions