본문 바로가기

분류 전체보기100

모두를 위한 프로그래밍 7주차 for 문을 이용하는 강의 파이썬은 복수형을 이해하지 못하기 때문에 아래 예시에서는 리스트 형으로 이해하여 오른쪽 처럼 출력하게 하게 된다 과제 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. En.. 2022. 1. 13.
모두를 위한 프로그래밍 6주차 <함수> 4.6 퀴즈 4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation. The function should return a value. Use 45 .. 2022. 1. 13.
모두를 위한 프로그래밍 5주차 노란 코드에서는 'Something else' 문장이 오렌지 코드에서는 'Below 10' 문장이 출력되지 않는다 이미 위 'Below 20' 문장이 사실 값이 되었기 때문 이러한 코드에서 계속해서 코드를 진행시키기 싶거나 혹은 traceback을 발생시키기 싫다면 ? try와 execpt 를 사용하면 된다. 첫 try 문장에선 정수 값이여서 firtst -1 로 결과가 나오고 두번째 try 문장에선 정수형이여서 제대로된 결과를 볼 수 있다. 일반적인 decision은 if를 사용하고 양뱡향의 decisions는 if - then - else를 동반함 try/execpt는 원하는 에러를 찾는데 사용된다고 생각하면 된다. 2022. 1. 12.
수학 식 계산 순서 너무나 당연하고 초등학교때 이미 다 배웠다 생각했기에 따로 생각해보지 않아 새롭게 안 사실 제곱을 계산할 때에는 우선 순위에서 두번째나 된다는 것 계산 순서는 다음과 같다 계산의 진행은 왼쪽에서 오른쪽 순서로 움직인다. 1. 괄호 2. 제곱 3. 곱하기,나누기 4. 덧셈 뺄셈 덧셈 뺄셈은 순서가 크게 의미가 없지만 곱셈과 나눗셈에서는 큰 의미가 있기 때문에 왼쪽에서 오른쪽으로 하는것이 우선적이란 것 2022. 1. 12.