Memory GWC 1/22 JS & Python MatchingVersión en línea Many of the concepts we learned in Javascript, will carry over to Python! Of course Python is unique, with its own syntax, but can you recognize, & guess, some sim’s & diff’s btw the concepts? Ex. Recognize the print statement in JS, and try to match it to the print in Python, knowing they will look similar por Victoria Vassell def my_function(): print("Hello from a function") my_function() Javascript String: let text = "HELLO WORLD"; a = "Hello" # Comment on a single line Javascript Print: console.log("hello,world!"); Javascript String Concatenation: let displayText = 'Your ' + service + ' bill is due on ' + month + '.'; print(bool("Hello")) print(bool(15)) print ("hello, world!") Javascript if Statements: if (condition) { // block of code to be executed if the condition is true } +Additionx + y -Subtractionx - y *Multiplicationx * y /Divisionx / y %Modulusx % y Javascript: Use the error() method x = 4 # x is of type int x = "Sally" # x is now of type str print(x) Javascript While Loop: while (i < 10) { text += "The number is " + i; i++; } x = "Python is " y = "awesome" z = x + y print(z) Javascript Comments: // This line will denote a comment SyntaxError: invalid syntax Javascript Function: function name(parameter1, parameter2, parameter3) { // code to be executed } i = 1 while i < 6: print(i) i += 1 Javascript Comparison Operators: == equal to != not equal > greater than < less than >= less than or equal to Javascript Semicolon Rule: "Semicolon"; "after"; "every"; "line"; No semicolons needed to represent the end of a statement :) a = 33 b = 33 if b > a: print("b is greater than a") elif a == b: print("a and b are equal") Javascript For loop: for (let i = 0; i < 5; i++) { text += "The number is " + i + ""; } Javascript Operators: +Additionx + y -Subtractionx - y *Multiplicationx * y /Divisionx / y %Modulusx % y fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) Javascript Variables: var x = 5; var y = 6; var z = x + y; Javascript Booleans: let x = 0; Boolean(x); == equal to != not equal > greater than < less than >= less than or equal to