본문 바로가기
728x90
반응형
SMALL

개념/혼자 공부하는 파이썬30

python) Student Class and Its Functionality class Student: def __init__(self,name,korean,math,english,science): self.name = name self.korean = korean self.math = math self.english = english self.science = science def get_sum(self): return self.korean + self.math + self.english + self.science def get_average(self): return self.get_sum() / 4 def __str__(self): return "{}\t{}\t{}".format(self.name, self.get_sum(), self.get_average()) student.. 2024. 12. 20.
python) Downloading and Saving Content from the Web with Python from urllib import request target = request.urlopen("http url") output = target.read() print(output) file = open("output.png", "wb") file.write(output) file.close() 1. **from urllib import request**: Imports the `request` submodule from Python's `urllib` module. `urllib` is a package that contains several modules for working with URLs, and `request` is specifically used for opening and reading U.. 2024. 11. 20.
python) __name__ method (Calculating Circumference and Area of a Circle in Python) A_0 PI = 3.141592 def number_input(): output = input("숫자 입력 : ") return float(output) def get_circumference(radius): return 2 * PI * radius def get_circle_area(radius): return PI * radius * radius print("get_circumference(10) : ", get_circumference(10)) print("get_circle_area(10) : ", get_circle_area(10)) 1. **PI = 3.141592**: This line defines a constant `PI` with the approximate value of pi (π.. 2024. 11. 19.
python) how to use the module package in python? A_0 PI = 3.141592 def number_input(): output = input("숫자 입력 : ") return float(output) def get_circumference(radius): return 2 * PI * radius def get_circle_area(radius): return PI * radius * radius 1. **PI = 3.141592**: Sets a constant named `PI` to an approximation of π, a mathematical constant that represents the ratio of a circle's circumference to its diameter. 2. **def number_input():** Defi.. 2024. 11. 18.
728x90
반응형
LIST