投稿

2月 21, 2021の投稿を表示しています

Generators

import random def lottery(): # returns 6 numbers between 1 and 40 for i in range(6): yield random.randint(1, 40) # returns a 7th number between 1 and 15 yield random.randint(1,15) # returns a 8th number between 100 and 120 yield random.randint(100,120) for random_number in lottery(): print("And the next number is... %d!" %(random_number)) ========= RESTART: C:/python/lottery20210222.py ======== And the next number is... 25! And the next number is... 25! And the next number is... 16! And the next number is... 38! And the next number is... 22! And the next number is... 4! And the next number is... 9! And the next number is... 115! >>>

About Interactive Tutorials(learnpython.org)

learnpython.org is a free interactive Python tutorial - one of the Interactive Tutorials websites. Interactive Tutorials is a personal project of mine aimed at making everyone in the world be able to learn how to code for free. The servers used to run the tutorials and the time invested in writing tutorials is funded through ads. The vision is to teach coding within the browser using short and effective exercises. By running actual code directly from the web browser, students are able to try out coding without installing and executing it locally, which can be hard and redundant for the purpose of learning how to code. This creates a more efficient learning process, because students focus on learning instead of setting up coding environments. This website and its content may be used freely and without charge, and it will always be free. source from here

pandas DataFrames Basic

Pandas is a high-level data manipulation tool developed by Wes McKinney. It is built on the Numpy package and its key data structure is called the DataFrame. DataFrames allow you to store and manipulate tabular data in rows of observations and columns of variables. There are several ways to create a DataFrame. One way way is to use a dictionary. For example: dict = {"country": ["Brazil", "Russia", "India", "China", "South Africa"], "capital": ["Brasilia", "Moscow", "New Dehli", "Beijing", "Pretoria"], "area": [8.516, 17.10, 3.286, 9.597, 1.221], "population": [200.4, 143.5, 1252, 1357, 52.98] } import pandas as pd print(dict) brics = pd.DataFrame(dict) print(brics) brics.index = ["BR", "RU", "IN", "CH", "SA"] print(brics) ===== RESTART: C:/python/PandasDataFrames...

pip list (Vostro 15 3000)

C:\Users\ooshi>python -m pip install --upgrade pip Requirement already satisfied: pip in c:\users\ooshi\appdata\local\programs\python\python39\lib\site-packages (21.0.1) C:\Users\ooshi>pip list Package Version ------------------------- --------- altgraph 0.17 cycler 0.10.0 et-xmlfile 1.0.1 future 0.18.2 jdcal 1.4.1 kiwisolver 1.3.1 matplotlib 3.3.3 numpy 1.19.4 openpyxl 3.0.5 panda3d 1.10.8 pandas 1.2.2 pefile 2019.4.18 Pillow 8.1.0 pip 21.0.2 pygame 2.0.1 pyinstaller 4.2 pyinstaller-hooks-contrib 2020.11 pyparsing 2.4.7 python-dateutil 2.8.1 pytz 2021.1 pywin32 300 pywin32-ctypes 0.2.0 reportlab ...