programming assignment 1

  • Is CS 121 a good fit for you?
  • Academic Honesty
  • Introductory Labs
  • M1: Introduction to Programming
  • M2: Functions
  • M3: Dictionaries & File Basics
  • M4: Classes and Objects
  • M6: Recursion
  • M7 (Bonus): Pandas
  • Getting Help
  • How to Learn in this Class
  • Asking Questions on Piazza
  • Office Hours
  • Coursework Basics
  • Testing Your Code
  • Virtual Desktop
  • Working Remotely with Visual Studio Code and SSH
  • Style Guide
  • The Debugging Guide
  • Pre-recorded Lectures
  • Textbook Chapters
  • Zoom Sessions
  • Short Exercises
  • Programming Assignment

M1: Introduction to Programming ¶

This first module provides an introduction to basic programming concepts and skills.

Pre-recorded Lectures ¶

The pre-recorded lectures are available through Canvas.

The lectures include a video to introduce the module (“Introduction to Module M1”) and a series of 5-15 minute videos divided into three sections:

1a.1 - Introduction

1a.2 - Writing and Running your First Program

1a.3 - Variables

1a.4 - Expressions

1a.5 - Bonus: Types Revisited

1b.1 - Introduction

1b.2 - Conditional Statements

1b.3 - “for” loops

1b.4 - Example: Primality Testing

1b.5 - “while” loops

1c.1 - Introduction

1c.2 - List Creation and Basic Usage

1c.3 - List Iteration

1c.4 - Adding/Removing Elements from a List

1c.5 - List Slicing

1c.6 - Lists of Lists

1c.7 - Tuples

1c.8 - Strings

1c.9 - Bonus: List Comprehensions

1c.10 - Bonus: Lists in Memory

Textbook Chapters ¶

The chapters corresponding to this module are:

Computational Thinking

Programming Basics

Control Flow Statements

Lists, Tuples, and Strings

A PDF version of the textbook is also available here .

You will be asked to log in with your CNetID before you can see the textbook.

Please note that the pre-recorded lectures cover largely the same material as the book. We recommend starting with the pre-recorded lectures, and then reading through the book (but do not feel bad if you find yourself skipping large portions of the textbook, if you feel they tread on material that you already understood when watching the lectures)

Zoom Sessions ¶

You will find the links to the Zoom sessions on Canvas.

Wednesday, September 30th : Introduction to CS 121

Friday, October 2nd : Q&A and Git

Wednesday, October 7th : Lab #1

Friday, October 9th : Q&A and List/Loops Examples

Lab #1: Lists and Loops

In the October 7th lecture, we will be working through a few of the problems in this lab. You are not expected to complete the lab before that lecture, but you should try to read through it so you are familiar with its contents.

Short Exercises ¶

Short Exercises #1 , due Sunday, Oct 11 at 3pm CDT

Programming Assignment ¶

Programming Assignment #1 , due Friday, Oct 16 at 3pm CDT

CS 2110: Object-Oriented Programming and Data Structures

Assignment 1.

A1 consists of a series of exercises to help you transition to procedural programming in the Java language. The problem-solving elements are at the level of lab exercises from CS 1110/1112. The assignment comes bundled with a thorough test suite, so you will know when you have implemented each method’s specifications correctly.

You must work on this assignment independently (no partners)—we want to ensure that every student can write, test, and submit Java code on their own. For this reason, we are also grading this assignment for mastery ; if a grader identifies mistakes that you didn’t catch yourself, you may resubmit once to correct them without penalty.

Learning objectives

  • Author Java code in the IntelliJ IDEA IDE.
  • Employ operations on Java’s primitive types ( boolean , int , double ) and strings to solve high-level problems.
  • Employ Java control structures ( if , for , while ) to implement algorithms for solving high-level problems.
  • Select relevant mathematical functions from Java’s standard library by referencing JavaDoc pages.
  • Verify the correctness of implementations by running JUnit test cases.
  • Adopt good programming style to facilitate readability and maintenance.
  • Witness examples of precise method specifications that separate “what” from “how”.

If you are worried that these exercises seem a bit dry and mathematical, that is a consequence of restricting ourselves to Java’s primitive types (which are mostly numbers). Once we get to object-oriented programming in A2, the problem domains will become richer.

Collaboration policy

This assignment is to be completed as an individual. You may talk with others to discuss Java syntax, debugging tips, or navigating the IntelliJ IDE, but you should refrain from discussing algorithms that might be used to solve the problems, and you must never show your in-progress or completed code to another student. Consulting hours are the best way to get individualized assistance at the source code level.

Frequently asked questions

There is a pinned post on Ed where we will post any clarifications for this assignment. Please review it before asking a new question in case your concern has already been addressed. You should also review the FAQ before submitting to see whether there are any new ideas that might help you to improve your solution.

I. Getting started

You already know at least one procedural language (e.g. Python) with which you should be able to solve the problems on this assignment. If that language is not Java, then the goal is for you to become comfortable with procedural Java syntax, as it compares with what you already know, by practicing it in targeted problems. Start by reading transition to Java on the course website, which provides a focused translation guide between Python, MATLAB, and Java.

Download the release code from the CMSX assignment page; it is a ZIP file named “a1-release.zip”. Decide where on your computer’s disk you want your project to be stored (we recommend a “CS2110” directory under your home or documents folder), then extract the contents of the ZIP file to that directory. Find the folder simply named “a1” (depending on your operating system, this may be under another folder named “a1-release”); its contents should look like this:

We assume you have already followed the setup instructions for IntelliJ, possibly in your first discussion section. It is important that JDK 17 has been downloaded.

In IntelliJ, select File | Open , then browse to the location of this “a1” directory, highlight “a1”, and click OK . IntelliJ may ask whether you want to open the project in the same window or a new one; this is up to you, noting that if you choose the same window, whatever project you previously had open (e.g. a discussion activity or old assignment) will be closed.

Just two more steps before you can begin coding: you need to tell IntelliJ which version of Java to use for your project (even if you only have one), and you need to tell it what software to use to run the tests.

  • From IDEA’s project browser, open “src/cs2110/A1.java”. You should see a banner at the top of your editor saying “Project JDK is not defined”; click the “Setup SDK” link in the upper-right corner, then select the version 17 JDK that you downloaded earlier.
  • Open “tests/cs2110/A1Test.java”; expect lots of errors to be highlighted in red. At the top of the file will be one or more import statements related to JUnit (e.g. import org.junit.jupiter.api.Test; ); you might need to expand the import block to see them. Hover your mouse over the word junit on one of those lines, wait a second for a context popup to appear, then click “More actions…” and choose “Add ‘JUnit 5.8.1’ to class path”. (Do not choose JUnit 4.) Finally, click OK in the resulting dialog.

The red highlights should go away, and you should be able to implement methods and run tests.

Please keep track of how much time you spend on this assignment. There is a comment at the top of “A1.java” for reporting this time, along with asserting authorship.

II. Working with the provided code

Specifications and preconditions.

A recurring theme in this course is distinguishing between the roles of client and implementer . For methods, a client is someone who calls a method, and the implementer is someone who writes the method’s body. Although you might function both as client and implementer in a small project, ideally the two roles have no knowledge of one another, so you should keep track of which role you are currently in and “split your brain” accordingly. For most of this assignment you will be in the implementer role.

Each method is accompanied by a specification in a JavaDoc comment. As the implementer, your job is to write a method body that fulfills that specification. Specifications may include a precondition phrased as a “requires” clause. As the implementer, you can assume that the precondition is already satisfied. You do not have to attempt to check the precondition or to handle invalid arguments in any special way. It would be the responsibility of clients to ensure that they do not violate such conditions.

For example, if a specification contains the precondition “ nTerms is non-negative”, then the client is never permitted to pass negative arguments to the function. If the client nonetheless does so, the specification promises nothing about the result. Specifically, the specification does not promise that the function will check for non-negativity, and the specification does not promise that any kind of error will be produced. That means the implementer has an easy job: they can simply ignore the possibility of negative arguments.

You might have been taught in previous programming classes that implementers must always check preconditions, or must always produce an error when a precondition is violated. Those are useful and important defensive programming techniques! (And we will see how to employ them in Java soon.) But the point we are making here is that they are not mandated by a “requires” clause. So in this assignment, you do not have to use such techniques, and it’s likely to be easier for you to omit them entirely.

Replacing method “stubs”

The body of each method initially looks like this:

This is a placeholder —it allows the method to compile even though it doesn’t return a value yet, but it will cause any tests of the method to fail. You should delete these lines as the first step when implementing each method. (We’ll discuss the meaning of these lines later in the course when we cover exceptions, objects, and so forth.)

Use the TODO comments to guide you to work that still needs to be done. As you complete each task, remove the comment line with the TODO since it doesn’t need doing anymore! Temporary comment prefixes like TODO and FIXME are a convenient way to keep track of your progress when writing and debugging code.

Finally, some method bodies contain comments with “implementation constraints.” These are not part of the specification, as they do not affect potential clients. Instead, they are requirements of the assignment to ensure that you get practice with the necessary skills. Violating these constraints will not cause unit tests to fail, but points will be deducted by your grader, so make sure you obey them.

Test cases for each method are in “tests/cs2110/A1Test.java”. You are encouraged to read the test suites to see what corner cases are considered, but you do not need to add any tests of your own for this assignment.

To run a test case, click the green arrow to the left of the method name, then select “Run”; the results will be shown at the bottom of the screen. To run all test cases, use the arrow to the left of the class name ( A1Test ). If a test fails with a yellow “X”, that means it returned the wrong result. By reading the messages in the output window, you should be able to determine which case failed and what your implementation computed instead. If it fails with a red “!”, that means it encountered an error (or you forgot to delete the placeholder throw line).

III. Assignment walkthrough

Implement the methods one at a time. As soon as you implement one, run the corresponding test case to verify your work. Do not modify any method signatures (or return types or throws clauses)—not only would that change the class type we provided, but it would make it impossible for our autograder to interoperate with your code. And do not leave print statements in your final submission unless the method specification mentions printing output as a side effect.

Each of the numbered exercises below references a section of the Supplement 1 chapter of the primary course textbook, Data Structures and Abstraction with Java , 5th edition, to which you should have access in Canvas through the “Course Materials” link. That supplement is designed to help students who know how to program, but are new to Java. It is a great resource for making the transition to Java.

1. Regular polygons

[Textbook: S1.29: The Class Math ]

The area of a regular polygon with n sides of length s is given by the formula:

$$A = \frac{1}{4} s^2 \frac{n}{\tan(\pi/n)}$$

Implement this formula. You will need one or more math functions and/or constants from Java’s standard library. Skim the JavaDoc page for the static methods in the Math class to learn which functions are available. Remember that a Math. prefix is required when calling them (so to compute the absolute value of -5, you would write Math.abs(-5) ).

Take some time to explore these functions and get a feel for how Java’s standard library is documented. The functions you are most likely to use later in the course include: abs() , min() , max() , sqrt() , pow() , and the trigonometric functions.

Note: methods dealing with dimensionful quantities (like length and area) should always say something about what units (e.g. meters, acres) those quantities are measured in. In this case, the formula makes no assumptions about units, so the specification simply tells the client that the units of the output are compatible with the units of the input.

2. Collatz sequence

[Textbook: S1.59: The while Statement]

The Collatz conjecture is a fun piece of mathematical trivia: by repeatedly performing one of two simple operations on a positive integer (depending on whether it is even or odd), you always seem to get back to 1. The rules for determining the next number in the sequence are:

  • If the last number was even, divide it by 2.
  • If the last number was odd, multiply it by 3 and add 1.

Our objective is to sum all of the terms in the sequence starting from a given “seed” number until we get to 1. This involves indefinite iteration , and you should use a while loop for this.

This is also a chance to practice problem decomposition and defining new methods. Declare and implement a method named nextCollatz() that takes one int argument and returns an int value according to the given specification. When you have done this, remove the TODO and uncomment the relevant test case in A1Test (it was commented out because the test case will not compile unless that method is at least declared, preventing you from running tests for other methods in the suite). Tip: there is an IntelliJ keyboard shortcut for commenting and uncommenting whole selections of code; can you find it?

3. Median of three

[Textbook: S1.38: The if-else Statement]

The median value of a collection of numbers is the value that would be in the middle if the collection were sorted. A special case is median-of-three voting , which is used in fault-tolerant systems to decide how to proceed when not all components agree. This small function is actually one of the most commonly-run procedures in SpaceX’s flight software, helping it determine which sensors and commands to trust dozens of times per second.

You need to develop an algorithm for determining which of three numbers is the middle value. The numbers could be in any order, and there could be duplicates. Use a chain of conditional statements ( if / else ), possibly nested, to find the middle value.

4. Interval overlaps

[Textbook: S1.41: Boolean Expressions]

Intervals are a useful abstraction when working with schedules. For example, if class meeting times are represented as intervals over the seconds of a day, then an overlap would imply that two classes conflict.

This exercise is designed to help you avoid a common “anti-pattern” among new programmers:

(here, expr is a Boolean expression, like x > 0 ). Remember that the conditions used in if statements are expressions that yield a boolean value and can be used anywhere a boolean value like true or false could be used. Therefore, the above code can (and should) be rewritten as:

Keeping this in mind, implement intervalsOverlap() using a single return statement.

5. Estimating pi

[Textbook: S1.61: The for Statement]

The Madhava-Leibniz series is an infinite sum of numbers that is related to π:

$$\frac{\pi}{4} = 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \ldots$$

Observe that the denominators of the terms are the sequence of odd integers and that the sign alternates between plus and minus.

By truncating this series after a finite number of terms, we get an approximation for π (though this particular formula requires many terms for even modest accuracy). Use a for -loop to evaluate this approximation for a specified number of terms (this is an example of definite iteration ). Recall that integer division in Java rounds down to another integer, so you may need to cast some numbers to a floating-point type when evaluating the fractions.

As a corner case, note that the sum of zero terms is 0.

6. Palindromes

[Textbook: S1.67: The Class String ]

With control structures and primitive types out of the way, it’s time to get some experience with our first aggregate type : String (an aggregate type is one that groups together multiple values, like how a String contains multiple char s). Strings get some special treatment in Java; while they are objects , they are immutable (their contents can’t be changed), which means they behave much like primitive values. And unlike other objects, they have their own literals and even an operator ( + for concatenation). But as a sequence of characters they are like arrays, giving you some early practice with algorithms that iterate over data.

A palindrome has the same sequence of characters when written backwards as when written normally. To examine the i th character in string s , use s.charAt(i) . The total number of characters in s is given by s.length() . In Java, the index of the first character is 0 , and the index of the last character is s.length() - 1 . The specifications for these methods are in the API documentation for String ; by calling them, you are now in the client role with respect to the String class.

7. Formatting messages

[Textbook: S1.70: Concatenation of Strings]

A common task in computing systems is to format information to be read by humans. The system may need to support translations in multiple languages, and sometimes words will change depending on the data being explained (e.g. singular vs. plural nouns, “a” vs. “an” depending on the following word, etc.). To manage this potential complexity, it is a good idea to move formatting logic into its own function (Java actually provides a sophisticated infrastructure for managing this in large applications, but that is beyond the scope of this course).

This exercise requires you to concatenate strings and to format numerical data as a string. There are several approaches you can take; the + operator is probably most convenient, but if you have used a format or printf feature in another language, you might be interested in String ’s format() method. This is also a good opportunity to get practice with Java’s ternary operator ?: , an awkward-to-read but extremely useful bit of syntax; use this to decide between the singular and plural forms of “item” without using an if -statement.

8. Making a program

Now it’s time to step into the client role. Add a main() method so that the A1 class can be run as a program. Find a way to use at least four of the methods in A1 in combination, then print the final result. Is is okay to be silly here! Ideas include:

  • Compute the sums of three Collatz sequences of your choice, then take their median; use this as the number of sides of a polygon. For the length of the polygon’s sides, use an estimate of π. Print the polygon’s area.
  • Compute the median of three numbers of your choice, then find the next number in the Collatz sequence after it. Use this as the number of items in an order, then determine whether that order’s confirmation message is a palindrome.

You can be creative here and provide arbitrary inputs as necessary, but all four methods must contribute somehow to the final result.

Your program’s printed output should be a complete sentence written in English. It should describe what final operation was performed, what its inputs were, and what the result was (the inputs and outputs should not be baked into the text; they should be the values of program variables or expressions). For example, “The area of a polygon with 4 sides of length 0.5 m is 0.25 m^2.” When you run your program, make sure this is the only output (i.e. that there are no “debugging prints” in the other methods you are calling).

IV. Scoring

This assignment is evaluated in the following categories:

  • Submitted and compiles (25%)
  • Fulfills specifications (43%)
  • Complies with implementation constraints (25%)
  • Exhibits good code style (5%)
  • Contains metadata in header comment (2%)

You can maximize the “fulfilling specifications” portion of your score by passing all of the included unit tests (don’t forget to uncomment the ones for nextCollatz() ). The smoketester will also run these tests for you when you submit so you can be sure that your code works as well for us as it does for you.

Formatting is a subset of style. To be on the safe side, ensure that our style scheme is installed and that you activate “Reformat Code” before submitting. Graders will deduct for obvious violations that detract from readability, including improper indentation and misaligned braces.

But beyond formatting, choose meaningful local variable names, follow Java’s capitalization conventions (camelCase), and look for ways to simplify your logic. If the logic is subtle or the intent of a statement is not obvious, clarify with an implementation comment.

V. Submission

Double-check that you have provided the information requested in the header comment in “A1.java” (name, NetID, hours worked).

Upload your “A1.java” file to CMSX before the deadline. If you forgot where your project is saved on your computer, you can right-click on “A1.java” in IntelliJ’s project browser and select “Open In”, then your file explorer (e.g. “Explorer” for Windows, “Finder” for Mac). Be careful to only submit “.java” files, not files with other extensions (e.g. “.class”).

After you submit, CMSX will automatically send your submission to a smoketester , which is a separate system that runs your solution against the same tests that we provided to you in the release code. The purpose of the smoketester is to give you confidence that you submitted correctly. You should receive an email from the smoketester shortly after submitting. Read it carefully, and if it doesn’t match your expectations, confirm that you uploaded the intended version of your file (it will be attached to the smoketester feedback). Be aware that these emails occasionally get misclassified as spam, so check your spam folder. It is also possible that the smoketester may fall behind when lots of students are submitting at once. Remember that the smoketester is just running the same tests that you are running in IntelliJ yourself, so don’t panic if its report gets lost—we will grade all work that is submitted to CMSX, whether or not you receive the email.

Write a program to estimate the value of the percolation threshold via Monte Carlo simulation.

import edu.princeton.cs.algs4.StdRandom; import edu.princeton.cs.algs4.StdStats; import edu.princeton.cs.algs4.WeightedQuickUnionUF;
         
public class Percolation { // creates n-by-n grid, with all sites initially blocked public Percolation(int n) // opens the site (row, col) if it is not open already public void open(int row, int col) // is the site (row, col) open? public boolean isOpen(int row, int col) // is the site (row, col) full? public boolean isFull(int row, int col) // returns the number of open sites public int numberOfOpenSites() // does the system percolate? public boolean percolates() // test client (optional) public static void main(String[] args) }
--> \[ \overline x = \frac{x_1 \, + \, x_2 \, + \, \cdots \, + \, x_{T}}{T}, \quad s^2 = \frac{(x_1 - \overline x )^2 \, + \, (x_2 - \overline x )^2 \,+\, \cdots \,+\, (x_{T} - \overline x )^2}{T-1} \]
--> \[ \left [ \; \overline x - \frac {1.96 s}{\sqrt{T}}, \;\; \overline x + \frac {1.96 s}{\sqrt{T}} \; \right] \]
public class PercolationStats { // perform independent trials on an n-by-n grid public PercolationStats(int n, int trials) // sample mean of percolation threshold public double mean() // sample standard deviation of percolation threshold public double stddev() // low endpoint of 95% confidence interval public double confidenceLo() // high endpoint of 95% confidence interval public double confidenceHi() // test client (see below) public static void main(String[] args) }
~/Desktop/percolation> java-algs4 PercolationStats 200 100 mean = 0.5929934999999997 stddev = 0.00876990421552567 95% confidence interval = [0.5912745987737567, 0.5947124012262428] ~/Desktop/percolation> java-algs4 PercolationStats 200 100 mean = 0.592877 stddev = 0.009990523717073799 95% confidence interval = [0.5909188573514536, 0.5948351426485464] ~/Desktop/percolation> java-algs4 PercolationStats 2 10000 mean = 0.666925 stddev = 0.11776536521033558 95% confidence interval = [0.6646167988418774, 0.6692332011581226] ~/Desktop/percolation> java-algs4 PercolationStats 2 100000 mean = 0.6669475 stddev = 0.11775205263262094 95% confidence interval = [0.666217665216461, 0.6676773347835391]

Browse Course Material

Course info, instructors.

  • Prof. Eric Grimson
  • Prof. John Guttag

Departments

  • Electrical Engineering and Computer Science

As Taught In

  • Programming Languages

Introduction to Computer Science and Programming

Assignments.

facebook

You are leaving MIT OpenCourseWare

Course Fry

Programming Assignment: Assignment 1 Time Zones Solution

In this article i am gone to share a Coursera Course: Learn to Program: The Fundamentals Week 1 Assignment | Programming Assignment: Assignment 1 Time Zones Solution with you..

There are several functions that you will need to implement. We have listed the functions roughly in order of complexity. Each function body will be quite short. You can submit your assignment for feedback once every hour up until the deadline; we recommend that you do this at least once early on in order to make sure you can submit properly.

  • Step 1: Download the starter code
  • Step 2: Complete the body of function seconds_difference
  • Step 3: Complete the body of function hours_difference
  • Step 4: Complete the body of function to float_hours
  • Step 5: Write functions get_hours, get_minutes and get_seconds
  • Step 6: Complete the bodies of functions time_to_utc and time_from_utc
  • Step 7: Submit your work.

Programming Assignment: Assignment 1 Time Zones

  • You first need to create a python file give name assignment1.py
  • Copy all the code paste in a file and then save it.
  • Now upload your file on Coursera Course assignment and then click on submit.

assignment1.py

def seconds_difference(time_1, time_2): “”” (number, number) -> number Return the number of seconds later that a time in seconds time_2 is than a time in seconds time_1.   >>> seconds_difference(1800.0, 3600.0) 1800.0 >>> seconds_difference(3600.0, 1800.0) -1800.0 >>> seconds_difference(1800.0, 2160.0) 360.0 >>> seconds_difference(1800.0, 1800.0) 0.0 “”” return time_2 – time_1 def hours_difference(time_1, time_2): “”” (number, number) -> float Return the number of hours later that a time in seconds time_2 is than a time in seconds time_1.   >>> hours_difference(1800.0, 3600.0) 0.5 >>> hours_difference(3600.0, 1800.0) -0.5 >>> hours_difference(1800.0, 2160.0) 0.1 >>> hours_difference(1800.0, 1800.0) 0.0 “”” return (time_2 – time_1)/3600.0 def to_float_hours(hours, minutes, seconds): “”” (int, int, int) -> float Return the total number of hours in the specified number of hours, minutes, and seconds. Precondition: 0 <= minutes < 60 and 0 <= seconds < 60 >>> to_float_hours(0, 15, 0) 0.25 >>> to_float_hours(2, 45, 9) 2.7525 >>> to_float_hours(1, 0, 36) 1.01 “”” return (hours + (minutes/60) + (seconds/3600)) def to_24_hour_clock(hours): “”” (number) -> number hours is a number of hours since midnight. Return the hour as seen on a 24-hour clock. Precondition: hours >= 0 >>> to_24_hour_clock(24) 0 >>> to_24_hour_clock(48) 0 >>> to_24_hour_clock(25) 1 >>> to_24_hour_clock(4) 4 >>> to_24_hour_clock(28.5) 4.5 “”” return hours % 24 ### Write your get_hours function definition here: def get_hours(time): “””(int) -> int   Return the number of hours that have elapsed since midnight, as seen on a 24-hour clock >>> get_hours(3800) 1 “”” x= time/3600 return int(to_24_hour_clock(x)) ### Write your get_minutes function definition here: def get_minutes(time): “””(int) -> int Return the number of minutes that have elapsed since midnight as seen on a clock. >>> get_minutes(3800) 3 “”” x=int(time/3600) z= time -(x*3600) y=z/60 return int(y) ### Write your get_seconds function definition here: def get_seconds(time): “””(int) -> int Return the number of seconds that have elapsed since midnight as seen on a clock. >>> get_seconds(3800) 20 “”” x=int(time/3600) z= time -(x*3600) y=z%60 return int(y) def time_to_utc(utc_offset, time): “”” (number, float) -> float Return time at UTC+0, where utc_offset is the number of hours away from UTC+0. >>> time_to_utc(+0, 12.0) 12.0 >>> time_to_utc(+1, 12.0) 11.0 >>> time_to_utc(-1, 12.0) 13.0 >>> time_to_utc(-11, 18.0) 5.0 >>> time_to_utc(-1, 0.0) 1.0 >>> time_to_utc(-1, 23.0) 0.0 “”” time_2 = (time -(utc_offset)) return (to_24_hour_clock(time_2)) def time_from_utc(utc_offset, time): “”” (number, float) -> float Return UTC time in time zone utc_offset. >>> time_from_utc(+0, 12.0) 12.0 >>> time_from_utc(+1, 12.0) 13.0 >>> time_from_utc(-1, 12.0) 11.0 >>> time_from_utc(+6, 6.0) 12.0 >>> time_from_utc(-7, 6.0) 23.0 >>> time_from_utc(-1, 0.0) 23.0 >>> time_from_utc(-1, 23.0) 22.0 >>> time_from_utc(+1, 23.0) 0.0 “”” time_2 = (time +(utc_offset)) return (to_24_hour_clock(time_2))

Note: after submit please wait your marks will we updated within 2 minutes.. If you get any error tell me i will resolved it.. Thank you..

Leave a Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

  • [Programming Assignment 1] R Programming
  • by Anderson Hitoshi Uyekita
  • Last updated almost 2 years ago
  • Hide Comments (–) Share Hide Toolbars

Twitter Facebook Google+

Or copy & paste this link into an email or IM:

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

Notes, programming assignments and quizzes from all courses within the Coursera Deep Learning specialization offered by deeplearning.ai: (i) Neural Networks and Deep Learning; (ii) Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization; (iii) Structuring Machine Learning Projects; (iv) Convolutional Neural Network…

amanchadha/coursera-deep-learning-specialization

Folders and files, repository files navigation, deep learning specialization on coursera (offered by deeplearning.ai).

Programming assignments and quizzes from all courses in the Coursera Deep Learning specialization offered by deeplearning.ai .

Instructor: Andrew Ng

For detailed interview-ready notes on all courses in the Coursera Deep Learning specialization, refer www.aman.ai .

Run setup.sh to (i) download a pre-trained VGG-19 dataset and (ii) extract the zip'd pre-trained models and datasets that are needed for all the assignments.

This repo contains my work for this specialization. The code base, quiz questions and diagrams are taken from the Deep Learning Specialization on Coursera , unless specified otherwise.

2021 Version

This specialization was updated in April 2021 to include developments in deep learning and programming frameworks, with the biggest change being shifting from TensorFlow 1 to TensorFlow 2. This repo has been updated accordingly as well.

Programming Assignments

Course 1: neural networks and deep learning.

  • Week 2 - PA 1 - Python Basics with Numpy
  • Week 2 - PA 2 - Logistic Regression with a Neural Network mindset
  • Week 3 - PA 3 - Planar data classification with one hidden layer
  • Week 4 - PA 4 - Building your Deep Neural Network: Step by Step
  • Week 4 - PA 5 - Deep Neural Network for Image Classification: Application

Course 2: Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization

  • Week 1 - PA 1 - Initialization
  • Week 1 - PA 2 - Regularization
  • Week 1 - PA 3 - Gradient Checking
  • Week 2 - PA 4 - Optimization Methods
  • Week 3 - PA 5 - TensorFlow Tutorial

Course 3: Structuring Machine Learning Projects

  • There are no programming assignments for this course. But this course comes with very interesting case study quizzes (below).

Course 4: Convolutional Neural Networks

  • Week 1 - PA 1 - Convolutional Model: step by step
  • Week 1 - PA 2 - Convolutional Neural Networks: Application
  • Week 2 - PA 1 - Keras - Tutorial - Happy House
  • Week 2 - PA 2 - Residual Networks
  • Week 2 - PA 2 - Transfer Learning with MobileNet
  • Week 3 - PA 1 - Car detection with YOLO for Autonomous Driving
  • Week 3 - PA 2 - Image Segmentation Unet
  • Week 4 - PA 1 - Art Generation with Neural Style Transfer
  • Week 4 - PA 2 - Face Recognition

Course 5: Sequence Models

  • Week 1 - PA 1 - Building a Recurrent Neural Network - Step by Step
  • Week 1 - PA 2 - Dinosaur Land -- Character-level Language Modeling
  • Week 1 - PA 3 - Jazz improvisation with LSTM
  • Week 2 - PA 1 - Word Vector Representation and Debiasing
  • Week 2 - PA 2 - Emojify!
  • Week 3 - PA 1 - Neural Machine Translation with Attention
  • Week 3 - PA 2 - Trigger Word Detection
  • Week 4 - PA 1 - Transformer Network
  • Week 3 - PA 2 - Transformer Network Application: Named-Entity Recognition
  • Week 3 - PA 2 - Transformer Network Application: Question Answering

Quiz Solutions

  • Week 1 Quiz - Introduction to deep learning: Text | PDF
  • Week 2 Quiz - Neural Network Basics: Text | PDF
  • Week 3 Quiz - Shallow Neural Networks: Text | PDF
  • Week 4 Quiz - Key concepts on Deep Neural Networks: Text | PDF
  • Week 1 Quiz - Practical aspects of deep learning: Text | PDF
  • Week 2 Quiz - Optimization algorithms: Text | PDF
  • Week 3 Quiz - Hyperparameter tuning, Batch Normalization, Programming Frameworks: Text | PDF
  • Week 1 Quiz - Bird recognition in the city of Peacetopia (case study): Text | PDF
  • Week 2 Quiz - Autonomous driving (case study): Text | PDF
  • Week 1 Quiz - The basics of ConvNets: Text | PDF
  • Week 2 Quiz - Deep convolutional models: Text | PDF
  • Week 3 Quiz - Detection algorithms: Text | PDF
  • Week 4 Quiz - Special applications: Face recognition & Neural style transfer: Text | PDF
  • Week 1 Quiz - Recurrent Neural Networks: Text | PDF
  • Week 2 Quiz - Natural Language Processing & Word Embeddings: PDF
  • Week 3 Quiz - Sequence models & Attention mechanism: Text | PDF

I recognize the time people spend on building intuition, understanding new concepts and debugging assignments. The solutions uploaded here are only for reference . They are meant to unblock you if you get stuck somewhere. Please do not copy any part of the code as-is (the programming assignments are fairly easy if you read the instructions carefully). Similarly, try out the quizzes yourself before you refer to the quiz solutions. This course is the most straight-forward deep learning course I have ever taken, with fabulous course content and structure. It's a treasure by the deeplearning.ai team.

Contributors 9

@amanchadha

  • Jupyter Notebook 98.6%

IMAGES

  1. Programming Assignment 1

    programming assignment 1

  2. 2203 Programming assignment Unit 1

    programming assignment 1

  3. Programming Assignment 1.pdf

    programming assignment 1

  4. Introduction to C

    programming assignment 1

  5. PPT

    programming assignment 1

  6. Programming Assignment UNIT 1

    programming assignment 1

VIDEO

  1. NPTEL Programming In Java Week 1 Assignment 1 Answers Solution Quiz

  2. NPTEL Programming In Java Week 1 Programming Assignment Answers Solution

  3. NPTEL Problem Solving through Programming in C ASSIGNMENT 1 ANSWERS 2024

  4. NPTEL Programming, Data Structures and Algorithms using Python Assignment 1 Answers Week 1 Jan-2024

  5. NPTEL Programming in Modern C++ WEEK 1 ASSIGNMENT 1 ANSWERS Solutions Quiz

  6. NPTEL Programming In Java Week 1 Assignment 1 Answers Solution Quiz

COMMENTS

  1. GitHub

    Programming Assignment 1: Programming Challenges (OPTIONAL) Solving The Maximum Pairwise Product Programming Challenge in C++; Maximum Pairwise Product Programming Challenge; Using PyCharm to solve programming challenges (optional experimental feature) Acknowledgements (Optional)

  2. Assignment 1: JavaScript fundamentals

    Getting started. As with assignment 0, follow these steps to get started. Download the starter code and extract the .zip file's contents. Open your command line and navigate to the extracted assign1 directory. Run npm install. Run npm start to start the web server. Open localhost:1930 in your web browser.

  3. Algorithmic Toolbox

    There are 6 modules in this course. This online course covers basic algorithmic techniques and ideas for computational problems arising frequently in practical applications: sorting and searching, divide and conquer, greedy algorithms, dynamic programming. We will learn a lot of theory: how to sort data and how it helps for searching; how to ...

  4. Programming Assignment 1: Hello, World

    Programming Assignment 1: Hello, World. The purpose of this assignment is to introduce you to programming in Java and familiarize you with the mechanics of preparing and submitting assignment solutions. Install our Java programming environment (recommended). Install our novice-friendly Java programming environment on your computer by following ...

  5. Creative Programming Assignments

    Below are links to a number of creative programming assignments that we've used at Princeton. Some are from COS 126: Introduction to Computer Science; others are from COS 226: Data Structures and Algorithms . The main focus is on scientific, commercial, and recreational applications. The assignments are posed in terms of C or Java, but they ...

  6. Object Oriented Programming in Java

    Course Opening Title • 0 minutes • Preview module. Welcome (Object Oriented Java Programming: Data Structures and Beyond Specialization) • 3 minutes. Welcome (Object Oriented Programming in Java Specialization) • 1 minute. Project prototype • 4 minutes. Your Path through the Course • 5 minutes.

  7. M1: Introduction to Programming

    The lectures include a video to introduce the module ("Introduction to Module M1") and a series of 5-15 minute videos divided into three sections: 1a - Introduction to Programming. 1a.1 - Introduction. 1a.2 - Writing and Running your First Program. 1a.3 - Variables.

  8. Assignment 1 (CS 2110 Fall 2023)

    Assignment 1. A1 consists of a series of exercises to help you transition to procedural programming in the Java language. The problem-solving elements are at the level of lab exercises from CS 1110/1112. The assignment comes bundled with a thorough test suite, so you will know when you have implemented each method's specifications correctly.

  9. Programming Assignment 1: Percolation

    Programming Assignment 1: Percolation. Write a program to estimate the value of the percolation threshold via Monte Carlo simulation. Install our Java programming environment (optional). Install our custom IntelliJ programming environment by following these step-by-step instructions for your operating system [ Mac OS X · Windows · Linux ].

  10. Assignments

    Introduction to Computer Science and Programming. Menu. More Info Introductory Programming Courses Archived D-Space Course Assignments. pdf. 98 kB Getting Started: Python and IDLE. file. 193 B ... 1 kB ps5_ghost. file. 6 kB test_ps5. pdf. 78 kB Problem Set 6: Word Game II. file. 7 kB ps6. pdf. 29 kB Problem Set 7. pdf ...

  11. Sonia-96/Coursera-Data_Structures_and_Algorithms

    My solutions to assignments of Data structures and algorithms (by UCSD and HSE) on Coursera. All problems from Course 1 to Course 5 have been solved. - Sonia-96/Coursera-Data_Structures_and_Algorithms ... Dynamic Programming 1. Money Change Again; Primitive Calculator; Edit Distance; Longest Common Subsequence of Two Sequences; Longest Common ...

  12. PDF Programming Assignment 1: Learning Distributed Word Repre- sentations

    CSC421/2516 Winter 2019 Programming Assignment 1 To make your life easier, we have provided the routine checking.check_gradients, which checks your gradients using nite di erences. You should make sure this check passes before continuing with the assignment. Once you've implemented the gradient computation, you'll need to train the model ...

  13. Programming Assignment #1 Solution

    This video presents my solution to programming assignment #1 from the POSA Concurrency MOOC.

  14. Programming Assignment Exp 1

    UNIT 4 - PROGRAMMING ASSIGNMENT A A1 - COMPUTATIONAL THINKING 'Computational thinking' is the term used to describe the use of computers to help us solve a problem.

  15. Programming Assignment: Assignment 1 Time Zones Solution

    Programming Assignment: Assignment 1 Time Zones. You first need to create a python file give name assignment1.py; Copy all the code paste in a file and then save it. Now upload your file on Coursera Course assignment and then click on submit. assignment1.py. def seconds_difference(time_1, time_2): """ (number, number) -> number

  16. RPubs

    [Programming Assignment 1] R Programming; by Anderson Hitoshi Uyekita; Last updated almost 2 years ago; Hide Comments (-) Share Hide Toolbars

  17. Programing Fundamental (Unit 1)

    Programming Assignment Unit 8; Programming Asm Unit 4; Unit 8 - Good work; Unit 8 Assignment; CS 1101-01 Programming assignment; Programming Assignment Unit 7; Related documents. Assignment Unit 1; CS1101-01 Week 7 Assignment; Learning journal unit 2; Discussion Forum Unit 6; CS1101-Unit01 discussion assigment;

  18. amanchadha/coursera-natural-language-processing-specialization

    Use dynamic programming, hidden Markov models, and word embeddings to autocorrect misspelled words, autocomplete partial sentences, and identify part-of-speech tags for words. Use dense and recurrent neural networks, LSTMs, GRUs, and Siamese networks in TensorFlow and Trax to perform advanced sentiment analysis, text generation, named entity ...

  19. Assignment 1 Programming

    Advanced programming assignment 1. Programming. Mandatory assignments. 100% (8) 19. Assignment Brief 1 - Unit 1 - Programing Course. Programming. Mandatory assignments. 100% (3) 11. A1 Unit 1 Programing - Chỉ đủ để pass môn các bạn có thể tham khảo. Programming. Mandatory assignments.

  20. amanchadha/coursera-deep-learning-specialization

    Notes, programming assignments and quizzes from all courses within the Coursera Deep Learning specialization offered by deeplearning.ai: (i) Neural Networks and Deep Learning; (ii) Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization; (iii) Structuring Machine Learning Projects; (iv) Convolutional Neural Networks; (v) Sequence Models - amanchadha/coursera-deep ...

  21. A Student's Journey: Unlocking Success with Numerical ...

    In the vast expanse of the internet, finding reliable numerical differentiation programming assignment help can feel like searching for a needle in a haystack. Faced with countless options, each promising unparalleled expertise, I tread cautiously, evaluating every contender with meticulous scrutiny. It was amidst this digital labyrinth that ...