From a9e4befe282397c3567be761669e2545da19c729 Mon Sep 17 00:00:00 2001 From: Eric Douglas Date: Thu, 8 May 2014 21:38:43 -0300 Subject: [PATCH] add example.py 01.01.02 --- .../UNIT-01/02-core-elements-of-a-program/example.js | 11 +++++++++++ .../UNIT-01/02-core-elements-of-a-program/example.py | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.py diff --git a/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.js b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.js index e6b2bd8..9adec37 100644 --- a/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.js +++ b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.js @@ -1,3 +1,14 @@ x = 3; // Create variable and assign value 3 to it + x = x * x; // Bind x to value 9 + console.log( x ); // print the x's value + +process.stdout.write( 'Enter a number: ' ); // better way to print in the terminal +process.stdin.resume(); +// convert the entered value from stream into a string +// process.stdin.setEncoding( 'utf8' ); +process.stdin.on('data', function( inputText ) { + process.stdout.write( inputText.toString() ); + process.exit(); +}); diff --git a/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.py b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.py new file mode 100644 index 0000000..d27309f --- /dev/null +++ b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/02-core-elements-of-a-program/example.py @@ -0,0 +1,5 @@ +x = 3 # create variable x and assign value 3 to it +x = x * x # bind x to value 9 +print x +y = raw_input('enter a number:') +print type(y)