monthly

GitHub All Languages Trending

The latest build: 2024-07-19Source of data: GitHubTrendingRSS

Programmer's guide about how to cook at home (Simplified Chinese only).


buildLicenseGitHub contributorsnpmMan hoursDocker

~

Web Docker

docker pull ghcr.io/anduin2017/how-to-cook:latestdocker run -d -p 5000:5000 ghcr.io/anduin2017/how-to-cook:latest

PDF /document.pdf

Pull request

:

The platform for building AI from enterprise data



MindsDB is the platform for building AI from enterprise data. You can create, serve, and fine-tune models in real-time from your database, vector store, and application data. Tweet

About us

MindsDB is the platform for building AI from enterprise data.

With MindsDB, you can deploy, serve, and fine-tune models in real-time, utilizing data from databases, vector stores, or applications, to build AI-powered apps - using universal tools developers already know.

MindsDB integrates with numerous data sources, including databases, vector stores, and applications, and popular AI/ML frameworks, including AutoML and LLMs. MindsDB connects data sources with AI/ML frameworks and automates routine workflows between them. By doing so, we bring data and AI together, enabling the intuitive implementation of customized AI systems.

Learn more about features and use cases of MindsDB here.

Get Started

To get started, install MindsDB locally via Docker or Docker Desktop, following the instructions in linked doc pages.

MindsDB enhances SQL syntax to enable seamless development and deployment of AI-powered applications. Furthermore, users can interact with MindsDB not only via SQL API but also via REST APIs, Python SDK, JavaScript SDK, and MongoDB-QL.

Solutions SQL Query Examples
Fine-Tuning FINETUNE mindsdb.hf_model FROM postgresql.table;
Knowledge Base CREATE KNOWLEDGE_BASE my_knowledge FROM (SELECT contents FROM drive.files);
Semantic Search SELECT * FROM rag_model WHERE question='What product is best for treating a cold?';
Real-Time Forecasting SELECT * FROM binance.trade_data WHERE symbol = 'BTCUSDT';
Agents CREATE AGENT my_agent USING model='chatbot_agent', skills = ['knowledge_base'];
Chatbots CREATE CHATBOT slack_bot USING database='slack',agent='customer_support';
Time Driven Automation CREATE JOB twitter_bot ( <sql_query1>, <sql_query2> ) START '2023-04-01 00:00:00';
Event Driven Automation CREATE TRIGGER data_updated ON mysql.customers_data (sql_code)

Examples

MindsDB enables you to deploy AI/ML models, send predictions to your application, and automate AI workflows.

Discover more tutorials and use cases here.

AI Workflow Automation

This category of use cases involves tasks that get data from a data source, pass it through an AI/ML model, and write the output to a data destination.

Common use cases are anomaly detection, data indexing/labeling/cleaning, and data transformation.

This example showcases the data enrichment flow, where input data comes from a PostgreSQL database and is passed through an OpenAI model to generate new content which is saved into a data destination.

We take customer reviews from a PostgreSQL database. Then, we deploy an OpenAI model that analyzes all customer reviews and assigns sentiment values. Finally, to automate the workflow for incoming customer reviews, we create a job that generates and saves AI output into a data destination.

-- Step 1. Connect a data source to MindsDBCREATE DATABASE data_sourceWITH ENGINE = "postgres",PARAMETERS = { "user": "demo_user", "password": "demo_password", "host": "samples.mindsdb.com", "port": "5432", "database": "demo", "schema": "demo_data"};SELECT *FROM data_source.amazon_reviews_job;-- Step 2. Deploy an AI modelCREATE ML_ENGINE openai_engineFROM openaiUSING openai_api_key = 'your-openai-api-key';CREATE MODEL sentiment_classifierPREDICT sentimentUSING engine = 'openai_engine', model_name = 'gpt-4', prompt_template = 'describe the sentiment of the reviewsstrictly as "positive", "neutral", or "negative"."I love the product":positive"It is a scam":negative"{{review}}.":';DESCRIBE sentiment_classifier;-- Step 3. Join input data with AI model to get AI outputSELECT input.review, output.sentimentFROM data_source.amazon_reviews_job AS inputJOIN sentiment_classifier AS output;-- Step 4. Automate this workflow to accomodate real-time and dynamic dataCREATE DATABASE data_destinationWITH ENGINE = "engine-name", -- choose the data source you want to connect to save AI outputPARAMETERS = { -- list of available data sources: https://docs.mindsdb.com/integrations/data-overview "key": "value",...};CREATE JOB ai_automation_flow (INSERT INTO data_destination.ai_output (SELECT input.created_at, input.product_name, input.review, output.sentimentFROM data_source.amazon_reviews_job AS inputJOIN sentiment_classifier AS outputWHERE input.created_at > LAST););

AI System Deployment

This category of use cases involves creating AI systems composed of multiple connected parts, including various AI/ML models and data sources, and exposing such AI systems via APIs.

Common use cases are agents and assistants, recommender systems, forecasting systems, and semantic search.

This example showcases AI agents, a feature developed by MindsDB. AI agents can be assigned certain skills, including text-to-SQL skills and knowledge bases. Skills provide an AI agent with input data that can be in the form of a database, a file, or a website.

We create a text-to-SQL skill based on the car sales dataset and deploy a conversational model, which are both components of an agent. Then, we create an agent and assign this skill and this model to it. This agent can be queried to ask questions about data stored in assigned skills.

-- Step 1. Connect a data source to MindsDBCREATE DATABASE data_sourceWITH ENGINE = "postgres",PARAMETERS = { "user": "demo_user", "password": "demo_password", "host": "samples.mindsdb.com", "port": "5432", "database": "demo", "schema": "demo_data"};SELECT *FROM data_source.car_sales;-- Step 2. Create a skillCREATE SKILL my_skillUSING type = 'text2sql', database = 'data_source', tables = ['car_sales'], description = 'car sales data of different car types';SHOW SKILLS;-- Step 3. Deploy a conversational modelCREATE ML_ENGINE langchain_engineFROM langchainUSING openai_api_key = 'your openai-api-key'; CREATE MODEL my_conv_modelPREDICT answerUSING engine = 'langchain_engine', model_name = 'gpt-4', mode = 'conversational', user_column = 'question' , assistant_column = 'answer', max_tokens = 100, temperature = 0, verbose = True, prompt_template = 'Answer the user input in a helpful way';DESCRIBE my_conv_model;-- Step 4. Create an agentCREATE AGENT my_agentUSING model = 'my_conv_model', skills = ['my_skill'];SHOW AGENTS;-- Step 5. Query an agentSELECT *FROM my_agentWHERE question = 'what is the average price of cars from 2018?';SELECT *FROM my_agentWHERE question = 'what is the max mileage of cars from 2017?';SELECT *FROM my_agentWHERE question = 'what percentage of sold cars (from 2016) are automatic/semi-automatic/manual cars?';SELECT *FROM my_agentWHERE question = 'is petrol or diesel more common for cars from 2019?';SELECT *FROM my_agentWHERE question = 'what is the most commonly sold model?';

Agents are accessible via API endpoints.

Contribute

If youd like to contribute to MindsDB, install MindsDB for development following this instruction.

Youll find the contribution guide here.

We are always open to suggestions, so feel free to open new issues with your ideas, and we can guide you!

This project is released with a Contributor Code of Conduct. By participating in this project, you agree to follow its terms.

Also, check out the rewards and community programs here.

Support

If you find a bug, please submit an issue on GitHub here.

Here is how you can get community support:

If you need commercial support, please contact the MindsDB team.

Current contributors

Made with contributors-img.

Subscribe to updates

Join our Slack community and subscribe to the monthly Developer Newsletter to get product updates, information about MindsDB events and contests, and useful content, like tutorials.

License

For detailed licensing information, please refer to the LICENSE file.

30 days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than100 days, follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw


30 Days Of Python

# DayTopics
01Introduction
02Variables, Built-in Functions
03Operators
04Strings
05Lists
06Tuples
07Sets
08Dictionaries
09Conditionals
10Loops
11Functions
12Modules
13List Comprehension
14Higher Order Functions
15Python Type Errors
16Python Date time
17Exception Handling
18Regular Expressions
19File Handling
20Python Package Manager
21Classes and Objects
22Web Scraping
23Virtual Environment
24Statistics
25Pandas
26Python web
27Python with MongoDB
28API
29Building API
30Conclusions

HAPPY CODING

Support the author to create more educational materials
Paypal Logo

30 Days Of Python: Day 1 - Introduction

Twitter Follow

Author: Asabeneh Yetayeh
Second Edition: July, 2021

Portuguese

Day 2 >>

30DaysOfPython

Day 1

Welcome

Congratulations for deciding to participate in a 30 days of Python programming challenge . In this challenge you will learn everything you need to be a python programmer and the whole concept of programming. In the end of the challenge you will get a 30DaysOfPython programming challenge certificate.

If you would like to actively engage in the challenge, you may join the 30DaysOfPython challenge telegram group.

Introduction

Python is a high-level programming language for general-purpose programming. It is an open source, interpreted, objected-oriented programming language. Python was created by a Dutch programmer, Guido van Rossum. The name of Python programming language was derived from a British sketch comedy series, Monty Python's Flying Circus. The first version was released on February 20, 1991. This 30 days of Python challenge will help you learn the latest version of Python, Python 3 step by step. The topics are broken down into 30 days, where each day contains several topics with easy-to-understand explanations, real-world examples, many hands on exercises and projects.

This challenge is designed for beginners and professionals who want to learn python programming language. It may take 30 to 100 days to complete the challenge, people who actively participate on the telegram group have a high probability of completing the challenge.

This challenge is easy to read, written in conversational English, engaging, motivating and at the same time, it is very demanding. You need to allocate much time to finish this challenge. If you are a visual learner, you may get the video lesson on Washera YouTube channel. You may start from Python for Absolute Beginners video. Subscribe the channel, comment and ask questions on YouTube vidoes and be proactive, the author will eventually notice you.

The author likes to hear your opinion about the challenge, share the author by expressing your thoughts about the 30DaysOfPython challenge. You can leave your testimonial on this link

Why Python ?

It is a programming language which is very close to human language and because of that it is easy to learn and use. Python is used by various industries and companies (including Google). It has been used to develop web applications, desktop applications, system adminstration, and machine learning libraries. Python is highly embraced language in the data science and machine learning community. I hope this is enough to convince you to start learning Python. Python is eating the world and you are killing it before it eats you.

Environment Setup

Installing Python

To run a python script you need to install python. Let's download python. If your are a windows user. Click the button encircled in red.

installing on Windows

If you are a macOS user. Click the button encircled in red.

installing on Windows

To check if python is installed write the following command on your device terminal.

python --version

Python Version

As you can see from the terminal, I am using Python 3.7.5 version at the moment. Your version of Python might be different from mine by but it should be 3.6 or above. If you mange to see the python version, well done. Python has been installed on your machine. Continue to the next section.

Python Shell

Python is an interpreted scripting language, so it does not need to be compiled. It means it executes the code line by line. Python comes with a Python Shell (Python Interactive Shell). It is used to execute a single python command and get the result.

Python Shell waits for the Python code from the user. When you enter the code, it interprets the code and shows the result in the next line. Open your terminal or command prompt(cmd) and write:

python

Python Scripting Shell

The Python interactive shell is opened and it is waiting for you to write Python code(Python script). You will write your Python script next to this symbol >>> and then click Enter. Let us write our very first script on the Python scripting shell.

Python script on Python shell

Well done, you wrote your first Python script on Python interactive shell. How do we close the Python interactive shell ? To close the shell, next to this symbol >> write exit() command and press Enter.

Exit from python shell

Now, you know how to open the Python interactive shell and how to exit from it.

Python will give you results if you write scripts that Python understands, if not it returns errors. Let's make a deliberate mistake and see what Python will return.

Invalid Syntax Error

As you can see from the returned error, Python is so clever that it knows the mistake we made and which was Syntax Error: invalid syntax. Using x as multiplication in Python is a syntax error because (x) is not a valid syntax in Python. Instead of (x) we use asterisk (*) for multiplication. The returned error clearly shows what to fix.

The process of identifying and removing errors from a program is called debugging. Let us debug it by putting * in place of x.

Fixing Syntax Error

Our bug was fixed, the code ran and we got a result we were expecting. As a programmer you will see such kind of errors on daily basis. It is good to know how to debug. To be good at debugging you should understand what kind of errors you are facing. Some of the Python errors you may encounter are SyntaxError, IndexError, NameError, ModuleNotFoundError, KeyError, ImportError, AttributeError, TypeError, ValueError, ZeroDivisionError etc. We will see more about different Python error types in later sections.

Let us practice more how to use Python interactive shell. Go to your terminal or command prompt and write the word python.

Python Scripting Shell

The Python interactive shell is opened. Let us do some basic mathematical operations (addition, subtraction, multiplication, division, modulus, exponential).

Let us do some maths first before we write any Python code:

  • 2 + 3 is 5
  • 3 - 2 is 1
  • 3 * 2 is 6
  • 3 / 2 is 1.5
  • 3 ** 2 is the same as 3 * 3

In python we have the following additional operations:

  • 3 % 2 = 1 => which means finding the remainder
  • 3 // 2 = 1 => which means removing the remainder

Let us change the above mathematical expressions to Python code. The Python shell has been opened and let us write a comment at the very beginning of the shell.

A comment is a part of the code which is not executed by python. So we can leave some text in our code to make our code more readable. Python does not run the comment part. A comment in python starts with hash(#) symbol. This is how you write a comment in python

 # comment starts with hash # this is a python comment, because it starts with a (#) symbol

Maths on python shell

Before we move on to the next section, let us practice more on the Python interactive shell. Close the opened shell by writing exit() on the shell and open it again and let us practice how to write text on the Python shell.

Writing String on python shell

Installing Visual Studio Code

The Python interactive shell is good to try and test small script codes but it will not be for a big project. In real work environment, developers use different code editors to write codes. In this 30 days of Python programming challenge we will use visual studio code. Visual studio code is a very popular open source text editor. I am a fan of vscode and I would recommend to download visual studio code, but if you are in favor of other editors, feel free to follow with what you have.

Visual Studio Code

If you installed visual studio code, let us see how to use it. If you prefer a video, you can follow this Visual Studio Code for Python Video tutorial

How to use visual studio code

Open the visual studio code by double clicking the visual studio icon. When you open it you will get this kind of interface. Try to interact with the labeled icons.

Visual studio Code

Create a folder named 30DaysOfPython on your desktop. Then open it using visual studio code.

Opening Project on Visual studio

Opening a project

After opening it you will see shortcuts for creating files and folders inside of 30DaysOfPython project's directory. As you can see below, I have created the very first file, helloworld.py. You can do the same.

Creating a python file

After a long day of coding, you want to close your code editor, right? This is how you will close the opened project.

Closing project

Congratulations, you have finished setting up the development environment. Let us start coding.

Basic Python

Python Syntax

A Python script can be written in Python interactive shell or in the code editor. A Python file has an extension .py.

Python Indentation

An indentation is a white space in a text. Indentation in many languages is used to increase code readability, however Python uses indentation to create block of codes. In other programming languages curly brackets are used to create blocks of codes instead of indentation. One of the common bugs when writing python code is wrong indentation.

Indentation Error

Comments

Comments are very important to make the code more readable and to leave remarks in our code. Python does not run comment parts of our code. Any text starting with hash(#) in Python is a comment.

Example: Single Line Comment

 # This is the first comment # This is the second comment # Python is eating the world

Example: Multiline Comment

Triple quote can be used for multiline comment if it is not assigned to a variable

"""This is multiline commentmultiline comment takes multiple lines.python is eating the world"""

Data types

In Python there are several types of data types. Let us get started with the most common ones. Different data types will be covered in detail in other sections. For the time being, let us just go through the different data types and get familiar with them. You do not have to have a clear understanding now.

Number

  • Integer: Integer(negative, zero and positive) numbers Example: ... -3, -2, -1, 0, 1, 2, 3 ...
  • Float: Decimal number Example ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ...
  • Complex Example 1 + j, 2 + 4j

String

A collection of one or more characters under a single or double quote. If a string is more than one sentence then we use a triple quote.

Example:

'Asabeneh''Finland''Python''I love teaching''I hope you are enjoying the first day of 30DaysOfPython Challenge'

Booleans

A boolean data type is either a True or False value. T and F should be always uppercase.

Example:

 True # Is the light on? If it is on, then the value is True False # Is the light on? If it is off, then the value is False

List

Python list is an ordered collection which allows to store different data type items. A list is similar to an array in JavaScript.

Example:

[0, 1, 2, 3, 4, 5] # all are the same data types - a list of numbers['Banana', 'Orange', 'Mango', 'Avocado'] # all the same data types - a list of strings (fruits)['Finland','Estonia', 'Sweden','Norway'] # all the same data types - a list of strings (countries)['Banana', 10, False, 9.81] # different data types in the list - string, integer, boolean and float

Dictionary

A Python dictionary object is an unordered collection of data in a key value pair format.

Example:

{'first_name':'Asabeneh','last_name':'Yetayeh','country':'Finland', 'age':250, 'is_married':True,'skills':['JS', 'React', 'Node', 'Python']}

Tuple

A tuple is an ordered collection of different data types like list but tuples can not be modified once they are created. They are immutable.

Example:

('Asabeneh', 'Pawel', 'Brook', 'Abraham', 'Lidiya') # Names
('Earth', 'Jupiter', 'Neptune', 'Mars', 'Venus', 'Saturn', 'Uranus', 'Mercury') # planets

Set

A set is a collection of data types similar to list and tuple. Unlike list and tuple, set is not an ordered collection of items. Like in Mathematics, set in Python stores only unique items.

In later sections, we will go in detail about each and every Python data type.

Example:

{2, 4, 3, 5}{3.14, 9.81, 2.7} # order is not important in set

Checking Data types

To check the data type of certain data/variable we use the type function. In the following terminal you will see different python data types:

Checking Data types

Python File

First open your project folder, 30DaysOfPython. If you don't have this folder, create a folder name called 30DaysOfPython. Inside this folder, create a file called helloworld.py. Now, let's do what we did on python interactive shell using visual studio code.

The Python interactive shell was printing without using print but on visual studio code to see our result we should use a built in function _print(). The print() built-in function takes one or more arguments as follows print('arument1', 'argument2', 'argument3'). See the examples below.

Example:

The file name is helloworld.py

# Day 1 - 30DaysOfPython Challengeprint(2 + 3) # addition(+)print(3 - 1) # subtraction(-)print(2 * 3) # multiplication(*)print(3 / 2) # division(/)print(3 ** 2) # exponential(**)print(3 % 2) # modulus(%)print(3 // 2) # Floor division operator(//)# Checking data typesprint(type(10)) # Intprint(type(3.14)) # Floatprint(type(1 + 3j)) # Complex numberprint(type('Asabeneh')) # Stringprint(type([1, 2, 3])) # Listprint(type({'name':'Asabeneh'})) # Dictionaryprint(type({9.8, 3.14, 2.7})) # Setprint(type((9.8, 3.14, 2.7))) # Tuple

To run the python file check the image below. You can run the python file either by running the green button on Visual Studio Code or by typing python helloworld.py in the terminal .

Running python script

You are amazing. You have just completed day 1 challenge and you are on your way to greatness. Now do some exercises for your brain and muscles.

Exercises - Day 1

Exercise: Level 1

  1. Check the python version you are using
  2. Open the python interactive shell and do the following operations. The operands are 3 and 4.
    • addition(+)
    • subtraction(-)
    • multiplication(*)
    • modulus(%)
    • division(/)
    • exponential(**)
    • floor division operator(//)
  3. Write strings on the python interactive shell. The strings are the following:
    • Your name
    • Your family name
    • Your country
    • I am enjoying 30 days of python
  4. Check the data types of the following data:
    • 10
    • 9.8
    • 3.14
    • 4 - 4j
    • ['Asabeneh', 'Python', 'Finland']
    • Your name
    • Your family name
    • Your country

Exercise: Level 2

  1. Create a folder named day_1 inside 30DaysOfPython folder. Inside day_1 folder, create a python file helloworld.py and repeat questions 1, 2, 3 and 4. Remember to use print() when you are working on a python file. Navigate to the directory where you have saved your file, and run it.

Exercise: Level 3

  1. Write an example for different Python data types such as Number(Integer, Float, Complex), String, Boolean, List, Tuple, Set and Dictionary.
  2. Find an Euclidian distance between (2, 3) and (10, 8)

CONGRATULATIONS !

Day 2 >>