Python) Problems using For

First problem: Adding all numbers from 1 to the number it is typed(using For)

Second Problem: Making “*” in stair shape, the last row will have the same numbers of stars that you have typed

Python) For

When you use ‘for’, it will print out whatever you have written in the list or tuple.

The alphabet ‘i’ in the example could be anything

You can change it to anything else and it will work the same

Not just using ‘for’ to print out the element, you could use it and give ㅕㄴㄷ mathematical symbols into it

Python) while, break

When you repeat and get the output of the same sentence over and over to the point you set, you use ‘while’ rather than ‘if’

This example gets outputs of 1, 2 .. up to 9 because if a reach the number of 10, it stops since it is not smaller than 10 that I set for while

This shows that ‘while’ runs forever until python thinks it is false

__________________________________________________________________

Since python will loop over and over to when the statement is recognized as not true, thus there will be a situation when you want to stop the loop

There are several ways to stop the loop, like changing the statement, but the easy way is to use ‘break’

Python) If, else, elif

When the outcomes are different by different acts or different inputs, we use ‘if’ to set the right outcomes for each acting

Also use it to distinguish particular numbers into different categories, such as odd or even.

Python) Dictionary

There are two parts in dic(dictionary), key and value

when you set a dic, and type key, then python will automatically print the value

To type key and get value for output, you should create a blank dict and add key and values to dict and print it

Python) list, tuple

Both list and tuple are to make a group of some type of things:

Difference between two:

words or letters in the tuple are immutable

words or letters in the list are mutable

tuple doesn’t require parenthesis

_______________________________________________________

Could delete, add, or edit the things in the tuple or list:

Python) String

Everything that you write inside ‘’, or “”, those are all to be categorized into strings

Can declare string like numbers, and can add different strings to one like:

If you want to include a quotation mark or double-quotation mark, you can put a backslash(\) before ‘, or “

To change the line, you use \n:

Python) Number

There are two different types in number, which are integer, and floating-point

Integer: Using the whole number

Floating-point: Using the decimal number

You could declare numbers to alphabets and could calculate in python like:

Different mathematical expressions into python

^ = **

To find remainder = % Ex) 7 % 3 = 1

To find cocient = // Ex) 7 // 3 = 2 ashton