컴퓨터 공학/Python(9)
-
Palindrome 팰린드롬 문제 풀이/코드잇
거꾸로 읽어도, 제대로 읽어도, 같은 값을 보여주는 값들을 팰린드롬이라고 부릅니다. 간단한 코드를 통해 Palindrome 이 아닌지 맞는지 확인해보는걸 만들 수가 있습니다 방법 1. def is_palindrome(word): # 여기에 코드를 작성하세요 reversed_word = word[::-1] # 단어를 뒤집음 if word == reversed_word: return True else: return False # 테스트 코드 print(is_palindrome("racecar")) print(is_palindrome("stars")) print(is_palindrome("토마토")) print(is_palindrome("kayak")) print(is_palindrome("hello")) 방..
2024.03.03 -
룬 알고리즘/Luhn Algorithm
Luhn Algorithm (youtube.com) 일단 나보다 설명을 잘하는 인도아저씨가 나타나 설명을 해주고 있어요 요약 1. Starting from the rightmost digit (the check digit), double the value of every second digit. 2. If doubling a digit results in a number greater than 9, subtract 9 from the product. 3. Sum up all the digits.If the total sum is divisible evenly by 10, then the number is valid according to the Luhn algorithm. 파이썬 코드 def verify..
2023.12.30 -
Python 코드를 작성하고 있습니다
여기서 작성한 코드를 몇개 비공개 처리 해야할거 같아요 ! 아무래도 과제를 워드 파일로 작성해서 공유하게 되는데, 거기서 표절 검사를 하는 프로그램에 온라인 데이타 베이스에 파일이 존재하냐 안하냐를 한번 더 확인하는 과정이 있거든요 ㅋㅋ;;; 나쁘지 않게 하고는 있습니다 . 내일은 에세이 작성에 힘을 줘야될거같아서 오늘은 여기까지! class Labotory: def __init__(self, name, number, origin): self.name = name self.number = number self.origin = origin def __str__(self): return f'My name is {self.name} and from {self.origin}' Labomen1 = Labotory..
2023.11.16 -
역시 코딩 초보자는 못말려
영어 에세이를 적는 원칙중에, 모든 글은 쉽게 쓰는 방법이 있으면 그렇게 써야한다 원칙이 있습니다. 코딩도 비슷한 원칙을 갖고있습니다. 어제 밤에 블로그 포스팅을 하고 오늘 아침에 내가 한 코드를 봤었는데요. 너무 부족한 부분이 많이 보여서 다시 수정을 했어요, 왜 당장 처음할때는 보이지 않았던 문제들이 이제와서 보이는건지 참 .... class Labotory: def __init__(self, name, Idnumber, origin): self.name = name self.number = Idnumber self.origin = origin def introduce(self): # Corrected method name from lntroduce to introduce print(f'My name..
2023.11.15 -
Python 기본으로 내가 좋아하는거 갖구 노는중
오늘 하루 2시간 동안 짠 건데 좀 많이 부족해 보이네요 살 좀 붙여야겠다 과제.. 인것도 있음, 내가 좋아하는 걸로 제출하면 그래도 동기부여가 꾸준히 될 줄 알고 하고 있는데 동기부여보다는 내가 사랑하는 것들을 하다커녕 그냥 마음만 아픈데요??? 처음 구조를 잡은 것 class World_line_alpha: def __init__(self, labomen, microwave, crt_tv, divergence_meter): self.labomen = labomen self.microwave = microwave self.crt_tv = crt_tv self.divergence_meter = divergence_meter def send_message(): def send_message_to_chang..
2023.11.14 -
Python Dictionary 와 Set 사용
amazon_data = [ {"id": 100, "is_prime": False, "monthly_spend": 800.0}, {"id": 101, "is_prime": True, "monthly_spend": 1500.0}, {"id": 102, "is_prime": False, "monthly_spend": 1000.0}, {"id": 103, "is_prime": True, "monthly_spend": 2350.0}, {"id": 104, "is_prime": False, "monthly_spend": 1100.0}, {"id": 105, "is_prime": True, "monthly_spend": 900.0}, {"id": 106, "is_prime": False, "monthly_spend..
2023.11.14