본문 바로가기

유데미79

Udemy : Python 딕셔너리 Udemy : Python 딕셔너리 딕셔너리 name = { "Alex" : 2; "Lisa" : 1; "Joon" : 1; } "Alex", "Lisa", "Joon" 은 key 2, 1, 1은 value들이다. 즉 key의 값들이다 딕셔너리는 key를 통해서 값을 가지고 올 수 있다 name["Alex"] 는 2로 출력된다 name = { "Alex" : 2, "Lisa" : 1, "Joon" : 1, } print(name["Alex"]) # 2 name["Yang"] = 5 print(name) # { # "Alex" : 2, # "Lisa" : 1, # "Joon" : 1, # "Yang" : 5, # } # Yang이 key로, 5가 Yang의 값으로 추가가 되었다 name["Joon"] = .. 2023. 1. 10.
Udemy : Python 매개변수와 Caesar Code Udemy : Python 매개변수와 Caesar Code 입력값을 받는 함수를 알게 될 것 Arguments 와 Parameters의 차이 입력 값이 있는 함수 # 그 전에 배웠던 함수 def greet(): print("Hello") print("Alex") greet() # 괄호에 아무것도 안 넣었다 def greet_with_name(name): print("Hello") print(name) greet_with_name('Alex') # greet_with_name() 안에 입력값을 넣어야 함수가 실행이 된다 # 그 입력값은 하나의 변수의 역할을 한다 # 괄호 안에 아무것도 없으면 argument가 없다고 에러 메세지가 뜬다 # TypeError: greet_with_name() missing .. 2023. 1. 9.
Udemy : Python 행맨 프로젝트 Udemy : Python 행맨 프로젝트 행맨은 알파벳을 입력하면서, 단어를 찾아내는 것이다. 알파벳을 고를 수 있는 차례는 주어져 있다 import random from hangman_art import logo, stages from hangman_words import word_list print(logo) word = random.choice(word_list) result = ["_"] * len(word) letter_choice = [] count = 6 flag = False while count != 0: letter = input("Guess a letter: ").lower() if letter.isalpha(): if letter in word: if letter not in let.. 2023. 1. 8.
Udemy : Python 함수와 카렐 Udemy : Python 함수와 카렐 Function function() - 앞에 function의 이름이 있고, 뒤에 괄호가 붙는다 왜 사용는건가? 지속적으로 똑같은 코드를 쓰기보단, 함수로 만들어서, 그 함수를 지속적으로 사용하면 된다 코드를 줄일 때, 유용하게 쓸 수 있다 function 만들기 def my_function() : print("My Function") print("Wow") my_function() # 함수 부르기 While Loop while something_is_true: #Do this #Then do this #Then do this while문은, 써 놓은 조건이 거짓일때까지, 지속적으로 코드를 실행하는 것이다 확실한 길이의 데이터가 주어지지 않을 때 while문을 사용.. 2023. 1. 7.
5.3_Javascript - Sliding Window 문제풀이 Udemy - Javascript - Sliding Window Sliding Window - maxSubarraySum Given an array of integers and a number, write a function called maxSubarraySum, which finds the maximum sum of a subarray with the length of the number passed to the function. Note that a subarray must consist of consecutive elements from the original array. In the first example below, [100, 200, 300] is a subarray of the origi.. 2023. 1. 7.
5.2_Javascript - Multiple Pointers 문제풀이 Udemy - Javascript - Multiple Pointers Multiple Pointers - averagePair Multiple Pointers - averagePair Write a function called averagePair. Given a sorted array of integers and a target average, determine if there is a pair of values in the array where the average of the pair equals the target average. There may be more than one pair that matches the average target. Bonus Constraints: Time: O(N).. 2023. 1. 7.
5.1_Javascript - Frequency Counter 문제풀이 Udemy - Javascript - Frequency Counter Frequency Counter Write a function called sameFrequency. Given two positive integers, find out if the two numbers have the same frequency of digits. Your solution MUST have the following complexities: Time: O(N) Sample Input: sameFrequency(182,281) // true sameFrequency(34,14) // false sameFrequency(3589578, 5879385) // true sameFrequency(22,222) // false s.. 2023. 1. 7.
Udemy : Python 반복문 Udemy : Python 반복문 For 문으로 평균 구하기 student_heights = input("Input a list of student heights ").split() for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) total_height = 0 student_num = 0 for height in student_heights: total_height += height student_num += 1 print(round(total_height / student_num)) sum() 과 len()을 사용하지 않고 구하기 total_height : 학생들의 키를 구하기 student_num.. 2023. 1. 6.
4_Udemy - Javascript 일반적인 문제풀이 패턴 Udemy - Javascript 일반적인 문제풀이 패턴 빈도수 세기 패턴 다중의 입력값들을 비교할 때 유용 배열을 이용하는 것이 아닌 / 주어진 입력값을 객체 ({}) 에 넣고, 문제를 해결하는 것이다 function anagram(word1, word2) { if (word1.length !== word2.length) { return false } else if (word1.length === 0 & word2.length === 0) { return true } let anagramObject1 = {} let anagramObject2 = {} for (let word = 0; word < word1.length ; word++) { if (word1[word] in anagramObject1).. 2023. 1. 6.