Sign in

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

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

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’

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.

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

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:

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:

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store