Download presentation
Presentation is loading. Please wait.
Published byFrank McCormick Modified over 9 years ago
1
Variables, Input, and Output
2
Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try
3
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
4
Input Requires ● A question ● A variable to put answer in
5
Variable ● A place in memory to hold things ● Like a container ● Different containers for different stuff ● Has a name
6
Variables require: ● Name – descriptive ● Init – starting value ● Type – kind of data (string, numeric) ● Purpose – or description
7
String Data ● Text ● Series of alphanumeric characters ● Usually enclosed in quotes (“”) ● Size depends on length of text
8
Numeric Data ● Integer (+/-,0, no decimals) ● Long Integer ● Float (includes decimal values) ● Double ● Size depends on type of number
9
Challenge: ● Ask the user his or her name. ● Reply “Hello, ” Where is the user name. ● Username should be incorporated into greeting
10
Sample Run ● Comp: what is your name? ● User: Marsha ● Comp: Hi Marsha! ● Pause video and try
11
String Concatenation ● Technique for combining text ● “a” + “b” = “ab” ● Frequently uses the plus sign ● Can be used to combine variables and literals: ● “Hi, “ + userName + “!”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.