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
# These comands make a gh-pages branch on your local machine and push it to github, as is. | |
# It is designed for a simple html repository. | |
# Github should automatically publish the repository page | |
# create gh-pages branch | |
git checkout --orphan gh-pages | |
# add all files | |
git add . |
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
""" | |
Post request dont work on Djano apps on A2 hosted servers. This replacement 'passenger_wsgi.py' | |
has fixed the issue for me. Works with Python 3.5 with Django 1.11, 2.0, 2.1, 2.2 and Python 3.7 with Django 3.0. | |
""" | |
# Keep this empty | |
SCRIPT_NAME = '' | |
class PassengerPathInfoFix(object): | |
""" |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> |
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
""" | |
Take a list of numbers and make a new list of only the first and last elements of the given list | |
""" | |
____author___ = "Christopher J Shaw" | |
def first_last(input_list): | |
return [input_list[0], input_list[-1]] | |
print(first_last([5, 10, 15, 20, 25])) |
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
""" | |
Ask the user for a number and determine whether the number is prime or not. | |
""" | |
___author___ = "Christopher J Shaw" | |
def check_prime(number): | |
for test in range(2, number): | |
if number % test == 0: | |
return False | |
return True |
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
""" | |
Take two lists and write a program that returns a list that contains only the elements that are | |
common between the lists (without duplicates). Make sure your program works on two lists of different | |
sizes. Write this using at least one list comprehension. | |
""" | |
___author___ = "Christopher J Shaw" | |
import random | |
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
""" | |
Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. | |
Keep going till the user types exit. Keep track of number of attempts | |
""" | |
___author___ = "Christopher J Shaw" | |
import random | |
number = random.randint(1, 9) |
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
""" | |
Make a two-player Rock-Paper-Scissors game. | |
""" | |
___author___ = "Christopher J Shaw" | |
import os | |
def cls(): | |
os.system('cls' if os.name=='nt' else 'clear') |
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
''' | |
07.py: Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it. | |
''' | |
____author___="Christopher J Shaw" | |
nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] | |
even = [num for num in nums if not num % 2] | |
print(even) |
NewerOlder