FOP: User Input & Strings

Slides:



Advertisements
Similar presentations
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Advertisements

 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Python
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
C programming for Engineers Lcc compiler – a free C compiler available on the web. Some instructions.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
02/03/ Strings Left, Right and Trim. 202/03/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
CCSA 221 Programming in C INPUT AND OUTPUT OPERATIONS IN C – PART 1 1.
13/06/ Strings Left, Right and Trim. 213/06/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Chapter 4 Strings and Screen I/O. Objectives Define strings and literals. Explain classes and objects. Use the string class to store strings. Perform.
Lecture2.
CMSC201 Computer Science I for Majors Lecture 03 – Variables
FOP: Multi-Screen Apps
User Input ICS2O.
Unit 2 Technology Systems
Lesson 03: Variables and Types
More about comments Review Single Line Comments The # sign is for comments. A comment is a line of text that Python won’t try to run as code. Its just.
what is computer programming?
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
Chapter 6 JavaScript: Introduction to Scripting
Unit 5 Lesson 6: User Input and Strings
FOP: JavaScript Arrays(Lists)
1-1 Logic and Syntax A computer program is a solution to a problem.
Introduction to Event-Driven Programming
FOP: Buttons and Events
Learning Intention Learning Intention: To develop understanding of variables, data types, and comments in text based programming languages Context: Sequencing.
Lesson 5-2 AP Computer Science Principles
ICS103 Programming in C Lecture 3: Introduction to C (2)
Chapter 13 - JavaScript/JScript: Introduction to Scripting
IF statements.
Chapter 1. Introduction to Computers and Programming
Variables, Expressions, and IO
Introduction to Scripting
Explain what touch develop is to your students:
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Print slides for students reference
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Lesson 4: Controlling Memory with Variables
Introduction to CS Your First C Programs
Use proper case (ie Caps for the beginnings of words)
Lesson 16: Functions with Return Values
Lesson 6: User Input and Strings
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
An Introduction to Python
Coding Concepts (Data Structures)
Introduction to TouchDevelop
Announcements How’s it going? My internet/power supply?
Lesson 03: Variables and Types
Lecture3.
Introduction In today’s lesson we will look at: why Python?
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
User Input Keyboard input.
JavaScript: Introduction to Scripting
Unit 3: Variables in Java
Lesson 02: Introduction to Python
C Programming Language
L L Line CSE 420 Computer Games Lecture #3 Introduction to Python.
Web Programming and Design
ASCII and Unicode.
Presentation transcript:

FOP: User Input & Strings

Plan your own Mad Libs: Today we will be working on how to store user input and create lines of text using the information a user has provided. Pay attention to the App Lab version demonstration of this game The app should be a “how-to” Mad Libs (e.g., “How to take care of your pet ostrich”). Afterwards, you list steps with key components left open for user input. There should be at least 3 steps in their instructions. Their app should accept at least 3 pieces of user input. Plan out your app on your paper using a similar structure for the app lab game. You can change your ideas later in the lesson and be creative with this app.

Strings and the getText Command: Strings are a data type found inside of most programming languages. Strings are simply an arbitrary length sequence of ASCII characters. var name = “William”; Sometimes we want to grab text that a user has typed into our app. For this we need to use the getText command which will grab the text from UI Element you specify on the screen. Imagine you have a text input box which has the id “nameInput”. To grab the text from the text input box call the command below: getText(“nameInput”); // You can store the text you get inside a variable as so. var name = getText(“nameInput”);

String Concatenation: You can also create Strings that are made up of other variables. This is called concatenation. Look at the example below: var name = “William”; var age = 25; var message = “My name is “ + name + “ and I am “ + age + “ years old.” console.log(message); What will get printed out to the user is : My name is William and I am 25 years old. NOT: My name is name and I am age years old

String Capitalization: You can also convert any String into uppercase or lowercase by using the appropriate commands: str.toUpperCase(); str.toLowerCase(); Pay attention to the example below: var name = “William”; console.log(name.toUpperCase); name = name.toLowerCase(); console.log(name);

Newline \n: To create formatted text within Strings, you can use the new line symbol. Take a look at the example below: var message = “Step 1: Create the layout \nStep 2: Write the Code \nStep 3: Debug”; write(message); The output when calling write would look like so: Step1: Create the layout Step 2: Write the Code Step 3: Debug

Remember Local vs Global Variables: If you want to use variables that you’ve created on multiple screens, you should consider declaring those variables global. To do this simply create your variables in the beginning of your code outside of any function. You’ll probably want to do this for your Mad Libs Game