Solve Problems by Coding Solutions - A Complete solution for python programming
Broadcasting in NumPy
#Broadcasting
import numpy as np
# We will add,multiply, subtract the vector v to each row of the matrix x,
x = np.array([[1,2,3], [4,5,6], [7,8,9]])
v = np.array([1, 0, 1])
print(x)
print(v)
y = x + v
y1= x * v
y2= x - v
print("Addition\n",y,"\n","Multiplication \n",y1,"\n","Subtraction \n",y2)
Drawing a H-Tree Fractal using turtle in python program
import turtle
SPEED = 8
BG_COLOR = "red"
PEN_COLOR = "lightgreen"
SCREEN_WIDTH = 600
SCREEN_HEIGHT = 600
DRAWING_WIDTH = 500
DRAWING_HEIGHT = 500
PEN_WIDTH = 5
TITLE = "H-Tree Fractal"
FRACTAL_DEPTH = 3
def draw_line(tur, pos1, pos2):
tur.penup()
tur.goto(pos1[0], pos1[1])
tur.pendown()
tur.goto(pos2[0], pos2[1])
def recursive_draw(tur, x, y, width, height, count):
draw_line(
tur,
[x + width * 0.25, height // 2 + y],
[x + width * 0.75, height // 2 + y],
)
draw_line(
tur,
[x + width * 0.25, (height * 0.5) // 2 + y],
[x + width * 0.25, (height * 1.5) // 2 + y],
)
draw_line(
tur,
[x + width * 0.75, (height * 0.5) // 2 + y],
[x + width * 0.75, (height * 1.5) // 2 + y],
)
if count <= 0:
return
else:
count -= 1
recursive_draw(tur, x, y, width // 2, height // 2, count)
recursive_draw(tur, x + width // 2, y, width // 2, height // 2, count)
recursive_draw(tur, x, y + width // 2, width // 2, height // 2, count)
recursive_draw(tur, x + width // 2, y + width // 2, width // 2, height // 2, count)
if __name__ == "__main__":
# Screen setup
screen = turtle.Screen()
screen.setup(SCREEN_WIDTH, SCREEN_HEIGHT)
screen.title(TITLE)
screen.bgcolor(BG_COLOR)
# Turtle artist (pen) setup
artist = turtle.Turtle()
artist.hideturtle()
artist.pensize(PEN_WIDTH)
artist.color(PEN_COLOR)
artist.speed(SPEED)
recursive_draw(artist, - DRAWING_WIDTH / 2, - DRAWING_HEIGHT / 2, DRAWING_WIDTH, DRAWING_HEIGHT, FRACTAL_DEPTH)
turtle.done()
Drawing a fractal tree using turtle in python program
import turtle
MINIMUM_BRANCH_LENGTH = 15
def build_tree(t, branch_length, shorten_by, angle):
if branch_length > MINIMUM_BRANCH_LENGTH:
t.forward(branch_length)
new_length = branch_length - shorten_by
t.left(angle)
build_tree(t, new_length, shorten_by, angle)
t.right(angle * 2)
build_tree(t, new_length, shorten_by, angle)
t.left(angle)
t.backward(branch_length)
tree = turtle.Turtle()
tree.hideturtle()
tree.setheading(90)
tree.color('red')
build_tree(tree, 50, 5, 30)
turtle.mainloop()
Biopython - Python Tools for Computational Molecular Biology
Biopython is a set of freely available tools for biological computation written in Python by an international team of developers.
HUGO - The world’s fastest framework for building websites
Hugo is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again.
Hugo Features
Hugo boasts blistering speed, robust content management, and a powerful templating language making it a great fit for all kinds of static websites.
General
Extremely fast build times (< 1 ms per page)
Completely cross platform, with easy installation on macOS, Linux, Windows, and more
Renders changes on the fly with LiveReload as you develop
Powerful theming
Host your site anywhere
Organization
Straightforward organization for your projects, including website sections
Customizable URLs
Support for configurable taxonomies, including categories and tags
Sort content as you desire through powerful template functions
Automatic table of contents generation
Dynamic menu creation
Pretty URLs support
Permalink pattern support
Redirects via aliases
Content
Native Markdown and Emacs Org-Mode support, as well as other languages via external helpers (see supported formats)
TOML, YAML, and JSON metadata support in front matter
Customizable homepage
Multiple content types
Automatic and user defined content summaries
Shortcodes to enable rich content inside of Markdown
“Minutes to Read” functionality
“WordCount” functionality
Additional Features
Integrated Disqus comment support
Integrated Google Analytics support
Automatic RSS creation
Support for Go HTML templates
Syntax highlighting powered by Chroma