본문 바로가기
반응형

python8

Parameter/ Argument functions with inputs Parameter 와 Argument의 차이 def my_function(something) : def my_function(something) : #Do this with something #Then do this #Finally do this my_function(123) something = 123 ↓ ↓ parameter argument argument는 함수로 전달되고 호출되는 데이터를 의미하고 parameter는 그 데이터의 이름으로 함수 안에서 그 변수가 사용될 쓰인다. 즉, argument는 그 데이터의 실제 값 parameter는 함수에 전달된 데이터의 이름 2023. 11. 8.
[python]FizzBuzz 문제 풀기 Instructions You are going to write a program that automatically prints the solution to the FizzBuzz game. These are the rules of the FizzBuzz game: Your program should print each number from 1 to 100 in turn and include number 100. When the number is divisible by 3 then instead of printing the number it should print "Fizz". When the number is divisible by 5, then instead of printing the number .. 2023. 11. 2.
[Python] ADDING EVEN NUMBERS target 변수에 값을 무작위로 넣었을 때 그 값의 짝수로만 더해서 결과값 나오게 하기 내가 풀었던 방법은 new_num = 0 for num in range (target+1): if num %2 == 0: new_num += num print(new_num) 다른 방법들 even_sum = 0 for number in range(2, target + 1, 2): #시작하는 수 2, 범위값, 2씩 증가 even_sum += number print(even_sum) 2023. 11. 2.
[python]파이썬 for문 반복문 문제 1 학생들의 평균키 구하기 Example Input 1 156 178 165 171 187 In this case, student_heights would be a list that looks like: [156, 178, 165, 171, 187] Example Output 1 total height = 857 number of students = 5 average height = 171 Example Input 2 151 145 179 Example Output 2 total height = 475 number of students = 3 average height = 158 # Input a Python list of student heights student_heights = input()... 2023. 11. 1.
728x90
반응형