Programming with math procedures & constants | AP CSP (article) | Khan Academy (2024)

Want to join the conversation?

Log in

  • Mehul Tandon

    4 years agoPosted 4 years ago. Direct link to Mehul Tandon's post “For the first javascript ...”

    For the first javascript example, and the last pseudocode example, in the print/display statament, the actual expression was written. Can't you just write the variable name to print instead of the whole expression?

    (5 votes)

    • pamela ❤

      4 years agoPosted 4 years ago. Direct link to pamela ❤'s post “Ah, I was trying to show ...”

      Programming with math procedures & constants | AP CSP (article) | Khan Academy (4)

      From the author:Ah, I was trying to show that the results from calling procedures can be used in multiple ways, but it does indeed look like I'm just ignoring good practices by repeating the expression. I'll try to break that up into separate blocks!

      (13 votes)

  • mayakotek

    4 years agoPosted 4 years ago. Direct link to mayakotek's post “In the article, the funct...”

    In the article, the function explaining how to calculate an absolute is written like this:

    var abs1 = Math.abs(-5);
    println(Math.abs(-5));

    Can't it be written like this instead?
    var abs1 = Math.abs(-5);
    println(abs1);

    (5 votes)

  • London Brown

    a year agoPosted a year ago. Direct link to London Brown's post “What does num means and w...”

    What does num means and why do the computer provide it?

    (3 votes)

    • Abdelrahman

      a year agoPosted a year ago. Direct link to Abdelrahman's post “`num` is just the name of...”

      num is just the name of a parameter, which indicates that this function takes an input of type number

      (6 votes)

  • layaz7717

    4 years agoPosted 4 years ago. Direct link to layaz7717's post “In the program, why are a...”

    In the program, why are all the procedures repeated twice?

    (2 votes)

    • Shane McGookey

      4 years agoPosted 4 years ago. Direct link to Shane McGookey's post “If you are referring to r...”

      If you are referring to repetition such as:

      println("Math.abs(-32):");
      println(Math.abs(-32));

      Then it is important to understand that two different actions are happening here. In the first println statement, a string literal ("Math.abs(-32):") is being printed. In the second println statement, the Math.abs() function is actually being called to show the result of the function call.

      The purpose of doing it this way is to add clarity to the example. Without printing the string literal, you would simply see a succession of numbers, which may be unhelpful.

      (6 votes)

  • Sienna Hsu

    4 years agoPosted 4 years ago. Direct link to Sienna Hsu's post “Is it just me or the equi...”

    Is it just me or the equivalent Python code of Mathematical Procedures is linked to the wrong webpage?

    This is the correct link: https://repl.it/@PamelaFox1/MathematicalProcedures#main.py

    (3 votes)

  • vivekns007

    4 years agoPosted 4 years ago. Direct link to vivekns007's post “I don't see the ← symbol ...”

    I don't see the ← symbol on my keyboard.How can I type the pseudocode without that symbol?

    (2 votes)

    • Martin

      4 years agoPosted 4 years ago. Direct link to Martin's post “If you're on windows you ...”

      If you're on windows you can use alt keys
      For ← you type Alt and 27.
      If you're on linux you can use AltGr
      For ← you type AltGr and y

      (2 votes)

  • Maxter

    a year agoPosted a year ago. Direct link to Maxter's post “Does khan academy have th...”

    Does khan academy have the constant PHI?

    (2 votes)

  • Srinivas

    4 years agoPosted 4 years ago. Direct link to Srinivas's post “What does the abs1 mean i...”

    What does the abs1 mean in
    abs1 ← ABS(-5)
    DISPLAY( ABS(-5) )

    (1 vote)

    • Evan

      4 years agoPosted 4 years ago. Direct link to Evan's post “abs1 is simply the variab...”

      abs1 is simply the variable name. You could use whatever name you want, although you should use a name that reminds you of what it's used for.

      (2 votes)

  • Justin Ussery

    6 months agoPosted 6 months ago. Direct link to Justin Ussery's post “Quoted from above-"In Jav...”

    Quoted from above-"In JavaScript, we can use the built-in procedure Math.abs():
    var abs1 = Math.abs(-5);
    println(Math.abs(-5));"

    Aren't these the only ways to print in Javascript?
    Using the console.log() function
    Using the windows.alert() function
    Using the innerHTML property
    Using the document.write() function

    (0 votes)

  • Fredrick Nganga

    5 years agoPosted 5 years ago. Direct link to Fredrick Nganga's post “how do I command the para...”

    how do I command the parameter so as to see the result

    (0 votes)

    • Dzaka H. Athif

      4 years agoPosted 4 years ago. Direct link to Dzaka H. Athif's post “It depends, you can save ...”

      It depends, you can save the result first inside a variable, then display the value of the variable using println

      var absl = Math.abs(-10);
      println(absl);

      or you can just utilize a println procedure and directly write the operation

      println(Math.abs(-10));

      both ways output result
      10

      (1 vote)

Programming with math procedures & constants | AP CSP (article) | Khan Academy (2024)
Top Articles
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 5249

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.