Day 1: Variables, Constants, and Basic Data Types

Day 1 Tutorial

Variables and constants

Use var when the value may change:

varname="Emily"name="Luoming"

Use let when the value will not change:

letschool="NYU"

When possible, use let because it makes the code safer.

Strings

A String stores text:

letproject="ASCII Leaf"

A multiline string uses three quotation marks:

letintroduction="""Hello!This is my project."""

Useful String functions:

print(project.count)print(project.uppercased())print(project.hasPrefix("ASCII"))

Integers

An Int stores a whole number:

letage=23varscore=10score+=5

Underscores can make large numbers easier to read:

letpopulation=8_000_000