프로그래밍/알고리즘
-
[파이썬][알고리즘] Palindrome(회문) 구현프로그래밍/알고리즘 2021. 1. 6. 00:07
기본 palindrome (6자리 이하만 구현하였습니다) while(1): char = input("input your message> ") times = len(char)//2 if times > 3: print("6자리 이하만 입력해주세요") elif times == 3: if char[0] == char[-1]: if char[1] == char[-2]: if char[2] == char[-3]: print(f"{char}은 palindrome 입니다!") elif times == 2: if char[0] == char[-1]: print(f"{char}은 palindrome 입니다!") elif times == 1: if char[0] == char[-1]: print(f"{char}은 palin..
-
[초보자를 위한 파이썬 300제] 011 - 020프로그래밍/알고리즘 2021. 1. 3. 14:56
# 11 # 클래스화 삼성전자 = 50000 class samsung: def calculate(times): return 삼성전자 * times def print(cost): print(cost) s1 = samsung stock = int(input("삼성전자 몇 주를 가지고 있나요?: ")) s1.print(f"총 평가금액은 {s1.calculate(stock)}원 입니다") # 12 시가총액 = 298000000000000 현재가 = 50000 PER = 15.79 # 13 s = "hello" t = "python" print(s+"!", t) # 14 print(2 + 2 * 3) # 답 : 8 # 15 a = "132" print(type(a)) # 16 num_str = "720" prin..