From a4988a8ee29009cccef2e6b44d531d074a68d2c0 Mon Sep 17 00:00:00 2001 From: loiswells97 Date: Mon, 10 Jan 2022 15:36:50 +0000 Subject: [PATCH 1/2] Create draft PR for #4 From 3b02425d10b7f5f204a7c71becd08ff4d79ad06c Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Mon, 10 Jan 2022 15:53:30 +0000 Subject: [PATCH 2/2] Added example project for the runner to the database --- lib/tasks/projects.rake | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/lib/tasks/projects.rake b/lib/tasks/projects.rake index 4fc78988e..ae00f9e87 100644 --- a/lib/tasks/projects.rake +++ b/lib/tasks/projects.rake @@ -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 @@ -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 +