0% found this document useful (0 votes)
23 views9 pages

Lab Bio

This document provides instructions for completing Lab #1 in EECS 1015 Introduction to Computer Science and Programming. The objectives of the lab are to become familiar with the Jupyter notebook environment and using variables to create and calculate mathematical equations in Python. Students are instructed to download lab files, install Anaconda/Jupyter Notebook, and complete 5 questions in a single Jupyter notebook. They are to submit the notebook file and an HTML or PDF file to the course website by the due date.

Uploaded by

ggvhbnjbhbjh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views9 pages

Lab Bio

This document provides instructions for completing Lab #1 in EECS 1015 Introduction to Computer Science and Programming. The objectives of the lab are to become familiar with the Jupyter notebook environment and using variables to create and calculate mathematical equations in Python. Students are instructed to download lab files, install Anaconda/Jupyter Notebook, and complete 5 questions in a single Jupyter notebook. They are to submit the notebook file and an HTML or PDF file to the course website by the due date.

Uploaded by

ggvhbnjbhbjh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

EECS 1015 Introduction to Computer Science and Programming

LAB #1 - Introduction to Python

(Due: as posted on eClass)


Objectives:

 Familiar with working in the Jupyter notebook environment


 Using variables to create and calculate mathematical equations in Python, input function

_________________________________________________________________________________

Submit your Notebook (.ipynb) and HTML or PDF in eClass.


https://eclass.yorku.ca/

You may submit files as many times as you like. The most recent submission overwrites all previous
submissions.

____________________________________________________________________________________

Please follow the steps below before you proceed to the lab exercises:

 Download lab files and review them thoroughly.

 Download and install Anaconda to access Jupyter notebook: You can refer to the week 1 (How
To Install Anaconda) for the required instructions to install Anacoda. You can also visit
https://docs.anaconda.com/anaconda/install/index.html for more information.

 Please note that you should use Jupyter notebook for this lab. As an alternative you can use
GoogleColab which has the same feature as Jupyter notebook and let you run your code in your
browser without the need of being installed locally. If you want to explore more about
GoogleColab visit https://www.geeksforgeeks.org/how-to-use-google-colab/.

 For this lab you need to have a good understanding of Python math module. For more
information you can check https://www.w3schools.com/python/module_math.asp.

Note: in Python, a comment is anything from a “#” to the end of the particular line. Comments
are completely ignored when the script is executed. To put in a comment, simply type the “#”
symbol at the beginning of a line.

Please complete all the exercises in ONE Notebook.

Please Submit two files: 1- A Notebook (.ipynb) File and 2- Either an HTML or a PDF
File.
1|Page
EECS 1015 Introduction to Computer Science and Programming

Please follow the steps below before you proceed to the lab exercises:

Creating Your First Notebook:

1. On Windows, you can run Jupyter via the shortcut Anaconda adds to your start menu, which will
open a new tab in your default web browser that should look something like the following
screenshot:

With Jupyter Notebook open in your browser, you may have noticed that the URL for the dashboard is
something like https://localhost:8888/tree. Localhost is not a website but indicates that the content is
being served from your local machine: your own computer.

2. Browse to the folder in which you would like to create your first notebook, click the “New”
drop-down button in the top-right and select “Python 3”:

2|Page
EECS 1015 Introduction to Computer Science and Programming

3. replace the title of created notebook with your name and student number (ex.
Mehdi_Abbasi_123456789)

Double click to rename

4. go to a new cell, change it to markdown,

Select Markdown

5. Type # Lab 1, ##your name and ##student number (as shown below)

6. And run the cell (shift+enter).

3|Page
EECS 1015 Introduction to Computer Science and Programming

7. go to a new cell, change it to markdown, Type # Question 1 and run the cell (shift+enter).

8. Go to the next cell, type the code for the question, run the code.

Note: start your code with import math


The math module has a set of methods and constants you will need for this lab.

4|Page
EECS 1015 Introduction to Computer Science and Programming

9. After you finish all the lab questions. Select “Download as” in the File, click on the notebook
(.ipynb) and download the file. You can also download the file as HTML or PDF. To download
as a PDF you may need to install a package. Refer to https://bit.ly/3Iduzvx for further
instructions.

5|Page
EECS 1015 Introduction to Computer Science and Programming

Lab questions:

QUESTION 1 For this task, the user will input an amount in Canadian dollars and then convert that
amount into several different currencies. The following table has the exchange rates for the different
currencies.

Currency Symbol Exchange Rate


US dollar USD 0.74
Russian ruble RUB 59.26
Singapore dollar SGD 0.99
Euro EUR 0.68
Chinese renminbi CNY 5.19

Examples of Question 1 (user input shown in red).

Amount in Canadian dollars: 100


Amount in other currencies:
USD: 74.0
RUB: 5926
SGD: 99
EUR: 68
CNY: 51.9

QUESTION 2 This task is to show the difference between integer and float math operations.

Your code should work as follows:


1. Prompt the user to input two integer numbers.

2. Perform the following operations and print out the results (see example below).

x/y division
x//y integer division (or floor division)
x%y modulus (remainder of division)
x**y exponent

3. Ask the user to input two float numbers. Perform the same math operations described above and print
out the results.

6|Page
EECS 1015 Introduction to Computer Science and Programming

Input integer x: 10
Input integer y: 2
Integer math:
x / y = 5.0
x// y = 5
x%y=0
x** y = 100
Input float x: 10.5
Input float y: 3.125
Float math:
x / y = 3.36
Don’t Worry about the
x// y = 3.0
formatting.
x % y = 1.125
x** y = 1553.1612959471813

QUESTION 3

For this task, ask the user to input a cylinder's radius (r) and
height (h) as a floating number. Then compute the surface area
and volume using the following formulas:

Surface Area =
Volume =

Python has a pre-defined value for π, but for this task, please
use the following approximation pi=355/113.

Examples of task 3 (user input shown in red).

Radius: 10
Height: 5
Cylinder surface area: 942.4778761061948
Cylinder volume: 1570.7964601769913

Radius: 2.5
Height: 8
Cylinder surface area: 164.93362831858408
Cylinder volume: 157.07964601769913

7|Page
EECS 1015 Introduction to Computer Science and Programming

QUESTION 4 When a satellite moves in a circular orbit, the centripetal acceleration is provided by the
gravitational attraction of the earth.

Re
ar
th
The period T (in seconds) of a satellite in a circular orbit with radius r is given below, where me is the
mass of the earth

2r 3 / 2
T
GmE

Determine the period in hours if the satellite wishes to orbit the earth at a height of 35,786 km. The
mass of the earth is 5.98 × 1024 kg, Rearth = 6,371 km and G is 6.673 × 10-11 N  m2/kg2.

QUESTION 5 The equations for motion in a straight line with constant acceleration are given by the
following equations, where v0 = initial velocity, a = acceleration, v= velocity, t = time, x0 = initial
position:

v  v0  at
1
y  y0  v0t  at 2
2
v 2  v02  2ax  x0 
 
x  x0    v0  v t
 2 

You throw a ball vertically upward from the roof of a tall building. The ball leaves your hand at a point
even with the roof railing with an upward speed of 15m/s; the ball is then in free fall with the gravity (g)
= 9.8m/s2.

8|Page
EECS 1015 Introduction to Computer Science and Programming

a. Determine the position of the ball 2 seconds after leaving your hand;
b. Determine the velocity of the ball 2 seconds after leaving your hand;

9|Page

You might also like