Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code for running project to database as starter project #6

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions lib/tasks/projects.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ namespace :projects do
project.components << Component.new(name: "emoji", extension: "py", content: emoji_content)
project.components << Component.new(name: "noemoji", extension: "py", content: no_emoji_content)
project.save

Project.find_by(identifier: "python-emoji-example")&.destroy
project = Project.new(identifier: "python-emoji-example", name: "Emoji Example Project")
project.components << Component.new(name: "main", extension: "py", content: main_runner_content)
project.components << Component.new(name: "emoji", extension: "py", content: emoji_content)
project.components << Component.new(name: "noemoji", extension: "py", content: no_emoji_content)
project.save
end
end

Expand Down Expand Up @@ -85,3 +92,54 @@ calendar = '▦'

END
end

def main_runner_content

main_runner_content = <<-END
#!/bin/python3

from emoji import *
from datetime import *
from random import randint

# Put function definitions under here

def roll_dice():
print(python, 'can make a', dice)
max = input('How many sides?') # get input from the user
print('That is a D', max) # use the number the user entered
roll = randint(1, int(max)) # generate a random number
print('You rolled a', roll) # print the value of the roll variable
print(fire * roll) # repeat the fire text roll times

def hobbies():
hobby = input('What do you like?')
print('That sounds', fun)
print('You could make a', python, 'project about', hobby)

# Put code to run under here
# Useful characters :',()*_/.#

print('Hello', world)
print('Welcome to', python)

input() # wait for the user to tap Enter

print(python, 'is very good at', sums)
print(230 * 5782 ** 2 / 23781)

input()

now = datetime.now() # get the current date and time
print('The', calendar, clock, 'is', now) # print with emoji

input()

roll_dice() # Call the roll_dice function

input()

hobbies() # Call the hobbies function
END
end