ENG1060 Lecture 4: Week 4 Strings and Errors

46 views2 pages
String
Used%to%store%characters
AKA%"character%strings"%or%"char%array"
**single%quotes NOT%DOUBLE%QUOTES
Behave%like%vectors%>>>%can%access%using%(idx)
Can%be%concatenated%like%vectors
ASCII
Since%computers%only%understand%numbers,%letters/characters%are%stored%as%
numerical%representations
ASCII%values%will%be%used%for%calculations,%not%actual%numbers
Eg.%'0'%does%NOT%mean%zero.
To%check%data%type,%whos command
whos:
char =%character%string
double =%numerical%value
char() >>>% converts%integers%to%character%(via%ASCII%codes)
str2num() >>>%string%to%num
num2str() >>>%num%to%string
**%only%for%vectors,%cannot%for%input
**if%;%between%elements,%column.%If%no%;%between%elements,%row.
To%accept%strings%as%input:
A = input('Enter your name:','s')
Errors-(don't%ignore!)
Syntax
Run-time
Logic
Human
WHY%WE%NEED%ASCII
A:%computers%need%to%understand%numbers,%so%characters%
and%letters%need%to%be%represented%using%these%set%numbers.
Week$4:$Strings$and$Errors
Saturday,%12%August%2017
17:57
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents