. Objectifs
- Être capable de mettre en œuvre la balise <canvas>.
- Détails
- Écrit par : Richard GAUTHIER
- Clics : 4014
Lire la suite : Activité n°9 : Javascript et la balise "canvas" (2)
Term. S |
Activité n°8 : Découverte du langage Javascript |
ICN |
Noms : | ||
Matériel : | - un ordinateur; | |
Logiciel : | - Netbeans 8.2; - Utiliser le navigateur Google Chrome. |
|
Document : |
I. Objectifs
- Être capable de programmer en javascript.
- Détails
- Écrit par : Richard GAUTHIER
- Clics : 4476
Lire la suite : Activité n°8 : Découverte du langage Javascript (2)
Une boucle permet d'exécuter une portion de code plusieurs fois de suite.
L'instruction while
- Détails
- Écrit par : Richard GAUTHIER
- Clics : 5228
Mini-project description - "We want... a shrubbery!"
This mini-project is optional. Specifically, your grade on this mini-project will not count towards your final grade in this class. While this mini-project may appear silly, its purpose is important: learning how to submit and peer assess your Python mini-projects via Coursera. This mini-project is your chance to run through this process and learn how to avoid some of the simple mistakes that have plagued students in previous sessions of this class. We will walk you through each step of the process so that, next week when it is time for Rock-paper-scissors-lizard-Spock, you will understand the process completely.
The logistics of release, completion, submission and assessment of a mini-project
Before proceeding to the details of this mini-project, let's first review the general cycle of release, completion, submission and assessment of a mini-project. Here are the major steps:
- This mini-project description and its accompanying video describes the mini-project's requirements in detail. Each mini-project includes a detailed development process and an accompanying program template (a link to a CodeSkulptor file) that provides a good starting point for the project. Please use it.
- For subsequent mini-projects, the material for each mini-project also includes a page titled "Code Clinic Tips" page that includes common errors and hints. These items are based on observing 10+ sessions of students work though the associated mini-project.
- Once you have completed your mini-project, you can submit your mini-project by copying and pasting the CodeSkulptor URL for your code into the text box provided on the peer assessment page. (If you have trouble generating a CodeSkulptor URL, use the CodeSkulptor save service.)
- Once you have submitted the URL for your solution, Coursera will prompt your to assess the submissions of five of your peers. In particular, Coursera will provide you with the CodeSkulptor URLs for five of your classmate's mini-projects. Each week's mini-project has an associated grading rubric included in the assignment. You will use the pull down tabs at the bottom of the page to assign values for each rubric item to your peer's projects. As a matter of courtesy, please include a written comment if you decide not to give full score on an item. Remember that losing points with no feedback is very frustrating, so spend a little time, and explain what the problem was.
- Once you have assessed the work for five of your peers, your score for the assignment will be available. The score is the sum of the median of your peer's scores on each item of the grading rubric. Note that by taking the median of your peers' scores, any errors in grading by one of your peers will not affected your final grade.
The origins of Python
Python is a computer programming language that was conceived in the late 1980s by Guido van Rossum. Perhaps the most common beginner Python question is “Why would anyone name a computer language after a snake?” In fact, Python's name is derived from the television series Monty Python's Flying Circus. A common theme in the Python community is to make inside references to the television series when working with Python. Our initial mini-project honors this tradition.
Mini-project development process
Your task is simple: modify this program template to print
in the CodeSkulptor console. Your program should consist of a single line of Python. Before submitting your program, we suggest that you review the grading rubric given below.
Grading rubric — 4 pts total
Your peers will assess your mini-project according to the following rubric. Small deviations from the textual output described above, like an extra period (.) or space are fine. Whether moderate deviations, such as just printing "shrubbery", satisfy an item of the grading rubric is at your peers' discretion during their assessment. You should avoid large deviations such as printing a different Monty Python quote. Here is a breakdown of the scoring:
- 1 pt — A valid CodeSkulptor URL was submitted. No credit if the code is just pasted into the text box.
- 1 pt — Running the program does not throw an error.
- 1 pt — The program prints a message in the console.
- 1 pt — The program prints the desired message "We want... a shrubbery!".
- Détails
- Écrit par : Richard GAUTHIER
- Clics : 5425
Practice Exercises for Variables and Assignments
Solve each of the practice exercises below. Each problem includes three CodeSkulptor links: one for a template that you should use as a starting point for your solution, one to our solution to the exercise, and one to a tool that automatically checks your solution.
- Given a template that pre-defines a variable miles, write an assignment statement that defines a variable feetwhose value is the number of feet in miles miles. Miles to feet template --- Miles to feet solution --- Miles to feet (Checker)
- Given a template that pre-defines three variables hours, minutes and seconds, write an assignment statement that updates the variable total_seconds to have a value corresponding to the total number of seconds for hours hours, minutes minutes and seconds seconds. Hours to second template --- Hours to second solution ---Hours to second (Checker)
- Given a template that pre-defines the variables width and height that are the lengths of the sides of a rectangle, write an assignment statement that defines a variable perimeter whose value is the perimeter of the rectangle in inches. Perimeter of rectangle template --- Perimeter of rectangle solution --- Perimeter of rectangle (Checker)
- Given a template that pre-defines the variables width and height that are the lengths of the sides of a rectangle, write an assignment statement that defines a variable area whose value is the area of the rectangle in square inches. Area of rectangle template --- Area of rectangle solution --- Area of rectangle (Checker)
- Given a template that pre-defines the constant PI and the variable radius corresponding to the radius of a circle in inches, write an assignment statement that defines a variable circumference whose value is the circumference of a circle with radius radius in inches. Circumference of circle template --- Circumference of circle solution --- Circumference of circle (Checker)
- Given a template that pre-defines the constant PI and the variable radius corresponding to the radius of a circle in inches, write an assignment statement that defines a variable area whose value is the area of a circle with radius radius in square inches.Area of circle template --- Area of circle solution --- Area of circle (Checker)
- Given the pre-defined variables present_value, annual_rate and years, write an assignment statement that define a variable future_value whose value is present_value dollars invested at annual_rate percent interest, compounded annually for years years. Future value template --- Future value solution --- Future value (Checker)
- Give the pre-defined variables first_name and last_name, write an assignment statement that defines the variable name_tag whose value is the string "My name is % %." where the percents should be replaced by first_name and last_name. Note that, in Python, you can use the + operator on strings to concatenate (i.e. join) them together into a single string. Name tag template --- Name tag solution --- Name tag (Checker)
- Given the pre-defined variables name (a string) and age (a number), write an assignment statement that defines a variable statement whose value is the string "% is % years old." where the percents should be replaced by name and the string form of age. Name and age template --- Name and age solution --- Name and age (Checker)
- Given the variables x0, y0, x1, and y1, write an assignment statement that defines a variable distance whose values is the distance between the points (x0,y0) and (x1,y1). Point distance template --- Point distance solution --- Point distance (Checker)
- Challenge: Heron's formulastates the area of a triangle is s(s−a)(s−b)(s−c)−−−−−−−−−−−−−−−−−√ where a, b and c are the lengths of the sides of the triangle and s=12(a+b+c) is thesemi-perimeterof the triangle. Given the variables x0, y0, x1,y1, x2, and y2, write a Python program that computes a variable area whose value is the area of the triangle with vertices (x0,y0), (x1,y1) and (x2,y2). (Hint: our solution uses five assignment statements.) Triangle area template --- Triangle area solution --- Triangle area (Checker)
- Détails
- Écrit par : Richard GAUTHIER
- Clics : 7014