Comp Sci study

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

2 steps to using functions in javascript

1. Define the function 2. Call it

Hexadeximal

A base-16 number system that uses sixteen distinct symbols 0-9 and A-F to represent numbers from 0 to 15.

Explain at least one reason why programming languages have functions. Include an example of something you did in this lesson that demonstrates the reason you describe.

A reason why programming languages have functions is to be able to share programmed code between programmers to find solutions for work. Functions also to make abstractions and efficient code. If functions weren't available the programmed code would be really confusing, and difficult to fix. Functions make the code more efficient and neater. An example is instead of righting turn left, turn left, turn left you just have to create and repeat the code by copying and pasting a function turn left into a function to turn right.

A programming environment

A tool where you write and run computer programs.

What is a function parameter? Para-meter: A measure of the distance between a function's conception and implementation. A way to give input to a function that controls how the function runs. A collection of commands that can be used in a programming language. Another name for the purpose of a function. A named memory location.

A way to give input to a function that controls how the function runs.

Parameter

An extra piece of information that you pass to the function to customize it for a specific need.

What is an API? Abstract Programming Inheritance - The idea that abstractions in languages get "passed down" in newer versions. Artificial Parameter Intelligence - The idea that function parameters should be intelligent enough to "know" what you want as a programmer. Application Program Interface - A well-documented library of functions provided in a programming language that helps to simplify complex programming tasks. Applied Power Implementation - A process by which functions are given extra override power related to parameters. Abstract Parameter Interface - A programming construct in which parameters are passed down through levels of abstraction.

Application Program Interface

Which of the following blocks is least similar to the others? A. moveTo (x,y) B. turnLeft (angle) C. arcRight (angle, radius) D. moveFoward (pixels)

B. turnLeft (angle)

Which of the following blocks is least similar to the others? A. penUp ( ) B. dot (radius) C. arcLeft (angle, radius) D. penWidth (width)

C. arcLeft (angle, radius)

Consider these various uses of randomNumber. Which one of the following is NOT a valid use of randomNumber Calling the parameters of the function Defining the parameters of a function Moving the turtle around the screen Orienting the direction of the turtle Setting pen properties None of the above

Defining the parameters of a function

Once you've taught a computer how to do a action once, you can make up your own name for that aciton

Easy to repeat later

In what ways is the meaning of "efficiency" the same? In what ways is it different?

Efficiency in a non-computer science environment means how fast you can do something, but efficiency in computer science how compact while still being precise so you can get a lower data storage. In the English language and in Computer Science to achieve efficiency you must be structured and organized.

Which of the following is NOT a true statement about functions? Functions are reusable programming abstractions. Functions help reduce the complexity of writing and maintaining programs. Functions help break a problem into logical chunks. Once defined, a function can be called many times from different parts of a program. Functions cannot make calls to other functions written by the same programmer.

Functions cannot make calls to other functions written by the same programmer.

"Abstraction" is often used to focus on a general case and ignore a specific instance of a problem. Given this meaning of the word, how are functions with parameters an example of abstraction?

Functions with parameters are an example of abstraction because parameters assume that the code for the parameter works and has proper placement as assumes the details of the function are respondent so that a parameter can work on specifying what the function will do.

Select the two true statements about functions with parameters: Parameters can only be used once within the body of a function. Functions with parameters can be used to prevent the creation of duplicated code. Parameters help generalize the solution of a specific problem. Values do not need to be provided to a function with parameters in any particular order.

Functions with parameters can be used to prevent the creation of duplicated code. Parameters help generalize the solution of a specific problem.

Define the Function

Giving a single name to a set of actions you want the computer ot prefeorm

Which of the following is NOT part of defining a function? Giving the function a name Identifying the parameters of the function Giving the parameters a value Adding code to the body of the function

Giving the parameters a value

Important Concepets

How do you define new commands, how to add your own words into a computer language

In computer science it can actually mean several different things depending on what you're talking about. Work on these challenges, try to solve them in a way that you think is best and we'll ask about efficiency at the end.

It is useful to learn how to solve and program solutions with a limited set of commands because using limited resources can expand your creativity and problem solve around any given computer science coding scenario. Learning how to work with the resources you are given will make a programmer more resourceful in the future and able to build on their mastered "simplistic" skills.

In the Create Performance Task, you will be asked to identify an abstraction in your program and explain how it helps manage the complexity of the program. Functions are a form of abstraction. Pick a function you wrote in your solution to the 3x3 square problem and explain how it helps manage the complexity of your program.

Me being able to assume that my function turnRight works and not have to worry about the small details is an absraction in my 3x3 square's code.

Choose the two (2) statements that are true about functions: Meaningful function names help people better understand programs. Meaningful function names help computers better understand programs. Functions in programming are useful mathematical tools for doing complex computations. Functions in programming are named groupings of programming instructions.

Meaningful function names help people better understand programs. Functions in programming are named groupings of programming instructions.

A procedure or function uses abstraction to solve problems

Once you have written a function or a procedure that you know works as intended, you can call the function as often as you wish, without worrying about the details or problems you had to solve to get it working.

Hundreds of different programming languages

That have been created for humans to communicate with computers.

Adding a Parameter to a function generalizes the functionality, so now the function is useful in an entire range of situations as opposed to being used for one particular instance.

The function is now more flexible and control without needing to create duplicate code.

It is said that functions with parameters generalize the behavior of a more specific command and allow programmers to use functions instead of duplicated code. Explain what this means to you using the difference between turnLeft() and turnLeft(angle) as an example.

The turnLeft (angel) is an example of a parameter which allows for a programmer to create a more efficent image by creating a specific amount of a degree the turtle should turn. If a function was just repeated code with turnLeft() would create a redundant, non-efficent code, which would just make a proggramer repeat themselves for less exact solutions.

Which of the following statements about writing functions and Top-Down Design is NOT true? Writing functions helps manage complexity in a program. Top-Down Design leads to programs which feature multiple layers of abstraction. Two programmers solving the same problem using Top-Down Design should arrive at identical programs. Top-Down Design relies upon identifying sub-problems of a larger problem. Top-Down Design assists in identifying the layers of functions that will be used to solve a programming problem.

Two programmers solving the same problem using Top-Down Design should arrive at identical programs.

Call it

Type the name of a function followed by ( ) This is telling the computer to perform or execute the set of actions you gave a name to.

Javascript

Used for interactive websites and mobile apps

Being able to write your own function with parameter is

Useful and powerful

Briefly describe how the code for drawing a rectangle would be different than drawing a square.

When coding for a square you just have to repeat the code many times, because all 4 side dimensions are equal, but when coding for a rectangle 2 side dimensions are equal and 2 other side dimensions are equal, so in a rectangle, the code must be longer and requires more thought.

Turtle Proggraming

a classic method for learning programming with commands to control movement and drawing of an on-screen robot called a "turtle". The turtle hearkens back to early implementations in which children programmed a physical robot whose dome-like shape was reminiscent of a turtle.

Library

a collection of commands / functions, typically with a shared purpose

API

a collection of commands made available to a programmer

Documentation

a description of the behavior of a command, function, library, API, etc.

Function

a named group of programming instructions. Functions are reusable abstractions that reduce the complexity of writing and maintaining programs

A parameter is

a named value that is provided as an input into the function.

Top Down Design

a problem solving approach (also known as stepwise design) in which you break down a system to gain insight into the sub-systems that make it up.

Abstraction

a simplified representation of something more complex. Abstractions allow you to hide details to help you manage complexity, focus on relevant concepts, and reason about problems at a higher level.

Function definition should be placed

at the end of the program

You can add more parameters and separate them by using

commas.

In defining a function to preform a certain task you have

essentially increased the capabilities of the programming language. You can use the function on its own or as a part of even more complex actions.

When you define your own command and give it a name it is called a

function

In java Script we call them

functions

Using parameters makes

functions more useful. Not a lot of options on how to draw drawings. Exact

Defining a function just

gives a name to a function

Parameters use abstraction by

identifying patterns, and by doing so you will realize that using parameters will let you define a single function with general behavior that can solve any instance of the problem with one piece of code. This is a powerful skill that removes the need for creating duplicated code and leads programs that are easier to read, write and maintain.

A progrmaing language

is a coding language that is used to dictate specific instructions to a computer.

when a function is called with a specific numerical number the "size" parameter

is replaced by the numerical value

By referencing a large and complex block of code by a single name

it makes it much easier understand what a program is doing by reading the code and also easier to locate and fix problems or errors.

Replace number value with "size" in order to properly use a

parameter

The generic term is

procedure

Language depends on

what you re trying to do, but all programming languages are equal in being able to express any algorithm


Ensembles d'études connexes

Chapter 9 ( Development Across the Lifespan)

View Set

3 - Medical Expense Insurance (Test only has 10 Questions)

View Set

RHIT Practice Exam: Chapter 5: Quality Management and Performance Improvement

View Set

Bone, Tissue and the Skeletal System Vocabulary

View Set

HEHI2 exam 4/final exam Spring 2017

View Set

CompTIA Network+ Certification Exam N10-007 Practice Test 1

View Set