[Python] 기초 소스

2026. 5. 14. 12:37·Programming/Python

Python Study

1. Hello
프로그램의 기초 Hello 찍기 Print 명령어 사용

#Hello Print
hello = "Hello"
print(hello)
 
a = 'Python'
print(a*2) # 실행결과 PythonPython

 

2. 줄바꿈 없이 출력, Print 명령어 사용

# print hello world
print("hello", end='') #줄바꿈 없이 출력
print(" world")

 

3. if 문 공부

a 값이 1보다 크면 a 가 1보다 크다 표시

#if 문 공부 
a = 3
if a > 1:
    print('a > 1')

 

4. 출력문 기초

print 문의 활용 법

print("=" * 50)
print("My Program")
print("=" * 50)

 

5. 원면적 계산


반지름을 입력하면 원면적을 계산해주는 프로그램
import math 수학 라이브러리 사용

원면적 계산법 : math.pi (3.14) * 반지름 * 반지름

import math
 
print "-- 원 면적 계산 프로그램 --"
r = input(" 반지름 입력 : ")
 
cal = math.pi*r*r;    #r*r==r**2
print "반지름 : ",r,", 원면적 : ",cal

 

6. 삼각함수 구하기


상수를 입력하면 삼각함수를 구해주는 프로그램
import math 수학 라이브러리 사용
sin, cos, tan 삼각함수 사용

import math
print "-- 삼가함수 구하기 --"
degree = input(" 상수 입력 : ")
 
rad = math.pi * degree /180.0
 
print " sin : ",math.sin(rad)
print " cos : ",math.cos(rad)
print " tan : ",math.tan(rad)

 

7. BMI 계산기

print("-- BMI 계산기 --")
 
num1 = input("키를 입력하세요. : ")
num2 = input("몸무개를 입력하세요. : ")
 
key = int(num1) / 100 #m 환산된 키
weight = int(num2) #몸무개
 
key = key * key #bmi 식 의 키
bmi = weight / key
 
# bmi 결과 
if bmi <= 18.5:
  result = '저체중'
elif bmi > 18.5 and bmi <= 23:
  result = '정상'
elif bmi > 23 and bmi <= 25:
  result = '과체중'
elif bmi > 25 and bmi <= 30:
  result ='경도비만'
else:
  result = '중등비만'
 
# bmi 결과 출력
print("-- BMI 결과 :", result)

Python 기초 공부하면서 만든 소스들
github 에서 관리 합니다.

https://github.com/skshpapa80/python_study

'Programming > Python' 카테고리의 다른 글

Python Tkinter - GUI 라이브러리  (0) 2025.11.22
구글 드라이브에서 파이썬(Python) 사용하기 (Colab)  (0) 2025.11.19
[Python] 이미지/Exif Tag 정보 읽어오기  (0) 2025.11.17
Python 소개  (0) 2025.11.15
'Programming/Python' 카테고리의 다른 글
  • Python Tkinter - GUI 라이브러리
  • 구글 드라이브에서 파이썬(Python) 사용하기 (Colab)
  • [Python] 이미지/Exif Tag 정보 읽어오기
  • Python 소개
레이조(RayCho)
레이조(RayCho)
개발자 레이조(RayCho)의 블로그입니다. 똑똑하게 배우고 기록하는 공간
  • 레이조(RayCho)
    레이(Ray)의 개발이야기
    레이조(RayCho)
  • 전체
    오늘
    어제
    • 분류 전체보기 (54) N
      • Programming (54) N
        • Python (5)
        • Flutter (4)
        • Delphi (20) N
        • Lazarus (1)
        • C#.NET (6) N
        • ASP.NET (5)
        • Database (5)
        • Game Dev (0)
        • Web (5)
        • ETC (3)
      • Homebrew (0)
  • 블로그 메뉴

    • 홈
    • Introduce
    • 태그
    • 방명록
  • 링크

    • Naver Blog
    • Diary Blog
  • 공지사항

  • 인기 글

  • 태그

    iis
    개발환경
    기초
    Flutter
    소스코드
    delphi
    ASP.NET
    델파이
    웹프로그래밍
    Python
    VCL
    강좌
    Web
    문법
    C#
    프로그래밍
    JSON
    SQL
    mssql
    objectpascal
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.5
레이조(RayCho)
[Python] 기초 소스
상단으로

티스토리툴바