Giter VIP home page Giter VIP logo

use_gpt_as_programming_lang's Introduction

use gpt as programming language

this is a project to use GPT as a programming language.

install requirements

pip install -r requirements.txt

api key

you need to get an api key from openai
and put it in a file called .env in the root of the project.
the file should look like this:

OPENAI_API_KEY=your_api_key



hello world

create a new string variable called hello
set the value of the hello variable to "hello world"
print the hello variable

or

print hello world

run these codes:

python main.py examples/hello/hello1
python main.py examples/hello/hello2

output:

hello world



bubble sort

create a new array named a
add 7, 8, 9, 4, 5, 6, 1, 2, 3 and 0 to array a respectively
sorting an array with bubble sort
print array a

or

a = 7, 8, 9, 4, 5, 6, 1, 2, 3 and 0
bubble sort a
print a

run these codes:

python main.py examples/bubble_sort/bubble_sort1
python main.py examples/bubble_sort/bubble_sort2

output:

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]



fibonacci

create a function called fibonacci that takes n arguments
create variable a and b inside fibonacci function and assign 0 and 1 respectively
in the fibonacci function, print a as long as a is less than n, then set a to b and b to a+b
give n a value of 100
call the fibonacci function with n as the argument

or

function fibonacci n
    a = 0
    b = 1
    while a < n
        print a
        a = b
        b = a + b
end fibonacci
n = 100
fibonacci n

or

print up to 100 fibonacci series

run these codes:

python main.py examples/fibonacci/fibonacci1
python main.py examples/fibonacci/fibonacci2
python main.py examples/fibonacci/fibonacci3

output:

0 1 1 2 3 5 8 13 21 34 55 89



arguments

if you want to save the python code, use the following code

python main.py --save examples/fibonacci/fibonacci1

if you want to print the python code, use the following code

python main.py --print examples/fibonacci/fibonacci1

if you want to save and print the python code, use the following code

python main.py --save --print examples/fibonacci/fibonacci1

use_gpt_as_programming_lang's People

Contributors

emresvd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.