UWO

CS 1026 : Computer Science Fundamentals



Assignment 01
Python Basics

Due Date:
Friday, October 6, 2023 23:55:00 ET



If you want to store a PDF version of this assignment, press Ctrl+p on Windows or Command+p on Mac, the print window withh appear. Then, select Save As PDF from the Destination dropdown. Then click Save


1 INTRODUCTION

The purpose of this assignment is to provide the student with experience in creating their first code and creating their first Python programs. This assignment will further provide experience using the basic code control structures covered in class.

It is especially important that students adhere to the provided standards exactly. Most of the assignment will be computer graded and the computer will grade based on exacting specifications provided in this assignment. The students are expected to submit their work based on these standards (wording, spelling, spacing and output order). Grades will be based on adhering to these standards as much as to the correct output values. The ability to follow instructions and produce code to standards is essential throughout all of computer science.

Late policy

  • It is expected that students budget enough time to properly submit their assignments via OWL and allow for any unforeseen technological issues. Students are expected to regularly backup their assignments and submit well before any deadline.
  • Each student will be given four (04) “late coupons” in total for the entire semester that may be used to submit an assignment one day late per coupon.
  • Late coupons will be applied automatically when an assignment is submitted late and tracked in the OWL gradebook. No intervention by the students is required.
  • If a student has no late coupons remaining or submits an assignment more than 4 days late, a zero grade will be given for the assignment (no partial late marks will be given).
  • Late coupons must be used before special circumstances are considered.
  • After all late coupons are used, no extensions will be given for assignments except for in the event of serious medical or compassionate grounds. A student must follow the procedure for Academic Accommodation for Medical Illness as given in the Course Outline document.

NOTE:
The code required for this assignment is considerably basic. As such, there are many resources where a student can find the solutions on-line. This is discouraged not only because it is an academic offense, but it will remove the practice of learning the rudimentary tools all programmers need to complete coding projects. The main goal of this assignment is to provide the student with the foundation on which to succeed. Experiencing the difficulties and pitfalls of writing your first programming assignment will pave the way for more robust and interesting assignments down the road not only in this class, but all your future classes. The required code is purposely basic. Remember, you learn more from your failures than you do from your successes.
The challenges will be in applying what you have learned regarding control structures and conditional statements. This assignment is also aimed and providing experience in creating and submitting work to the standards required by the course. Please read this document carefully and in its entirety. Students will be graded on the format and style of the input and output.

Example Code:
The students are provided with an executable example of the completed program. Notice that all three projects in Part One (01) are contained in a single file for ease of use. This allows the student to see the exact expected input and output of the required program as well as the behaviour based on any inputs. Students are to break each part down to separate and independent Python programs. This executable is compiled for a Windows based computer.

2 Project 01 – Part A : Fibonacci Sequence


The Fibonacci sequence is a sequence of numbers in which each successive number in the sequence is obtained by adding the two previous numbers in the sequence. The sequence is named after the Italian mathematician Leonardo Fibonacci da Pisa. The sequence starts with zero and one, and proceeds forth as 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 and so on. The Fibonacci sequence is widely used in applications pertaining to mathematics, science, computers, art and nature.

The general rule to obtain the nth number in the sequence is by adding previous (n-1)th term and (n-2)th term:.

This sequence will continue up to and including the value entered by a user prompt. This prompt will be included in the student’s program for this part.
The output must look exactly as shown. Each separate line will consist of the sequence number followed by a colon, one space and then the next value in the sequence outputted as an unformatted value. This will be followed by a single space and the same value formatted with commas.

Below is a screen shot of the expected output:
Note :in ALL images the brackets are curved (01) and not angled <01>
This means the N term in the output goes from 0 to 50 (for a total of 51 values – Zero (0) is the base case ).
This makes the 21st number in the series to be outputted as:
20: 6765 6,765
NOTE: Displaying values with comma separators is purposely not covered in class or in the notes. This is to provide the students with the experience of researching Python usage beyond what is covered (a very valuable skill set that is good to learn early). It is recommended student do a simple search with the appropriate search terms. This demonstrates the difference between referencing syntax (which is allowed) versus looking up completed sections of code (which is not allowed).

3 Project 01 – Part b : Prime Choice


Create a program to find all prime numbers within a user specified range.

Upon execution of this portion of the program, the user will be asked to provide the from & to range and then the program would display all the prime numbers in sequential manner for the provided range. Using this program, the user can find out the prime numbers between any valid range. The user enters the desired range, for example, if the user wants to display all the prime numbers from 100 to 999 then they will enter numbers 100 and 999 when program prompts for input.
Hint: Look up if negative numbers, 0, and 1 are considered Prime Numbers ..
The program must check the input and ensure the first value is less than or equal to the second value. If the use enters the values incorrectly, the program will inform the user of the incorrect input and will automatically switch the values.
The prompts and output must look exactly as shown [You MUST use these words and line spacing exactly]:

4 Project 01 – Part c : The Moore the Merrier


Moore’s Law concerns the rate of increase in computer performance.

Gordon E. Moore first made his observation back in the relatively early days of mass produced computers. In crude terms, it describes how much computing power you can stuff into a given volume.

Moore's law is the observation that the number of transistors in an integrated circuit (IC) doubles about every two years.

Project One – Part C will compute and display a crude estimate of this law and the resulting computing power this represents.

One measure of computing power if the number of Floating-Point Operations Per Second (FLOPS) a computer is capable of preforming. For the purpose of this assignment, assume that each transistor results in 50 FLOPS (this is not technically accurate, but it does allow a good representation of the increase in computing power over the years).

If a computer had 100 transistors, it would be assumed (for the purpose of this program) to be capable of 5,000 FLOPS (100 * 50).

The program will prompt a user for three values.
The starting number of transistors:
The year to start the calculations from:
The number of years to calculate.

As Moore’s law states the increase is based on a two year cycle. Compute the increase in two year increments. Each two year cycle will produce twice as many transistors as the previous two year cycle.

The computing power (FLOPS) is simply the number of transistors multiplied by a factor of 50.

The output will show the year, the number of transistors and then the computing power in FLOPS (first as a Unit Definition to two (02) decimal places and then as the actual number).

NOTE:
The unit definition will reflect the actual values.
so:
40,000 FLOPS is 40 KiloFLOPS
and
40,000,000 FLOPS is 40 MegaFLOPS
The unit definition must correspond with the actual computed values as shown below. The program must handle values up to the YottaFLOPS. The Unit Definitions and the corresponding values are shown in the chart below: Notice that the resulting values mimic Moore’s Law results based on the following graph:

5 Verify reading the Academic Dishonesty document


Create a new Microsoft Word document and complete Project Two (02) in that document.
In other words, you will be submitting a separate single (one) written document for this part of the assignment.
Every student is required to know the contents of this document. Failure to read this document in its entirety will not be considered as an excuse.

Insert at the top of the Word document:
Document prepared by:
<Student Name>
<Student Number>
<Student UWO ID>
<Date Document Prepared>

Section A) Proof of Opening the Document

  1. Go to the Course Resources section in OWL for CS1026. (A copy of this document is also included in the Assignment One (01) section in OWL.)
  2. Open the document titled: A Discussion on Academic Dishonesty.
  3. Write down your student number and on the next line write the last two digits of your student number. Finally, write the word that is that corresponds to that position in the document.
    (Note: Start with the Title. So, Word One (1) is: An, Word Two (2) is: Important, Word Three (3) is: Discussion, etc.)

    Examples (note: these are the actual words at those locations):
    Student Number: 250845378
    Last Two Digits: 78
    The word that is exactly 78 words from the beginning of the document is: it

    Student Number: 250451903
    Last Two Digits: 03
    The word that is exactly 3 words from the beginning of the document: Discussion

    Student Number: 250234212
    Last Two Digits: 12
    The word that is exactly 12 words from the beginning of the document: Every

    Student Number: 250565700
    Last Two Digits: 00 (note: this is a special case, enter the word that is 100 words from the beginning)
    Word that is 100 words from the beginning of the document: allowing


Section B) Proof of Reading the Document

  1. Go to page two (2) of the document.
  2. There are six responsibilities listed.
    They are denoted by A.) and B.) and C.) and D.) and E.) and F.).
  3. You must type out the first line (the line that is completely in bold) for each of the six responsibilities.
  4. You enter Section B in the same document as Part Two (02) Section A above, right under Section A.).

This part of the document should look something like:
Responsibilities:
  • blah blah blah (but the actual words from the document)
  • blah blah blah (but the actual words from the document)
  • blah blah blah (but the actual words from the document)
  • blah blah blah (but the actual words from the document)
  • blah blah blah (but the actual words from the document)
  • blah blah blah (but the actual words from the document)


Section C) Proof of Understanding the Document


There is a phrase towards the bottom of page three (3) in the document that is not in English.
A.) What language is this phrase?
B.) Translate this phrase into English.

You enter Section C in the same document right under Part Two (02) Section B above.).

This part of the document should look something like:
Language: (identify)
Translation: (the phrase in English)

Note:
This document might seem overly detailed or specific, but if it stops even one student from cheating, then it will be considered worth the effort on all our parts.

The part will be marked based on following the instructions for Project Two (02). Below is a breakdown of the marks for this assignment:
[7 marks] Document submitted.
[3 marks] Correct values entered in the document. All values must be correct to achieve the full 3 marks. No part marks.
Total: 10 marks

6 TIPS AND GUIDELINES

  1. All code is to be indented correctly.
  2. Comments at the very beginning (top – first lines) of the file must be:
    NOTE: Change the second line for each part accordingly:
    END: Project One (01) – Part A
    END: Project One (01) – Part B
    END: Project One (01) – Part C
  3. The second last line of each of your parts for Project 1 must indicate successful completion of the code accordingly:
    END: Project One <01> – Part A
    END: Project One <01> – Part B
    END: Project One <01> – Part C
  4. The last line of your code must print out your name and your Western user name.
    example:
    Max Magguilli mmagg37 000326384
  5. All variables (excluding any counter variable inside for loops) MUST have a comment describing their intended use(s).
  6. For this assignment, three separate and independent Python files are to be submitted. Each Python file (ending in the suffix .py) is required. All code for all three parts of Project One (01) are be submitted.
  7. The student MUST submit three Python files for Project One (01) of this assignment. Any other file or any file with any other extension except .py will NOT be graded.
  8. A comment describing the code for each exercise must be included. The comment(s) can be brief but must convey what that section of code performs.
  9. Variables should be in the official Python style for variables. Lowercase words separated by an underscore (e.g. my_variable).
  10. Add comments throughout your code to explain what each section of the code is doing and/or how it works.

7 RULES

  • Read and follow the instructions carefully.
  • Submit the PDF document (the document MUST have the .PDF extension). No other text document will be graded.
  • Forgetting to submit a finished assignment is not a valid excuse for submitting late.
  • Submissions must be done on Gradescope. They will not be accepted by email.
  • You may re-submit your document as many times as you would like. Gradescope uses your last submission as the one for grading by default. There are no penalties for resubmitting. However, re-submissions that come in after the due date will be considered late and automatically subject to the use of late coupons.

8 MARKING GUIDELINES

The assignment may be marked as a combination of your auto-graded tests and manual grading of your code logic, comments, formatting, style, etc. Below is a breakdown of the marks for this assignment:

  • [55 marks] Auto-Testing your code for correctness and adherence to the specifications by producing the expected output
  • [15 marks] Code logic and completeness
  • [5 marks] Comments
  • [10 marks] Code formatting
  • [5 marks] Meaningful and properly formatted variables
  • [10 marks] Academic Dishonesty Document
  • Total: 100 marks

9 GRADESCOPE SUBMISSION

  1. You must submit the 4 files to the Assignment 1 submission page on Gradescope. The required files are:
    yourUWOAccountName_Asn01_A.py( for part A of Project One (01) )
    yourUWOAccountName_Asn01_B.py( for part B of Project One (01) )
    yourUWOAccountName_Asn01_C.py ( for part C of Project One (01) )
    yourUWOAccountName_Asn01.pdf( for Project Two (02) )
    (example: assume my UWO email is kdoit373@uwo.ca i.e. if my email is – kdoit373@uwo.ca then my ID will be – kdoit373 So, my UWO Account Name is: kdoit373 and this assignment is Asn01. therefore, my file names that are to be used for submission are:
    kdoit373_Asn01.py -and- kdoit373_Asn01.pdf
  2. .html , .ipynb, and all other file extensions will not be accepted under any circumstances and it will result in failing ALL test.
  3. The submission will be using Gradescope.
    You can find the instruction on how to complete your submission by following the steps in this video:

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/ajarada3/public_html/other/1026F23/assig01.php on line 672

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/ajarada3/public_html/other/1026F23/assig01.php on line 673

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/ajarada3/public_html/other/1026F23/assig01.php on line 673
this file was last modified on 2023-10-02 13:12:01 EST
TOP