Variables, Input, and Output
Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try
Input ● Asks the user a question (input implies output!) ● Stores answer in a variable ● You can't use input if you haven't created the variable
Input Requires ● A question ● A variable to put answer in
Variable ● A place in memory to hold things ● Like a container ● Different containers for different stuff ● Has a name
Variables require: ● Name – descriptive ● Init – starting value ● Type – kind of data (string, numeric) ● Purpose – or description
String Data ● Text ● Series of alphanumeric characters ● Usually enclosed in quotes (“”) ● Size depends on length of text
Numeric Data ● Integer (+/-,0, no decimals) ● Long Integer ● Float (includes decimal values) ● Double ● Size depends on type of number
Challenge: ● Ask the user his or her name. ● Reply “Hello, ” Where is the user name. ● Username should be incorporated into greeting
Sample Run ● Comp: what is your name? ● User: Marsha ● Comp: Hi Marsha! ● Pause video and try
String Concatenation ● Technique for combining text ● “a” + “b” = “ab” ● Frequently uses the plus sign ● Can be used to combine variables and literals: ● “Hi, “ + userName + “!”