Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
CodeMaster7000 / Fibonacci Series (R).r
Created January 22, 2022 22:24
A program in R that prints the Fibonacci series for as long as you want!
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)
@CodeMaster7000
CodeMaster7000 / H.C.F. Finder.r
Created January 22, 2022 22:22
A program in R to find the H.C.F. of any 2 integers.
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
}
@CodeMaster7000
CodeMaster7000 / Factor Finder.r
Created January 22, 2022 22:17
A program in R to find the factors of a given number.
print_factors <- function(x) {
print(paste("The factors of",x,"are:"))
for(i in 1:x) {
if((x %% i) == 0) {
print(i)
}
}
}
@CodeMaster7000
CodeMaster7000 / Simple Calculator.r
Created January 22, 2022 22:15
A simple calculator coded in R, performing the 4 basic functions.
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) {
@CodeMaster7000
CodeMaster7000 / Ball Catching Game.py
Last active January 20, 2022 20:02
A spectacular ball catching game coded in Python 3 with Tkinter.
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()
@CodeMaster7000
CodeMaster7000 / Round Dance.py
Created January 8, 2022 11:49
A geometrically wonderful round dance coded in Python 3 with turtle.
from turtle import *
def stop():
global running
running = False
def main():
global running
clearscreen()
bgcolor("black")
@CodeMaster7000
CodeMaster7000 / Story Generator.py
Created January 2, 2022 22:49
A random yet interesting story generator coded in Python 3.
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']
@CodeMaster7000
CodeMaster7000 / Magic 8 Ball.py
Created January 1, 2022 21:52
A Magic 8 Ball coded in Python 3 with the answers to all of your life questions!
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)
@CodeMaster7000
CodeMaster7000 / Fibonacci Spiral.py
Created December 29, 2021 22:34
A Fibonacci Spiral coded in Python 3 with Turtle.
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)
@CodeMaster7000
CodeMaster7000 / Fireworks Sprinkler.py
Created December 29, 2021 15:17
A New Year fireworks sprinkler in Python 3.
from random import randint
from processing import *
numberOfParticules = 40;
position=[]
velocity=[]
lifespan=[]
color=1
def setup():