리버싱 과정이 끝났고

다음 과정인 암호학과 웹 해킹

과정 진행을 위해

 

파이썬 숙달과정 시작

 

 

 


 

 

 

 제 01 장 파이썬 시작하기

 

(주의) 들여쓰기

 

파이썬 버전 확인

# python --version

 

파이썬 스타일 가이드

* PEP8

 

예약어

* if, while, for, ....

 

멀티 라인 문장으로

name = one + \

two + \

three

 

싱글 라인 문장으로

print('hello world') ; input()

 

주석처리

싱글 라인 주석: #

멀티 라인 주석: ''' ~ ''', """ ~ """

 

입출력 함수

입력 함수: input()

출력 함수: print()

 

[참고] 함수의 종류와 사용법 확인

>>> dir(str)

>>> help(join)

 

 

 

 

제 02 장 데이터 종류

 

수치형(Numeric Types) : int, float, complex

순서형(Sequence Types) : str, list, tuple, range

매핑형(Mapping Types) : dict

집합형(Set Types) : set

 

 

(1) 문자열(string)

특성:

* 인덱싱(indexing)

* 스라이싱(slicing)

* 연결 연산자(+)

* 반복 연산자(*)

* 요소의 변경 X

* 중복된 요소 가능

함수:

* count() - 문자열의 요소인 문자 개수 세기

* find(), index() - index 알아내기

* join(), split() - 조립해서 붙이기, 분리하기

* lower(), upper() - 소문자, 대문자 전환

* strip(), lstrip(), rstrip() - 공백 제거

* startswith(), endswith() - 시작하면, 끝나면

* len() - 요소 개수 세기

 

 

(2) 리스트(list)

특성:

* 인덱싱(indexing)

* 스라이싱(slicing)

* 연결 연산자(+)

* 반복 연산자(*)

* 요소의 변경 0

* 중복된 요소 가능

함수:

* append(), extend(), 연결연산자(+) - 리스트에 요소 추가하기

* sort(reverse=True), sorted(), reverse() - 정열하기, 역정열하기

* index() - 요소의 index 확인하기

* insert(), remove(), del 지시자, pop(), extend(), 연결연산자(+)

 

 


 

 

기본 문법 연습

menu = '''
1.Attack
2.run
3.skill
'''
print(menu)
choice=input('enter your number : ')
print(choice)

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

num = input("Enter Only number : ")
print(num)

if int(num) == 1:
    print("Pass")
else :
    print("fail")

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


name = 'banana'
print('k' + name[0:], end='\n\n')

if 'b' in name:
    print("yes")
else:
    print("no")


for i in name:
    print(i, end=' ')

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


name1 = "Lee"
name2 = "Choi"
a = 37
b = 38

print('%d' % a )
print('%s' % name1)

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


resp = input('Enter your choice [y|n] : ')
print(resp)

if resp.lower().startswith('y'):
    print('**YES**')
else:
    print('**no**')


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


string = "Step by step goes a long way."
print(string.replace("step", "STEP"))

Moon="""
My fellow Koreans, I am grateful to you all. I bow my head in deep appreciation for the choice of you‚ the people. Today‚ serving as President in the 19th presidential term of the Republic of Korea, I take the first step toward a new Korea. My shoulders are now burdened with heavy mandates entrusted to me by the people‚ and my heart is burning with enthusiasm to create the kind of country that we have never been able to live in before. My head is now filled with blueprints for ushering in a new world characterized by unity and coexistence.
"""
print(Moon.count('Korea'))
print(Moon.index('K'))

Moonlist=Moon.split(' ')
print(Moonlist)
print(' '.join(Moonlist))

print(Moon.replace('Korea', 'Corea'))


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


mystring = "hello world"
print("Mystring's length =", len(mystring))

my_resolution = '1920x1080'
print("width = ", my_resolution.split('x')[0])
print("height = ", my_resolution.split('x')[1])


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


companies = ['NAVER', 'KAKAO', 'SK', 'SAMSUNG']
print(':'.join(companies))

companies = '000660;060310;0133340;095570;068400;006840'
print(companies.split(';'))


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


code = '                     000660'
split=code.lstrip()
print(split)


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


domain = input('address : ')
domain1 = domain.split('/')[2]
print(domain.split('.')[-1])

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

a = input('filename : ')
print(a.split('.')[-1])

a = input("Path : ")
print(a.split('/')[-1])

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

input = [1,2,3]
output = []
output2 = []

for i in input:
    output.append(i * i)
    print(output)

output2 = [i * i for i in input]
print(output2)

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

nums = [1,2,3,4,5,6,7,8,9,10]

for i in nums:
    if i % 2 == 0:
        print(i ** 2)

print([i ** 2 for i in nums if i % 2 == 0])

================================================
728x90

+ Recent posts