Question

*****THIS IS FOR MY PYTHON CLASS. PLEASE HELP***** { "cells": [ { "cell_type": "markdown", "metadata": {},...

*****THIS IS FOR MY PYTHON CLASS. PLEASE HELP*****

{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### CS 497 Lab 1\n",
    "\n",
    "\n",
    "### Instructions\n",
    "0. Rename this file username_lab1.  **Not literally, yourName_lab1 (technically correct, the best kind of correct!) but use your BU ID to fill in yourName.**  If I was submitting this lab, it would be called dbrennan_lab1.\n",
    "1. Read all instructions carefully, ask questions if anything is confusing.  \n",
    "2. Fill in the code/text blocks to answer each question.\n",
    "3. Do *not* change any of the existing code provided.  The code is specifically there to help you!\n",
    "4. Run the entire notebook *before* submitting it on Sakai to make sure that the code actually runs without errors.\n",
    "5. **Important**: Any question for which your code fails to run will receive 0 points.\n",
    "6. Have fun!\n",
    "7. Extra credit (if applicable) will only be granted if this lab is turned in before the end of class\n",
    "8. **Do not import any packages!**  Any packages available to you are designed to be used from their import statement down.  \n",
    "\n",
    "Example:  Problem 1 doesn't have any import statements.  Problem 2 imports one package called \"A\".  Problem 3 imports one package called \"B\".  You may not use \"A\" or \"B\" for problem 1, you may not use \"B\" for problem 2 and you may use both for problem 3.  If you were to restart and rerun all cells in your notebook you would not be able to use a package prior to importing it so it logically makes sense as well!\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Question 1 30 points\n",
    "\n",
    "Please sum up the numbers from 1 to N where, you choose to set N below.  The formula for the summation is provided, check your work!\n",
    "\n",
    "**This would look like $\\sum_{i=1}^ni=\\frac{(n+1)(n)}{2}$ if we were in a math class.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "##Your code below, you may change n to any value\n",
    "n = 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Question 2 30 points\n",
    "\n",
    "It's quite cold outside.  Don't go outside.  If you've always wondered how wind chill is calculated, today is your lucky day!\n",
    "\n",
    "The formula for calculating wind chill in T degrees Celsius and v km/hour is given below:\n",
    "\n",
    "$WC=13.12+.6215t-11.37[v^{\\frac{16}{100}}]+.3965t[v^{\\frac{16}{100}}]$\n",
    "\n",
    "Implement the above formula carefully, the wind chill at v=21, and T=-27 yields a wind chill of -39.6 (remember these are metric measurements!) \n",
    "\n",
    "0 deg C and 30 km/h yields a WC of -6.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "##Your code below, but change the values of T/v to test both pairs \n",
    "t = -27\n",
    "v = 21\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Question 3 40 points + 5 points EC\n",
    "\n",
    "You will be building your own quadratic equation solver!  Since we aren't importing the math library we will rely on the ** exponent we saw in class on Monday.  \n",
    "\n",
    "The quadratic equation $ax^2+bx+c=0$ can be solved by root 1 is $\\frac{-b-\\sqrt{b^2-4ac}}{2a}$ and root 2 is $\\frac{-b+\\sqrt{b^2-4ac}}{2a}$\n",
    "\n",
    "Now of course when the inside of the square root is less than zero we work with imaginary numbers.  For extra credit, you will find a way to print out those imaginary roots.  I'll leave how you handle that up to you.\n",
    "\n",
    "For normal credit, merely print out the two roots (with the provided print statement).\n",
    "\n",
    "a=2,b=5,c=-3 should yield roots of -3 and .5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Root 1 is: 0\n",
      "Root 2 is: 0\n"
     ]
    }
   ],
   "source": [
    "root1=0\n",
    "root2=0\n",
    "\n",
    "a=2\n",
    "b=5\n",
    "c=-3\n",
    "##Write your code below, modify root1 and root2 accordingly\n",
    "\n",
    "\n",
    "\n",
    "print(\"Root 1 is:\",root1)\n",
    "print(\"Root 2 is:\",root2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

homework.ipynb

{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"#### CS 497 Lab 1\n",
"\n",
"\n",
"### Instructions\n",
"0. Rename this file username_lab1. **Not literally, yourName_lab1 (technically correct, the best kind of correct!) but use your BU ID to fill in yourName.** If I was submitting this lab, it would be called dbrennan_lab1.\n",
"1. Read all instructions carefully, ask questions if anything is confusing. \n",
"2. Fill in the code/text blocks to answer each question.\n",
"3. Do *not* change any of the existing code provided. The code is specifically there to help you!\n",
"4. Run the entire notebook *before* submitting it on Sakai to make sure that the code actually runs without errors.\n",
"5. **Important**: Any question for which your code fails to run will receive 0 points.\n",
"6. Have fun!\n",
"7. Extra credit (if applicable) will only be granted if this lab is turned in before the end of class\n",
"8. **Do not import any packages!** Any packages available to you are designed to be used from their import statement down. \n",
"\n",
"Example: Problem 1 doesn't have any import statements. Problem 2 imports one package called \"A\". Problem 3 imports one package called \"B\". You may not use \"A\" or \"B\" for problem 1, you may not use \"B\" for problem 2 and you may use both for problem 3. If you were to restart and rerun all cells in your notebook you would not be able to use a package prior to importing it so it logically makes sense as well!\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# Question 1 30 points\n",
"\n",
"Please sum up the numbers from 1 to N where, you choose to set N below. The formula for the summation is provided, check your work!\n",
"\n",
"**This would look like $\\sum_{i=1}^ni=\\frac{(n+1)(n)}{2}$ if we were in a math class.**"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"45.0\n"
]
}
],
"source": [
"##Your code below, you may change n to any value\n",
"n = 10\n",
"for i in range(n):\n",
" result = (i+1)*(i)/2\n",
"print(result)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# Question 2 30 points\n",
"\n",
"It's quite cold outside. Don't go outside. If you've always wondered how wind chill is calculated, today is your lucky day!\n",
"\n",
"The formula for calculating wind chill in T degrees Celsius and v km/hour is given below:\n",
"\n",
"$WC=13.12+.6215t-11.37[v^{\\frac{16}{100}}]+.3965t[v^{\\frac{16}{100}}]$\n",
"\n",
"Implement the above formula carefully, the wind chill at v=21, and T=-27 yields a wind chill of -39.6 (remember these are metric measurements!) \n",
"\n",
"0 deg C and 30 km/h yields a WC of -6.5"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-39.59119651700358\n",
"-6.472951590454416\n"
]
}
],
"source": [
"##Your code below, but change the values of T/v to test both pairs \n",
"t = -27\n",
"v = 21\n",
"\n",
"wc = 13.12 + 0.6215*(t) - 11.37 * (v**0.16) + 0.3965*(t)*(v**0.16)\n",
"\n",
"print(wc)\n",
"\n",
"t = 0\n",
"v = 30\n",
"\n",
"wc = 13.12 + 0.6215*(t) - 11.37 * (v**0.16) + 0.3965*(t)*(v**0.16)\n",
"\n",
"print(wc)\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# Question 3 40 points + 5 points EC\n",
"\n",
"You will be building your own quadratic equation solver! Since we aren't importing the math library we will rely on the ** exponent we saw in class on Monday. \n",
"\n",
"The quadratic equation $ax^2+bx+c=0$ can be solved by root 1 is $\\frac{-b-\\sqrt{b^2-4ac}}{2a}$ and root 2 is $\\frac{-b+\\sqrt{b^2-4ac}}{2a}$\n",
"\n",
"Now of course when the inside of the square root is less than zero we work with imaginary numbers. For extra credit, you will find a way to print out those imaginary roots. I'll leave how you handle that up to you.\n",
"\n",
"For normal credit, merely print out the two roots (with the provided print statement).\n",
"\n",
"a=2,b=5,c=-3 should yield roots of -3 and .5"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Root 1 is: -3.0\n",
"Root 2 is: 0.5\n"
]
}
],
"source": [
"root1=0\n",
"root2=0\n",
"\n",
"a=2\n",
"b=5\n",
"c=-3\n",
"##Write your code below, modify root1 and root2 accordingly\n",
"\n",
"root1 = (-b - (b**2 - 4*a*c)**0.5)/(2*a)\n",
"root2 = (-b + (b**2 - 4*a*c)**0.5)/(2*a)\n",
"print(\"Root 1 is:\",root1)\n",
"print(\"Root 2 is:\",root2)"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"collapsed": false
},
"outputs": [
],
"source": [
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (Ubuntu Linux)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

Simple way to get your file is here:

https://cocalc.com/share/6521eafd-b409-414d-8758-57c03a19c7e3/2019-02-01-230947/homework.ipynb?viewer=share

Just go to this link you will find your homework there.

Note: If you have any doubt then please do comment below. I will be glad to help you out thanks. Just replace this json provided with your json file and name it homework.ipynb and open it in jupyter notebook . It should work like a charm.

Add a comment
Know the answer?
Add Answer to:
*****THIS IS FOR MY PYTHON CLASS. PLEASE HELP***** { "cells": [ { "cell_type": "markdown", "metadata": {},...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Rule book: 1.)Must be Python - 2.) no imported module (ie cmath) - no can do...

    Rule book: 1.)Must be Python - 2.) no imported module (ie cmath) - no can do on the imports... pure code.. 3.) numbers are float - not integer. Here's the prompt: (Algebra: solve quadratic equations) The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula: r1 = (-b + sqrt(b^2 - 4ac)) / (2a) and r2 = (-b - sqrt(b^2 - 4ac)) / (2a) b^2 - 4ac is called...

  • Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a,...

    Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a, b and c. Which will represent the coefficients in the quadratic equation ax2 + bx + c = 0. Print out the solutions (if any) of the quadratic equation. If no root exists (this happens if a == 0, or b2 <4ac) print the message No real root. Sample input/ user entries shown in red Corresponding output Enter a, b and c which represent...

  • Write the script code in Python 3.6 for this problem Write a program that asks a...

    Write the script code in Python 3.6 for this problem Write a program that asks a user for the 3 coefficients and outputs the roots of that equation. Be aware of the following: Be sure that your request for input and your output both have descriptive text. Be sure to handle the cases where some or even all of the coefficients are 0. If the roots have an imaginary component, use i when representing the imaginary term in the output....

  • I need help writing the test case in C++ code can you help? This is apart...

    I need help writing the test case in C++ code can you help? This is apart of my professors pseudo code for the project. // TEST CASE 1 // // DESCRIPTION // Coefficients a and c are > 0 and b < 0 so the equation should be output as: // // p(x) = 122.50000x^2 - 6.70000x + 3.00000 = 0 // // where we note that the operator printed before b is subtraction and we actually output -b rather...

  • Pseudocode and PYTHON source code, thanks! Program 1: Design (pseudocode) and implement (source code) a class...

    Pseudocode and PYTHON source code, thanks! Program 1: Design (pseudocode) and implement (source code) a class (name it QuadraticEquation) that represents a quadratic equation of the form of ax2+ bx + x = 0. The class defines the following variables and methods: Private data field a, b, and c that represent three coefficients. A constructor for the arguments for a, b, and c. Three get methods for a, b, and c. Method getDiscriminant()returns the discriminant value, which is disc =...

  • A quadratic equation is generally represented as, ax^2 + bx + c The root(s) of the...

    A quadratic equation is generally represented as, ax^2 + bx + c The root(s) of the above quadratic equation is computed using the following formula, root1 = (-b + sqrt(D))/ 2a root2 = (-b - sqrt(D))/2a Where D is the discriminant of the quadratic equation and is computed as, D = b^2 - 4ac Given the value of D, the roots of a quadratic equation can be categorized as follows, D > 0 : Two distinct real roots D =...

  • Using matlab and if/else statement please! Write a function that determines the real roots of a...

    Using matlab and if/else statement please! Write a function that determines the real roots of a quadratic equation ax2 + bx + c = 0. To calculate the roots of the equation, the function calculates the discriminant D, given by: D = b2-4ac If D> 0, the code should display "The equation has two roots" and print the values on a new line. If D 0, the code should display "The equation has one root.", and print the value on...

  • please answer this question with python. Write a program to solve the quadratic equation ax^2 +...

    please answer this question with python. Write a program to solve the quadratic equation ax^2 + bx + c = 0 using the standard quadratic formula x = -b plusminus Squareroot b^2 - 4ac/2a or the alternative formula x = 2c/-b Squareroot b^2 - 4ac. Your program should accept values for the coefficients a, b, and c as input and produce the two roots of the equation as output. Your program should detect when the roots are imaginary, but need...

  • Python 3.8.0 homework help We know a thermometer tells us the ambient temperature. However, we also...

    Python 3.8.0 homework help We know a thermometer tells us the ambient temperature. However, we also know that depending on other conditions, like humidity or wind velocity, can affect how warm or cold the air temperature feels. The wind chill temperature, Twc, is the temperature you feel on your exposed skin due to the wind velocity, v. The following equation can be used: Twc = 35.74 +0.6215TA-35.75v0.16 + 0.4275T (v0.16), TA= Temperature in Fahrenheit V = velocity in miles per...

  • write a C programming code for the following prompt. please use stucture concept and test if...

    write a C programming code for the following prompt. please use stucture concept and test if the code works perfectly. Project Description: In this project, you will write a program to calculate the roots of a quadratic equation. Structure concepts will be used in this project. Your program will prompt the user to enter the coefficients of a quadra coefficientsType. Then it will compute the roots of the quadratic equation and store the result in a structure variable of type...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT