This file contains 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
class Shape | |
def initialize(sides, perimiter, name) | |
@name = name | |
@sides = sides | |
@perimiter = perimiter | |
puts "Shape Name: #@name" | |
puts "Sides: #@sides" | |
puts "Perimiter: #@perimiter" | |
puts "Avg. Side Length: " + (@perimiter.to_i/@sides.to_i).to_s | |
if @sides.to_i < 3 or @perimiter.to_i <= 0 |
This file contains 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
#——————————————————# | |
#/////////\\\\\\\\\# | |
#/|-Solomon Wise-|\# | |
#/|-Do Not Steal-|\# | |
#\\\\\\\\\/////////# | |
#——————————————————# | |
# Imports modules | |
from random import randint, choice | |
from os import system | |
import platform |
This file contains 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
require 'ostruct' | |
profile = OpenStruct.new | |
BEGIN {puts "This program generates a profile for you."} | |
END {puts "Name: #{profile.name}" | |
puts "Description: #{profile.desc}" | |
puts "Gender: #{profile.gender}" | |
puts "Age: #{profile.age}" | |
puts "I Live in: #{profile.live}" | |
puts "I was born in: #{profile.born}" |
This file contains 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
def logtime(message, logfile): | |
"""Writes a message to a log file, as well as the time""" | |
log = open(logfile, 'a') | |
log.write("Error at:") | |
log.write(str(datetime.datetime.now())) | |
log.write(message) | |
def relog(message, logfile): | |
"""Overwrites the log file and writes a message to the log file, as well as the time""" | |
log = open(logfile, 'w') | |
log.write(str(datetime.datetime.now())) |
This file contains 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
class Profile | |
# Profile in the struct format | |
def initialize(name, desc, age, gender, status) | |
:attr_reader | |
puts "Name: #{name}" | |
puts "Description: #{desc}" | |
puts "Age: #{age}" | |
puts "Gender: #{gender}" | |
puts "Status: #{status}" | |
end |
This file contains 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
#!/usr/bin/env python | |
def multby(factor): | |
def mult(value): | |
return value * factor | |
return mult | |
times2 = multby(2) | |
times2(5) |
This file contains 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
def show(a, re) | |
if a =~ re | |
puts "#{$`}>>#{$&}<<#{$'}" | |
else | |
puts "No Match Found" | |
end | |
end |
This file contains 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
#——————————————————# | |
#/////////\\\\\\\\\# | |
#/|-Solomon Wise-|\# | |
#/|-Do Not Steal-|\# | |
#\\\\\\\\\/////////# | |
#——————————————————# | |
# Imports modules | |
from random import randint, choice | |
from os import system | |
listofitems = set() |
This file contains 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 textwrap | |
text = input("Enter in your text: ") | |
line = input("Enter in your line length: ") | |
try: | |
line = int(line) | |
except: | |
print("Invalid line value") | |
exit() | |
print(textwrap.fill(text, width=line)) |
This file contains 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
stext = input("Enter your text: ") | |
dedented = textwrap.dedent(stext) | |
print(dedented) |
OlderNewer