Python Daily I learned 1

Basic grammar

This means print hello world, it has to be surrounded with quotes.


This means put 2 into variable named a. 2 is an integer.

print(a+b) means add a and b a is 2, and b is 3, so the answer is 5


name = “Daniel” this means to put string Daniel to the variable name. You have to use quotes to write strings.

last_name = “Kim” You can’t put spaces in variable names.

print(name+last_name) This would come up with DanielKim because the name is Daniel, and the last name is Kim, so with you add them, it will get you DanielKim.

a = ‘2’

b = ‘two’

print(a+b) 2 in variable a is string because its surrounded with quotes, so it will get you 2two.

print(a+b) this will get you an error because in this case 2 in variable a is a integer because it isn’t surrounded with quotes.


hobbies = [‘coding’, ‘reading’, ‘youtube’] this is a list, list is a tools that use to describe several things in one variable and the order is very important. You must use square bracket to use list, and put comma after a item.

List sort

num = [5, 4, 2, 3, 1]

print(num.sort()) sort numbers in order.

print(num.sort(reverse=True)) sort numbers in reverse order.


append 6 to num.

List select

select first thing on num.


info = {‘name’:’Daniel’, ‘age’:12} this is a dictionary, dictionary is mostly about key:value, so in this code name, and age are keys, and Daniel, and 12 are values.

Dictionary add

add birthday(key) and put the value ‘09/17/2021’(value).

Dictionary select

Get ‘name’ = Daniel.


full_name = ‘Daniel Kim’

print(full_name[:6]) this is slicing, so I wanted to slice my first name, my first name has six words, so I will slice in 6th word =[:6] means first to 6. So it will get Daniel.


birthday = ‘09–17–2008’

print(birthday.split(‘-’)[0] this means to split by ‘-’ and [0] means to get first thing when it splitted, so it will be 09(computer counts from 0)


text = ‘abcdefg’

print(‘a’ in name) is a in text, it is true so we will get True.


text = ‘abcdefg’

print(len(text)) this is getting length of the text, so it would be 7.

Hello, I’m Daniel Kim. I write helpful tips about life.