1. Variable Nomenclature

Only Alphabet, numbers(*can't be the first place), _(underscore) can be Variable

Orange color's Keyword such as if, for, True, False, and, or, not etc., 

They has a special role, can't be Variable 

    if=30 (X)

    1st_score= 50 (x)

 

student_no = 10

student_name = "Charles" 

test_score1 = 90.4

test_score2 = 70.6

 

print("The student No.is :", student_no)

print("The name of the student is:", student_name)

print("The score for the 1st semester is:", test_score1)

print("The score for the 2nd semester is:", test_score2)

 

2. Data type 1

Data type(자료형)

                 a

            ================

 memory   l 10 l   l   l   l   l   l 

            ================

               p(a)

 

Like, there are many kinds of food.

Aren't there many types of bowls that fit that?

There are many kinds of data and memory space to hold it.

As long as you choose the food,

Python decides the bowl type for the food.

But at JAVA, you have to decide what kind of bowl to use.

 

1.Integer type(정수형)

ex)-13, 0, 6, 10, 44, 257

 

print(type(10))

#Read from right side. The data,10 -> What is the Type -> Print

print(type(-13))

      

i = 0 #Variable declaration

print(i)

print(type(i))

 

#Python is old grandpa, He supports binary, octal, hexadecimal numb

bin_numb = 0b10

print("0b10:", bin_numb)

oct_numb = 0o10

print("0o10:", oct_numb)

hex_numb = 0x10

print("0x10:", hex_numb)

 

#You can initilize decimal and print out to binary, octal, hexadecimal

print("2:", bin(2))

print("8", oct(8))

print("16:", hex(16))

#I was wondering in what kind of situation can use this grammar?

 

2. Float type(실수형)

f = 2.12

print(f)

print(type(f))

 

pi = 3.14159265

light_speed = 2.99e5(10 to the power of 5) * 1.0e3(10 to the power of 3) #299000000m/s  

print("pi is", pi, "!")

print("light speed is", light_speed, "m/s")

print(type(light_speed))

 

3.String(문자열)

something = 'Hello' #double quotation, quotation OK

print(type(something))

 

###Triple quotation for long sentence

long_sentence = """

What if...

What if we run away?

What if...

What if we left today?

What if we said goodbye to safe and sound?

What if...

What if we're hard to find?

What if...

What if we lost our minds?

What if we left them fall behind

And they're never found?

"""

print(long_sentence)

 

#Tip!

#You can type """(Multiple line of your code)"""

#Instead of typing tons of explanatory notes to not run the code

 

a = input("please type a number you like ")

print("The number you like is", type(a))

 

#a = input("type something")

#print(a * 5)

If you type 10, you can get 1010101010, not 50

Because the data type is string not int