GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Question 2: Assume that there exists a file named “aFile.txt…

Question 2: Assume that there exists a file named “aFile.txt” in the local disk. Write a program that prompts the user for a positive integer n as an input. The program should write the first n characters of each line in “aFile.txt” to a new file, named “newFile.txt”. The program should write the entire line, if n is greater than that line’s length. Below is a sample input and output for n = 10. Input – aFile.txt: First line of the file Second line of the file Third Output – newFile.txt: First line Second lin Third

Read Details

A Jupyter template for the exam has been provided to you abo…

A Jupyter template for the exam has been provided to you above. Complete the template and use this text box area to submit the Secret Gist ID of your code (saved in your GitHub account). Use the next question (file upload question) to attach the .ipynb file.

Read Details

Consider the DataFrame given in the previous question (named…

Consider the DataFrame given in the previous question (named df that already resides in memory). What is the output after running the following code? Assume that pandas package has already been imported. df.set_index(‘Team’,inplace=True) val = df.loc[(df[‘Conference’]==’East’) & (df[‘Wins’]>27),:].index print(list(val)) df.reset_index(inplace=True)

Read Details

Consider the following DataFrame named df that resides in me…

Consider the following DataFrame named df that resides in memory: Conference Team Wins 0 East Atlanta Hawks 24 2 East Brooklyn Nets 28 4 East Chicago Bulls 27 What is the output after running the following statement? Assume that pandas package has already been imported. print(df.loc[2,’Wins’],df.iloc[2,2])

Read Details

Which of the following is not one of the allowed inputs for…

Which of the following is not one of the allowed inputs for the .loc operator in Pandas?

Read Details

Assume that ‘example.txt’ does not exist in the local disk….

Assume that ‘example.txt’ does not exist in the local disk. Consider the following code: a_list = [1,2,3] file_obj = open(‘example.txt’, ‘w’) for num in a_list: print(num, end = ‘ ‘) print(num, file=file_obj, end=’ ‘)file_obj.close() What is the screen output after running this code?

Read Details

What is the output of the following code? def myFunc(x,y): i…

What is the output of the following code? def myFunc(x,y): if x == 0: return x return x + y myFunc(0,5)

Read Details

Consider the following two Numpy arrays: 3×3 shape: arr1 = n…

Consider the following two Numpy arrays: 3×3 shape: arr1 = np.array([[7,31,1], [4,12,2], [19,8,16]] ) 1×3 shape: arr2 = np.array([[10,15,20]]) Which of the following Numpy functions can be used to stack arr2 to the bottom of arr1 so that the resulting array has the shape of 4×3?

Read Details

What is the output of the following code? def letterPrint(le…

What is the output of the following code? def letterPrint(letter, n): cnt = 0 s = ” while cnt < n: s = s+letter return s cnt += 1 letterPrint('a',5)

Read Details

Information for questions 14-18 The world is made of two cou…

Information for questions 14-18 The world is made of two countries, La La Land, and Liverpond. Labor is the only factor of production. La La Land has 100 hours of labor available to be employed, while Liverpond has 200 hours of labor available to be employed. There are two goods, songs and movies. The following table shows the output of each good per hour of labor, in the two countries.   La La Land Liverpond Songs 10 4 Movies 20 5 Suppose we plotted the two countries PPCs, placing quantity of songs on the horizontal axis, and quantity of movies on the vertical axis. Which country’s PPC would have the smallest slope, in absolute value?

Read Details

Posts pagination

Newer posts 1 … 29,693 29,694 29,695 29,696 29,697 … 92,331 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top