This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nterms = as.integer(readline(prompt="How many terms should I print? ")) | |
| n1 = 0 | |
| n2 = 1 | |
| count = 2 | |
| if(nterms <= 0) { | |
| print("Plese enter a positive integer") | |
| } else { | |
| if(nterms == 1) { | |
| print("Fibonacci sequence:") | |
| print(n1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hcf <- function(x, y) { | |
| if(x > y) { | |
| smaller = y | |
| } else { | |
| smaller = x | |
| } | |
| for(i in 1:smaller) { | |
| if((x %% i == 0) && (y %% i == 0)) { | |
| hcf = i | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print_factors <- function(x) { | |
| print(paste("The factors of",x,"are:")) | |
| for(i in 1:x) { | |
| if((x %% i) == 0) { | |
| print(i) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add <- function(x, y) { | |
| return(x + y) | |
| } | |
| subtract <- function(x, y) { | |
| return(x - y) | |
| } | |
| multiply <- function(x, y) { | |
| return(x * y) | |
| } | |
| divide <- function(x, y) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tkinter import Tk, Button, Label | |
| from tkinter import Canvas | |
| from random import randint | |
| root = Tk() | |
| root.title("Ball Catching Game") | |
| root.resizable(False,False) | |
| canvas = Canvas(root, width=600, height=600) | |
| canvas.pack() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from turtle import * | |
| def stop(): | |
| global running | |
| running = False | |
| def main(): | |
| global running | |
| clearscreen() | |
| bgcolor("black") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| Sentence_starter = ['About 100 years ago', ' In the 20 BC', 'Once upon a time'] | |
| character = [' there lived a king.',' there was a man named Jack.', | |
| ' there lived a farmer.'] | |
| time = [' One day', ' One full-moon night'] | |
| story_plot = [' he was passing by',' he was going for a picnic to'] | |
| place = [' the mountains', ' the garden'] | |
| second_character = [' he saw a man', ' he saw a young lady'] | |
| age = [' who seemed to be in late 20s', ' who seemed very old and feeble'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import random | |
| ans = True | |
| while ans: | |
| question = input("Ask our trustworthy Magic 8 ball a question: (press enter to quit) ") | |
| answers = random.randint(1,20) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from turtle import * | |
| fibo_nr = [1,1,2,3, 5, 8, 13, 21, 34,55] | |
| def draw_square(side_length): | |
| for i in range(4): | |
| forward(side_length) | |
| right(90) | |
| nr_squares=len(fibo_nr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import randint | |
| from processing import * | |
| numberOfParticules = 40; | |
| position=[] | |
| velocity=[] | |
| lifespan=[] | |
| color=1 | |
| def setup(): |