Question

In: Computer Science

Challenge 1: Python is one of the world’s most widely-used analytics platforms. It is more popular...

Challenge 1: Python is one of the world’s most widely-used analytics platforms. It is more popular than R generally, it runs faster than R, and its analytic capabilities are rapidly improving. You'll want to use Anaconda Python because it includes many packages of use for analytics. Download Python 3.x at https://www.anaconda.com/distribution/ and install it.

Challenge 2: Spyder is an open-source, integrated development environment for data scientists to program in Python. You already installed it when you installed Anaconda's Python. On your computer, find and open Anaconda-Navigator and launch Spyder.

Note: If Spyder asks if you want to upgrade it, answer no. Otherwise you may be upgrading to a version that is not compatible with your version of Anaconda's Python.

Note: PyCharm is very popular and, by some accounts, a better IDE than Spyder. You are welcome to use PyCharm instead of Spyder.

Challenge 3: In Spyder, create a new script, add a multi-line comment at the top with the name of the workshop, your name, the date, and any other useful information. You should always have such a comment at the top. Save the script to your folder.

Copy and paste the remaining challenges in this same script. Note: When you paste into Spyder, everything may end up on one line. If you copy from here, paste into Word, copy from Word and paste into Spyder, you should get multiple lines.

NOTES:

  1. Python's variables should be in lower_case_under_score format, and they should be descriptive. In challenge 4, for example, you will want to call your variable, "hello_world."
  2. Besides keeping all the comments, below, in your script. Be sure to add your own comments for future reference. Explain what you are doing to the "future you!"
  3. Python uses the triple single quote (''') to start and end multi-line section header comments. It uses the hashtag (#) for all other multi-line, single line and end-of-line comments.

'''Challenge 4: Assign "Hello World" to a variable and print it to the console.
Use Spyder's "Run selection or current line" feature to execute your program.
Python Basics Cheat Sheet: https://www.dataquest.io/blog/python-cheat-sheet
'''

'''Challenge 5: Create a list with the names of three of your friends
and print it.
'''

'''Challenge 6: Python relies on packages for a wide range of functionality.
Three of the most important are numpy, scipy and pandas.
- numpy has numerical processing functionality;
- Tutorial: https://docs.scipy.org/doc/numpy/user/quickstart.html
- scipy has scientific processing functionality, including optimization
and statistical analysis
- Docs: https://docs.scipy.org/doc/scipy-1.2.1/reference/
- pandas (Python Data Analysis Library) has extensive functionality for
data manipulation. It includes tabular DataFrames. It is very fast
and often used instead of databases for data manipulation.
- 10-min Intro: http://pandas.pydata.org/pandas-docs/stable/getting_started/10min.htmls

These packages are already installed with Anaconda's Python.
Import numpy as np at the of your script, just below your introductory
comments.
'''

'''Challenge 7: Create these numpy arrays: (1, 3, 5), (2, 4, 6).
Add them together. Print the results.
Numpy Cheat Sheet: https://www.dataquest.io/blog/numpy-cheat-sheet
'''

'''Challenge 8: Multiply the vectors together. Print the results.'''

'''Challenge 9: Create a test to see if each element of the vector
(1, 3, 5) > 2. Print the results.
'''

'''Challenge 10: Print the second element of the vector (1, 3, 5).
Note: Python starts counting a 0.
'''

'''Challenge 11: Replace the second element of the vector with -3.
Print the results.
'''

'''Challenge 12: Print the second and third elements of the vector.'''

'''Challenge 13: Replicate the vector and print the new vector.
'''

'''Challenge 14: Create a list with numbers from 1-10.'''

Solutions

Expert Solution

SOURCE CODE:

"""
NAME OF THE WORKSHOP:
NAME:
Created on Sat Sep 28 14:30:50 2019

"""
#importing numpy package as np (challenge 6)
import numpy as np
#assign "Hello world" string to varible string (challenge 4)
string="Hello World"
print(string)

#reading three freinds name (challenge 5)
friend1=input("Enter 1st friend name:")
friend2=input("Enter 2nd friend name:")
friend3=input("Enter 3rd friend name:")
li=[friend1,friend2,friend3]
print(li)

#creating numpy arrays (challenge 7)
arr1=(1,3,5)
arr2=(2,4,6)
vector1=np.array(arr1)
vector2=np.array(arr2)

#addition of arrays
arr_add=np.add(vector1,vector2)

print("Addition of arrays:",arr_add)
#multiplication of arrays (challenge 8)
arr_mul=np.multiply(vector1,vector2)
print("Multiplication of arrays:",arr_mul)

# test to see each element of the vector >2 or not (challenge 9)
print("\nVector values greater than 2 are:")
for i in vector1:
    if(i>2):
        print(i," is greater than 2")
    else:
        print(i," is less than or equal to 2")

#print second elemnt of vector1 (challenge 10)
print("\nSecond element of vector:",vector1[1])
#since second element have index 1 (index starts from 0)

#challenge 11
vector1[1]=-3
print("\nAfter modification of second element:",vector1)

#challengee 12
print("\nSecond and Third elements are :",vector1[1:3]) #printing 2nd and 3rd elements index 1-3

#challenge 13
vector3=np.copy(vector1)
print("\nreplicated vector :",vector3)


#challenge 14
lis=[i for i in range(1,11)]
print("\nlist with numbers 1-10 :",lis)

CODE SCREENSHOT:

OUTPUT:


Related Solutions

Analytics is a term that is widely used especially in sports. How is analytics used to...
Analytics is a term that is widely used especially in sports. How is analytics used to help solve a current business problem? Give thorough explanation and provide examples. Business can be sports industry, medical industry, etc. There is no restriction on industry.
1. A widely popular brand of car tyres have consistently given more mileage to the consumers...
1. A widely popular brand of car tyres have consistently given more mileage to the consumers over time which have led to an increase in their prices. However, the inflation rate computed using CPI jumps up considerably because of this. What kind of drawback does the CPI have in this case? a. New Product Bias b. Outlet Bias c. Substitution Bias d. Quality Bias 2. Which one of the following is a major cost of inflation? a. Shoeleather Costs. b....
Speed World Cycles sells high-performance motorcycles and motocross racers. One of Speed World’s most popular models...
Speed World Cycles sells high-performance motorcycles and motocross racers. One of Speed World’s most popular models is the Kazomma 900 dirt bike. During the current year, Speed World Cycles purchased eight of these bikes at the following costs. Purchase Date Units Purchased Unit Cost Total Cost July 1 2 $ 4,950 $ 9,900 July 22 3 5,000 15,000 Aug. 3 3 5,100 15,300 8 $ 40,200 On July 28, Speed World Cycles sold four Kazomma 900 dirt bikes to the...
Speed World Cycles sells high-performance motorcycles and Motocross racers.  One of Speed World’s most popular models is...
Speed World Cycles sells high-performance motorcycles and Motocross racers.  One of Speed World’s most popular models is the Kazomma 900 dirt bike.  During the current year, Speed World purchased eight of these cycles at the following costs: Purchase Date                                             Units Purchased      Unit Cost   Total Cost July 1                                                                        2                    $4,950          $9,900 July 22 3                      5,000           15,000 August 3                                                                  3                        5,100           15,300                                                                                 ------                                  ------------ 8                                            $40,200 On July 28, Speed World sold four Kazomma 900 dirt bikes to the Vince Wilson racing team. The remaining four bikes remained in inventory at September 30, the end of Speed...
Speed World Cycles sells high-performance motorcycles and Motocross racers.  One of Speed World’s most popular models is...
Speed World Cycles sells high-performance motorcycles and Motocross racers.  One of Speed World’s most popular models is the Kazomma 900 dirt bike.  During the current year, Speed World purchased eight of these cycles at the following costs: Purchase Date                                             Units Purchased      Unit Cost   Total Cost July 1                                                                        2                    $4,950          $9,900 July 22 3                      5,000           15,000 August 3                                                                  3                        5,100           15,300                                                                                 ------                                  ------------ 8                                            $40,200 On July 28, Speed World sold four Kazomma 900 dirt bikes to the Vince Wilson racing team. The remaining four bikes remained in inventory at September 30, the end of Speed...
Man-in-the-middle is one of the most popular types of attack. It can be used to sniff...
Man-in-the-middle is one of the most popular types of attack. It can be used to sniff victims credentials to penetrate their system. Research the following attacks to find methods to prevent this from happening: MAC spoofing DNS poisoning DNS spoofing ICMP redirect
write a review article within 4-page topic is " Is sugar the world’s most popular drug?"
write a review article within 4-page topic is " Is sugar the world’s most popular drug?"
Although tea is the world’s most widely consumed beverage after water, little is known about its nutritional value.
Although tea is the world’s most widely consumed beverage after water, little is known about its nutritional value. Folacin is the only B vitamin present in any significant amount in tea, and recent advances in assay methods have made accurate determination of folacin content feasible. Consider the accompanying data on folacin content for randomly selected specimens of the four leading brands of green tea.                   (Data is based on ”Folacin Content of Tea,” J. Amer. Dietetic Assoc., 1983 : 627-632.) Does...
Why Programmatic direct is the most popular method (most used) in economics?
Why Programmatic direct is the most popular method (most used) in economics?
"The most widely used stain in microbiology is the Gram stain. Based on differences in the...
"The most widely used stain in microbiology is the Gram stain. Based on differences in the structure of the bacterial cell wall, the Gram stain divides bacteria into two major groups: Gram-positive and Gram-negative. Gram-positive cells have a thick layer of peptidoglycan, a polymer made of amino acids and sugars, in the cell wall. Crystal violet binds to peptidoglycan, rendering the cell purple. Gram-negative cells also have peptidoglycan and initially also stain purple. Since the peptidoglycan layer is much thinner,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT