반응형
반응형

TIOBE Index for August 2024

August Headline: Python is chasing Java's TIOBE index records

This month, Python has a ranking of more than 18% for the first time in its history. The last time a language hit more than 18% was Java in November 2016. Java is also the language with the highest ranking ever: 26.49% in June 2001. Runner up C++ is now exactly 8% behind Python, and that difference between position #1 and position #2 is also almost a record. The highest difference ever between position #1 and position #2 was in November 2016 when Java was 9.55% ahead of C. In summary, Python's hegemony is now undeniable. It is likely that it is Python's next step to become the most popular programming language ever. Is there any new language expected to come close to Python soon? Possible contenders Rust and Kotlin are approaching the TIOBE index top 10 fast, but it will take a lot of time before they become a real threat to Python. --Paul Jansen CEO TIOBE Software

The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular web sites Google, Amazon, Wikipedia, Bing and more than 20 others are used to calculate the ratings. It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

The index can be used to check whether your programming skills are still up to date or to make a strategic decision about what programming language should be adopted when starting to build a new software system. The definition of the TIOBE index can be found here.

 

 

https://www.tiobe.com/tiobe-index/

 

TIOBE Index - TIOBE

Home » TIOBE Index TIOBE Index for August 2024 August Headline: Python is chasing Java's TIOBE index records This month, Python has a ranking of more than 18% for the first time in its history. The last time a language hit more than 18% was Java in Novemb

www.tiobe.com

 

파이썬은 2024년 8월 티오베(Tiobe)의 프로그래밍 언어 인기 지수에서 역대 최고 평점인 18.04%를 기록했다. 이로써 파이썬은 2016년 11월 자바 이후 처음으로 18%에 도달한 언어가 됐다. 최고 기록은 자바가 2001년 6월에 세운 26.49%이다.

 

현재 파이썬은 2021년 10월에 처음으로 1위에 오르며 티오베 지수의 최상위 언어로 확고히 자리 잡았다. 티오베의 CEO 폴 얀센은 "파이썬의 상승은 주로 소프트웨어 엔지니어에 대한 수요가 많고 파이썬이 가장 배우기 쉬운 성숙한 범용 프로그래밍 언어이기 때문이다. 그래서 이 분야의 모든 초보자는 파이썬으로 시작한다"고 설명했다. 

2024년 8월 티오베 지수에서 파이썬은 10.04%의 2위 C++보다 8%나 앞서 있다. 3위와 4위는 C 언어와 자바로 각각 각각 9.17%와 9.16%를 기록했다. 지난달 13위로 역대 최고 순위를 기록했던 러스트 언어는 다시 14위로 하락했다. 얀센은 "러스트의 하락에 대해 걱정할 필요 없다. 다음 달에는 다시 상승할 것”이라고 예측했다.

티오베 지수의 공식 명칭은 '티오베 프로그래밍 커뮤니티 지수(Tiobe Programming Community Index)'로, 구글, 빙, 아마존, 위키피디아 등의 웹사이트를 통해 전 세계 숙련된 엔지니어수, 강좌, 서드파티 솔루션 업체 등을 기반으로 월간 지수를 산출해 인기를 평가한다.

2024년 8월 티오베 지수의 상위 10개 언어는 다음과 같다:

 

  • 파이썬 18.04%
  • C++ 10.04%
  • C 9.17%
  • 자바 9.16%
  • C# 6.39%
  • 자바스크립트 3.91%
  • SQL 2.21%
  • 비주얼 베이직 2.18%
  • 구글 고 2.03%
  • 포트란 1.79%

파이선은 8월 파이플 프로그래밍 언어 인기 지수(Pypl Popularity of Programming Language index)에서도 파이썬이 1위 언어 자리를 굳건히 지키고 있다. Pypl 지수는 구글에서 언어가 얼마나 자주 검색되는지 분석하여 인기도를 평가한다. 2024년 8월 파이플 지수의 상위 10개 언어는 다음과 같다.

 

  • 파이선 29.6%
  • 자바 15.51%
  • 자바스크립트 8.38%
  • C# 6.7%
  • C/C++ 6.31%
  • R 4.6%
  • PHP 4.35%
  • 타입스크립트 2.93%
  • 스위프트 2.76%
  • 러스트 2.58%
반응형
반응형

1. Creating a List

To conjure a list into being:

# A list of mystical elements
elements = ['Earth', 'Air', 'Fire', 'Water']

2. Appending to a List

To append a new element to the end of a list:

elements.append('Aether')

3. Inserting into a List

To insert an element at a specific position in the list:

# Insert 'Spirit' at index 1
elements.insert(1, 'Spirit')

4. Removing from a List

To remove an element by value from the list:

elements.remove('Earth')  # Removes the first occurrence of 'Earth'

5. Popping an Element from a List

To remove and return an element at a given index (default is the last item):

last_element = elements.pop()  # Removes and returns the last element

6. Finding the Index of an Element

To find the index of the first occurrence of an element:

index_of_air = elements.index('Air')

7. List Slicing

To slice a list, obtaining a sub-list:

# Get elements from index 1 to 3
sub_elements = elements[1:4]

8. List Comprehension

To create a new list by applying an expression to each element of an existing one:

# Create a new list with lengths of each element
lengths = [len(element) for element in elements]

9. Sorting a List

To sort a list in ascending order (in-place):

elements.sort()

10. Reversing a List

To reverse the elements of a list in-place:

elements.reverse()

 

 
반응형
반응형

 

1. Basic GET Request

To fetch data from an API endpoint using a GET request:

import requests
response = requests.get('https://api.example.com/data')
data = response.json()  # Assuming the response is JSON
print(data)

2. GET Request with Query Parameters

To send a GET request with query parameters:

import requests
params = {'key1': 'value1', 'key2': 'value2'}
response = requests.get('https://api.example.com/search', params=params)
data = response.json()
print(data)

3. Handling HTTP Errors

To handle possible HTTP errors gracefully:

import requests
response = requests.get('https://api.example.com/data')
try:
    response.raise_for_status()  # Raises an HTTPError if the status is 4xx, 5xx
    data = response.json()
    print(data)
except requests.exceptions.HTTPError as err:
    print(f'HTTP Error: {err}')

4. Setting Timeout for Requests

To set a timeout for API requests to avoid hanging indefinitely:

import requests
try:
    response = requests.get('https://api.example.com/data', timeout=5)  # Timeout in seconds
    data = response.json()
    print(data)
except requests.exceptions.Timeout:
    print('The request timed out')

5. Using Headers in Requests

To include headers in your request (e.g., for authorization):

import requests
headers = {'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
response = requests.get('https://api.example.com/protected', headers=headers)
data = response.json()
print(data)

6. POST Request with JSON Payload

To send data to an API endpoint using a POST request with a JSON payload:

import requests
payload = {'key1': 'value1', 'key2': 'value2'}
headers = {'Content-Type': 'application/json'}
response = requests.post('https://api.example.com/submit', json=payload, headers=headers)
print(response.json())

7. Handling Response Encoding

To handle the response encoding properly:

import requests
response = requests.get('https://api.example.com/data')
response.encoding = 'utf-8'  # Set encoding to match the expected response format
data = response.text
print(data)

8. Using Sessions with Requests

To use a session object for making multiple requests to the same host, which can improve performance:

import requests
with requests.Session() as session:
    session.headers.update({'Authorization': 'Bearer YOUR_ACCESS_TOKEN'})
    response = session.get('https://api.example.com/data')
    print(response.json())

9. Handling Redirects

To handle or disable redirects in requests:

import requests
response = requests.get('https://api.example.com/data', allow_redirects=False)
print(response.status_code)

10. Streaming Large Responses

To stream a large response to process it in chunks, rather than loading it all into memory:

import requests
response = requests.get('https://api.example.com/large-data', stream=True)
for chunk in response.iter_content(chunk_size=1024):
    process(chunk)  # Replace 'process' with your actual processing function

 

https://blog.stackademic.com/ultimate-python-cheat-sheet-practical-python-for-everyday-tasks-c267c1394ee8

반응형

'프로그래밍 > Python' 카테고리의 다른 글

[python] TIOBE Index for August 2024, Python 1st  (0) 2024.08.09
[python] Working With Lists  (0) 2024.07.24
[python] Working With Files  (0) 2024.07.24
[python] Pandas cheat sheet  (0) 2024.07.19
[python] 변수 scope, LEGB Rule  (0) 2024.07.15
반응형

1. Reading a File

To read the entire content of a file:

with open('example.txt', 'r') as file:
    content = file.read()
    print(content)

2. Writing to a File

To write text to a file, overwriting existing content:

with open('example.txt', 'w') as file:
    file.write('Hello, Python!')

3. Appending to a File

To add text to the end of an existing file:

with open('example.txt', 'a') as file:
    file.write('\nAppend this line.')

4. Reading Lines into a List

To read a file line by line into a list:

with open('example.txt', 'r') as file:
    lines = file.readlines()
    print(lines)

5. Iterating Over Each Line in a File

To process each line in a file:

with open('example.txt', 'r') as file:
    for line in file:
        print(line.strip())

6. Checking If a File Exists

To check if a file exists before performing file operations:

import os
if os.path.exists('example.txt'):
    print('File exists.')
else:
    print('File does not exist.')

7. Writing Lists to a File

To write each element of a list to a new line in a file:

lines = ['First line', 'Second line', 'Third line']
with open('example.txt', 'w') as file:
    for line in lines:
        file.write(f'{line}\n')

8. Using With Blocks for Multiple Files

To work with multiple files simultaneously using with blocks:

with open('source.txt', 'r') as source, open('destination.txt', 'w') as destination:
    content = source.read()
    destination.write(content)

9. Deleting a File

To safely delete a file if it exists:

import os
if os.path.exists('example.txt'):
    os.remove('example.txt')
    print('File deleted.')
else:
    print('File does not exist.')

10. Reading and Writing Binary Files

To read from and write to a file in binary mode (useful for images, videos, etc.):

# Reading a binary file
with open('image.jpg', 'rb') as file:
    content = file.read()
# Writing to a binary file
with open('copy.jpg', 'wb') as file:
    file.write(content)

https://blog.stackademic.com/ultimate-python-cheat-sheet-practical-python-for-everyday-tasks-c267c1394ee8

반응형

'프로그래밍 > Python' 카테고리의 다른 글

[python] Working With Lists  (0) 2024.07.24
[python] Working With Simple HTTP APIs  (0) 2024.07.24
[python] Pandas cheat sheet  (0) 2024.07.19
[python] 변수 scope, LEGB Rule  (0) 2024.07.15
[python] deepcopy  (0) 2024.07.04
반응형

Pandas는 데이터 분석, 조작 및 시각화를 위한 인기 있는 Python 라이브러리입니다. 구조화된 데이터와 구조화되지 않은 데이터를 포함하여 다양한 형식의 데이터를 쉽고 효과적으로 작업할 수 있는 풍부한 도구와 기능을 제공합니다. 이 문서에서는 Python에서 빠르고 효율적으로 데이터 분석을 수행하는 데 사용할 수 있는 일반적인 pandas 작업과 함수에 대한 치트시트를 제공합니다.

 

import pandas as pd

 

 

Pandas 라이브러리를 가져온 후에는 다음 작업과 함수를 사용하여 일반적인 데이터 분석 작업을 수행할 수 있습니다.

  • pd.read_csv(filename): CSV 파일에서 데이터를 로드합니다.
  • data.head(): 데이터 프레임의 처음 몇 행을 봅니다.
  • data.tail(): 데이터 프레임의 마지막 몇 행을 봅니다.
  • data.describe(): 숫자 열에 대한 요약 통계를 계산합니다.
  • data.info(): 데이터 프레임의 데이터 유형과 메모리 사용량을 확인합니다.
  • data.columns: 데이터 프레임의 열을 봅니다.
  • data['column']: 데이터 프레임의 열을 선택합니다.
  • data.loc[row_index]: 인덱스를 기준으로 데이터 프레임의 행을 선택합니다.
  • data.iloc[row_index]: 위치를 기준으로 데이터 프레임의 행을 선택합니다.
  • data.dropna(): 값이 누락된 행을 삭제합니다.
  • data.fillna(value): 누락된 값을 주어진 값으로 채웁니다.
  • data.rename(columns={'old': 'new'}): 데이터 프레임의 열 이름을 바꿉니다.
  • data.sort_values(by='column'): 열의 값을 기준으로 데이터 프레임을 정렬합니다.
  • data.groupby('column')['column'].mean(): 열의 값으로 데이터 프레임을 그룹화하고 다른 열의 평균을 계산합니다.
  • data.plot.hist(): 수치적 히스토그램을 그리다

반응형
반응형

LEGB Rule

  • 파이썬 변수 scope 룰을 LEGB 룰이라고 불리기도 합니다.
  • 변수가 값을 찾을 때, Local -> Enclosed -> Global -> Built-in
  • local - 가장 가까운 함수안 범위 입니다.
  • Enclosed - 파이썬은 함수 안에 함수가 정의 될수 있는데, 가장 가까운 함수가 아닌 두번째 이상의 함수 가까운 함수범위입니다.
  • Global - 함수 바깥의 변수 또는 import된 module
  • Built-in - 파이썬안에 내장되어 있는 함수 또는 속성들입니다.
>>> a = 5    # Global
>>> b = 10   # Global
>>> def outer():
...     a = 10  # outer함수의 local이며, inner함수의 Enclosed
...     def inner():
...             c=30 # inner 함수의 local
...             print(a, b, c)
...     inner()
...     a = 22  # outer함수의 local이며, inner함수의 Enclosed
...     inner()
... 
>>> outer()
10 10 30  
22 10 30
반응형

+ Recent posts