Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to...
-
Upload
frank-mccormick -
Category
Documents
-
view
215 -
download
0
Transcript of Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to...
![Page 1: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/1.jpg)
Variables, Input, and Output
![Page 2: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/2.jpg)
Challenge:
● Ask the user his or her name, and repeat that name to the user
● Pause video and try
![Page 3: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/3.jpg)
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
![Page 4: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/4.jpg)
Input Requires
● A question● A variable to put answer in
![Page 5: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/5.jpg)
Variable
● A place in memory to hold things
● Like a container● Different containers for different stuff
● Has a name
![Page 6: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/6.jpg)
Variables require:
● Name – descriptive● Init – starting value● Type – kind of data (string, numeric)
● Purpose – or description
![Page 7: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/7.jpg)
String Data● Text● Series of alphanumeric characters
● Usually enclosed in quotes (“”)
● Size depends on length of text
![Page 8: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/8.jpg)
Numeric Data● Integer (+/-,0, no decimals)● Long Integer● Float (includes decimal values)● Double● Size depends on type of number
![Page 9: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/9.jpg)
Challenge:● Ask the user his or her name.● Reply “Hello, <user>” Where <user> is the user name.
● Username should be incorporated into greeting
![Page 10: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/10.jpg)
Sample Run
● Comp: what is your name?
● User: Marsha● Comp: Hi Marsha!● Pause video and try
![Page 11: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/11.jpg)
String Concatenation● Technique for combining text● “a” + “b” = “ab”● Frequently uses the plus sign● Can be used to combine variables and literals:
● “Hi, “ + userName + “!”
![Page 12: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/12.jpg)
![Page 13: Variables, Input, and Output. Challenge: ● Ask the user his or her name, and repeat that name to the user ● Pause video and try.](https://reader036.fdocuments.in/reader036/viewer/2022082613/5697bff61a28abf838cbe0c1/html5/thumbnails/13.jpg)