VNUHCM
Bài trước Bài kế tiếp
  • Nội dung học
  • Trợ giúp
    Bạn có thắc mắc khi đang học?
    Hướng dẫn cách học Những câu hỏi thường gặp Email cho giáo vụ
    • Tiếng Việt
    • English
    • Thông tin Thành viên
    • Khoá học đăng ký
    • Đăng xuất
  • Cohota
  • HƯỚNG DẪN HỌC TẬP

  • Xem chi tiết >>
    Bạn đã hoàn thành 0% khoá học
  • HƯỚNG DẪN SINH VIÊN ĐĂNG NHẬP HỆ THỐNG
    • Hướng dẫn đăng nhập
    • Hướng dẫn vào khóa học
  • Introduction
    • Welcome
  • Unit 1: Values
    • Introduction - Unit 1: Values
    • Get Started With Values
    • Play with Values
    • Playground Basics
    • Naming and Identifiers
    • Simulation
    • Strings
    • Constants and Variables
    • Word Games
    • Build a PhotoFrame App
    • Design for People
  • Episode 1: The TV Club
    • Introduction - Episode 1: The TV Club
    • Searching for Content
    • Sharing Personal Information
    • Ordering Online
    • Reflection: Episode 1
  • Unit 2: Algorithms
    • Introduction - Unit 2: Algorithms
    • Get Started with Algorithms
    • Play with Programs
    • Functions
    • Types
    • Parameters and Results
    • Making Decisions
    • BoogieBot
    • Data Visualization
    • Build a QuestionBot App
    • Design an Experience
  • Episode 2: The Viewing Party
    • Introduction - Episode 2: The Viewing Party
    • Accessing the Show
    • Streaming on the Network
    • Reflection: Episode 2
  • Unit 3: Organizing Data
    • Introduction - Unit 3: Organizing Data
    • Get Started with Organizing Data
    • Play with Complex Data
    • Instances, Methods, and Properties
    • Arrays and Loops
    • Structures
    • Enums and Switch
    • Testing Code
    • Processing Data
    • Pixel Art
    • Password Security
    • Visualization Revisited
    • Build a BouncyBall App
    • Design a Prototype
  • Episode 3: Sharing Photos
    • Introduction - Episode 3: Sharing Photos
    • Capturing Images
    • Posting on Social Media
    • Reflection: Episode 3
  • Unit 4: Building Apps
    • Introduction - Unit 4: Building Apps
    • Get Started with App Development
    • Play with App Components
    • Color Picker
    • ChatBot
    • Rock, Paper, Scissors
    • MemeMaker
    • Build an ElementQuiz App
    • Design for Impact
  • Appendix
    • Episode Technical Concepts
    • Glossary
Tổng quan điểm khóa học
Đánh giá

Tiến độ
Tên tiêu chí Trọng số (%) Điểm Tiến độ (%)
Unit 1: Values

Constants and Variables

Unit 1: Values|Play

What you'll build

  • A program to help you track scores of a game of darts.

What you'll learn

  • How to make values that are allowed to change over time.
  • When you might want values to be changeable and when you might want them to remain constant.

Key vocabulary

  • Constant
  • Immutable
  • Mutable
  • Variable

Introduction

When you use an app, you’re almost always changing something—for example, the score in a game, the text in a message, or the number of photos in your photo album.

In this lesson, you’ll learn how to create values that can change as your program runs. Changeable values allow you to build programs that can adjust to the shifting nature of real-life situations. You’ll also learn why it might be important to create values that will never change.

Go Build

Open the Constants and Variables.playground file in your course resources and follow the instructions.

Screenshot of the Variables playground

Reflection Questions

Look around the room you’re in.

Can you divide the things in the room into constants and variables? If you were in the same room tomorrow, or next week, what things would be the same and what will have changed?

Think of the rules of a sport or game. During the course of the game, what remains constant and what varies? Would the game be better if anything about it could change at any time, or do the constants make it a better game?

Think of an app you use and all of the information it holds to do its job. Can you divide the information into variables and constants?

Summary

Introducing variables makes your code more exciting and powerful, but it can also make unexpected things happen if you aren't careful.

Constants and variables are both useful tools, and it’s important to know when and where to use each one. You’ve started to think about how a program models a real-life situation, which aspects of that situation can change, and which should stay the same.

You’ll use all the programming concepts from this unit—and learn more—as you ​move through the course. But first, you'll take some time to get creative with the skills you've already learned.

Báo lỗi