Python Programming Basics: Calculator and Turtle Graphics, Summaries of Computer Communication Systems

A step-by-step guide to creating a simple calculator and a turtle graphics program in python. It covers topics such as variables, data types, basic operations, input/output, and functions. The calculator program includes basic arithmetic operations, while the turtle graphics program allows users to draw shapes and lines using the mouse.

Typology: Summaries

2019/2020

Uploaded on 03/29/2024

suubit22
suubit22 🇰🇷

2 documents

1 / 32

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download Python Programming Basics: Calculator and Turtle Graphics and more Summaries Computer Communication Systems in PDF only on Docsity!

Section01 이 장에서 만들 프로그램

 [프로그램1] 간단 계산기

Section02 계산기 프로그램의 기본 기능 구현

 a=100은 a ← 100과 같은 개념  내부적으로는 a 와 b 그릇이 생겨 a 그릇에는 100 이, b 그릇에는 50 이 담긴 상태 → 프로그래밍 언어에서 그릇과 같은 역할을 하는 것이 바로 변수

Section02 계산기 프로그램의 기본 기능 구현

 a 그릇의 100 과 b 그릇의 50 을 합쳐 새로운 result 그릇에 들어간 상태가 됨  변수는 result에 값이 들어가더라도 a, b의 변수값이 그대로 남음

Section02 계산기 프로그램의 기본 기능 구현

Section03 계산기 프로그램 저장

Section03 계산기 프로그램 저장

 IDLE을 실행한 후 앞에서 입력한 나누기를 다시 실행

 메모리에 저장된 것은 IDLE을 종료하면 모두 사라져 오류 발생. 처음부터 다시 입력해야 함

 파이썬 코드는 하드디스크나 USB에 저장해 놓는 방법 사용

 이 책은 C 드라이브(C:) 바로 아래에

CookPython 폴더를 만들어 사용

Section03 계산기 프로그램 저장

 코드가 수십 줄인 경우는 스크립트 모드 사용(IDLE에서 [File]-[New File] 메뉴 선택)  메모장 같은 창인 스크립트 모드에서 코드를 여러 줄 입력 가능. 단, 실행은 되지 않음

Section03 계산기 프로그램 저장

 스크립트 모드에서 [Run]-[Run Module] 메뉴 선택(또는 [F5])  파이썬 코드를 파일 탐색기에서 바로 실행하는 방법은 교재 41 쪽의 [여기서 잠깐] 참고

Section03 계산기 프로그램 저장

 IDLE에서 [File]-[Open] 메뉴를 선택한 후 Code02-01.py 열기

Section03 계산기 프로그램 저장

Section04 계산기 프로그램 확장

 대화형 모드에서 [File]-[New File] 메뉴를 선택해 새 파일을 연 후 스크립트 모드에서 [File]- [Save] 메뉴를 선택해 C:\CookPython\Code02-02.py로 저장

Section04 계산기 프로그램 확장

 input( ) 함수를 사용해 정수로 변환

 오른쪽 예처럼 int() 함수를 사용해 정수로 변환  Code02-02.py의 1~2행을 다음과 같이 수정 후 다시 [F5]를 눌러 실행

Section04 계산기 프로그램 확장