Skip to content

Instantly share code, notes, and snippets.

View misterhtmlcss's full-sized avatar

Roger Kondrat misterhtmlcss

View GitHub Profile
@misterhtmlcss
misterhtmlcss / link-highjacker.js
Created September 8, 2020 18:21
How to solve a problem when you develop code.
# Describe how catching exceptions can help with file errors. Write three Python examples that actually generate file errors on your computer and catch the errors with try: except: blocks. Include the code and output for each example in your post.
# There are two ways to catch an error; handle it gracefully, which is done in the last except statement, but in the first one with ZeroDivisionError we apply the initial part of second implementation that is more dynamic and some would say 'useful' to the user and development team. When an exception is specifically targeted this allows for a software developer to more easily develop an 'antidote' to the issue. In this case division by 0. Possibly this could lead to a solution that upon exception returns 0.
# Describe how catching exceptions can help with file errors.
# Catching errors can mean two things; the graceful handling of your program failing. Rather than a crash! Can anyway anyway 2k bug? This means your code is more durable to errors.
def test_excepti
# **************************
# CS1101 - Discussion Unit 5
# **************************
# **************************
# Instructions
# 1. Check whether its argument has any lowercase letters
# 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters.
# 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!)
# 5. Describe why the result is incorrect. (SEE inline comments)
@misterhtmlcss
misterhtmlcss / unit-3-princewill.py
Created July 7, 2020 17:49
Discussion from Unit 3 - UoPeople
# x = -10
# x = 0
# x = 2
if x != 0:
print("This number ", x, " is not 0.")
else:
print(x, " is 0")
# I think the not operator is interesting.
@misterhtmlcss
misterhtmlcss / learning-journal-u2-b.py
Created July 3, 2020 04:48
learning-journal-u2-b
"""
# Part 2
Write your own function that illustrates a feature that you learned in this unit. The function must take at least one argument. The function should be your own creation, not copied from any other source. Do not copy a function from your textbook or the Internet.
Include all of the following in your Learning Journal:
✓ The code for the function that you invented.
✓ The inputs and outputs to three calls of your invented function.
✓ A description of what feature(s) your function illustrates.
// I was thinking about making this a nice HTML page... another day perhaps
Working with Strings:
[textNormalizer.js] https://gist.github.com/misterhtmlcss/b6f1ef8a76308c975c2faac4951acdd5
[Shouter.js] https://gist.github.com/misterhtmlcss/6bb9b08d140b57b0dddf472eb26c4443
[wisePerson.js] https://gist.github.com/misterhtmlcss/20126d550d9019652639b38ae8079e0b
Working with Numbers:
@misterhtmlcss
misterhtmlcss / number_game.js
Last active October 15, 2015 22:20
1st JS Game - Number guessing
var target, guess_input, guess_input_text;
var finished = false;
var guesses = 0;
function guessing_game() {
var random_number = Math.random() * 100;
var random_number_integer = Math.floor(random_number);
target = random_number_integer + 1;
while (!finished) {
guess_input_text = prompt("Guess what number I'm thinking of? ");