#### Loops in Swift Code | 循环 Xúnhuán

Hello everybody! Today in class we have learned 👩‍🏫 how to write loops 循环 (Xúnhuán) in Swift code 👩‍💻. We learned two kinds of loops ➰.

The first type of loop that we learned was a loop ➿ that repeats itself for a certain amount of times⏲. We learned 🏫 how to write this kind of loop in Swift code. Here’s an example.

for i in 1 … 4 {
moveForward()
turnRight()
moveForward()
turnLeft()
}

```for i in 1 ... 4 {
moveForward()
turnRight()
moveForward()
turnLeft()
}
```

Next we learned another loop ⭕ that repeats itself until the condition is false🙅‍♀️. This loop is called a while loop. Here’s an example.

while thereIsACoin {
moveForward()
collectCoin()
}

```while thereIsACoin {
moveForward()
collectCoin()
}```

In a while loop the loop will go forward ⏩ and collect the coin 💰 nonstop until the is no more coins ☹ in front of the coin collecter to collect. This is what we have accoplished today in class 👩‍🎓👨‍🎓.

We will learn much more very soon. Goodbye!!😃😃

In the meantime, please do your homework, and use the Swift documentation (aka “instructions”).

#### Learning Swift | 学习Swift

This weekend we started our first lesson on Swift. Swift is the language used by Apple across its products.

The class first tried using XCode, which is Apple’s IDE for Swift. But not every child is familiar with the Mac. So we switched to a learn Swift phone app, which worked well. But the class really love Swift Playground.  It is like Scratch to them.  The difference is that: we are going to make an app in two months using Swift.

The kids enjoyed programming a lot!  They didn’t want to stop.

The only minor issue is that it only works on iPads.

#### Credit and debt in the world | 信贷和债务 xìn dài hé zhài wù

This weekend’s financial math class started big: we looked at all the credit (money lend out as loans) or debt (money borrowed) from around the world.🌎🌏🌍

At any given moment, there are hundreds of trillions of debt or credit. You can “have a look” at All of the World’s Money and Markets in One Visualization from Visual Capitalist.  The information was from 2017, but you get the sense.

Debt (or credit) can be categorized in 4 groups: government, household💳, financial sector and non-financial companies.💰💶💴💷💵💸

We looked at the United States government debt in previous classes.   You can check the numbers from the Treasury Department.  The link is easy to remember too: treasurydirect.gov/NP/debt/current

You can get the numbers of other countries from IMF (International Monetary Fund), the World Bank, and some other organizations.

A company called Visual Capitalist summed up the government debts from all the countries, the number is \$63 Trillion!😲🤑

This means that the US government debt is one third of the world’s grand total government debt.🗽

#### Ipython Shell Keyboard shortcuts 键盘快捷键 （Kuàijié jiàn)

In this past weekend’s coding class we practice keyboard ⌨ shortcuts in the interactive Python shell (Ipython).

Since most of the students are learning typing ⌨, practicing these keyboard shortcuts actually help them learn typing by reinforcing memory of where the keys are.

The keyboard shortcuts allows you to minimize finger movements on the keyboard, which means you don’t even have to lift your hand ✋ for the “Backspace”, ‘Home’, ‘End’ or arrow keys (most of the time).    Spend 15 minutes per day practicing these.  Pretty soon, you will be a fast coder.

keystroke Action
`Ctrl-a` Move cursor to the beginning of the line
`Ctrl-e` Move cursor to the end of the line
`Ctrl-b` or the left arrow key Move cursor back one character
`Ctrl-f` or the right arrow key Move cursor forward one character

👦Text Entry

Keystroke Action
Backspace key Delete previous character in line
`Ctrl-d` Delete next character in line
`Ctrl-k` Cut text from cursor to end of line
`Ctrl-u` Cut text from beginning of line to cursor
`Ctrl-y` Yank (i.e. paste) text that was previously cut
`Ctrl-t` Transpose (i.e., switch) previous two characters

🐞Command History

Keystroke Action
`Ctrl-p` (or the up arrow key) Access previous command in history
`Ctrl-n` (or the down arrow key) Access next command in history
`Ctrl-r` Reverse-search through command history

🐳Miscellaneous

Keystroke Action
`Ctrl-l` Clear terminal screen
`Ctrl-c` Interrupt current Python command
`Ctrl-d` Exit IPython session

The shortcuts are referenced from  Python Data Science Handbook.   As its author Jake Vanderplas says, these shortcuts are not inherent in Ipython shell itself, but are based on GNU Readline library.

#### Mobile payments | 移动支付

This weekend’s financial math class is all about payments, in particular, mobile payments and mobile wallet💰.

Mobile wallet 移动钱包 are digital forms of wallet that people carry (or used to carry) in their pockets.  As we do not tend to carry large amounts of money in wallets, mobile wallets are convenient for small payments (as opposed to payments in larger businesses).

📳 They hold digital information about payments including credit and/or debit card, bank account, pre-paid card, virtual currency information, coupons and loyalty membership, and wallet holder identifications.📟

A mobile wallet is a software application (app) 💻that does the following:

• Secure enrollment of the holder (application download, identification)
• Securely store user information such as phone number, email address, and mailing address

The flow chart below summarizes the history of technology and events that evolve over the last eighty years.

In China and many places around the world 🌎, mobile payment is accounting for most of the retail payments.   So you should know about how it works.  Next class we will talk about the math that goes into making mobile payment secure.

#### Wealth distribution | 财富分配 💲

We went onto a journey of wealth discovery in this weekend’s math class.  We played with real world data from the Federal Reserve .

We spent the first five minutes just looking quietly at the chart below, and tried to understand its meaning.  Hint: read legends and labels.

The area chart shows the time series of total wealth of 4 buckets of US population.

The buckets are defined as 1st percentile, 90th – 99th percentile, 50th – 90th percentile, and the bottom 50% percentile of population by wealth.   In other words, if all the people in the US are ranked by wealth, the top 1%, and the top 90% to 99%, …, and the last 50%.

Source: Federal Reserve

The remainder of the class is discussion on what the chart means.

Kudos to Emily.  She was quick to point out that the red area of the chart is as thin as a line, and that’s all the wealth of the bottom 50% of Americans.

While the rest of the people are having more and more wealth overtime, the bottom 50% seem to have less and less, relative to the rest.

So is the world fair place?  No.

Some questions for the class to think about:

1. How to make the world more fair?
2.  Can the world be more fair?
3.  Should the world be more fair?
4.  What does fair mean?

#### Halloween 🎃 and holiday money spent | 万圣节及其他节日的花费

Today in class Emma asked how much money people spent on Halloween 🎃 every year.   So, the class went on doing research on this question.

Here are what the children have found out:

People spent about \$6.9 billion on Halloween each year. That’s a lot!

But why do people spent so much money on Halloween?!

💡The wisest answer among us may actually be children, whose uncluttered minds spoke the following super impressive and honest words (credit to Vickie, our little teacher and author):

If people didn’t spend so much money on Halloween, then we could use all that money to improve buildings, roads, the Navy, Army, Air Force etc.  Plus, why don’t the people save the money for retirement or to just to pay off their college student loan or mortgage.

Later in the class Jonathan asked how much do people spend on other holidays. We started making a list of Holidays and about how much dollars they spend each year.

• Halloween: 6.9 billion
• St.Patrick’s day: about 4.6 billion
• Valentines day: about 19.7 billion
• Mothers day: about 21.4 billion
• Fathers day: about 16 billion
• 4-Day Black Friday Weekend: 5.7 billion
• Christmas: 465 billion
• 4th of July: 6.7 billion

That’s a lot of money spent on holidays!!

💡Inspired by our class, we concluded that:

1. People 👫spend hundreds of billions of dollars on holidays.
2. They could have saved these money for improving important things for the country and community, or pay off their debts, or save for rainy day/retirement.

#### Use snippets to code faster | snippet 加速编程

Today’s weekend programming lesson we covered how to save code snippets in a code editor, such as Sublime Test 3 (ST) and Visual Studio Code (code).

🙂 You can save these chunks of code so next time you wouldn’t have to type it again.

Until NeuralLink or other developments that can help us bypass typing all together, we want to find ways to save ourselves time from typing code.   Using snippet is a must for children, who may not be great at typing.   Here is how to do it in Sublime Test 3 (ST) and Visual Studio Code (code).

😎Sublime Test:
Tools – > Developer -> New Snippet.

😎VS Code:
`Shift` + `Control` + `p`

😎 Shift + Control + F: to search for a string in your folder (perhaps the name of the snippet you saved).

💡Write the snippet that can be used by the code editor:

Snippets are json files. Use this ➡ web app, or some packages, or write json if you prefer to put the code into the json format.

Explaining .json snippet in VS Code:

• The first set of “” encloses the name of the snippet (call it anything you like).
• Prefix defines a prefix used in the IntelliSense drop down. For example, if you have a snippet for plotting, you may want to prefix it with “plot”.
• body is the snippet content.
• Note that: \$1, \$2 for tab stops
• Description is the description.  When you start typing the prefix of a snippet, its description will come up.

By the way, to quickly see what are the keyboard shortcuts are available in VS Code:

Ctrl + Shift + p

#### The White Lion🦁 | 白狮子

Today in class we talked about the story called “The White Lion”. The young👩 minds remember and tell that story so well.

The story is about a little white lion🦁.

The story began in a dark night where the white lion and his big brother were waiting for their mother to come back with dinner.  They were small cubs. The brother of the white lion went to see if their mother was close by.

But a snake bit his brother and ate him.  The little white lion ran as fast as he could from the snake.  He got lost so he just climbed a tree to rest in for the night.  Meanwhile in a village close by villagers were running out of food. The villagers sent a boy👦🏾 to go to the woods to look for food.
(more…)

error: Content is protected !!