Skip to content

Instantly share code, notes, and snippets.

View navraj213's full-sized avatar

Navraj Singh navraj213

View GitHub Profile
@navraj213
navraj213 / Assignment.md
Created August 14, 2021 00:12
Probability Calculator

Assignment

Suppose there is a hat containing 5 blue balls, 4 red balls, and 2 green balls. What is the probability that a random draw of 4 balls will contain at least 1 red ball and 2 green balls? While it would be possible to calculate the probability using advanced mathematics, an easier way is to write a program to perform a large number of experiments to estimate an approximate probability.

For this project, you will write a program to determine the approximate probability of drawing certain balls randomly from a hat.

First, create a Hat class in prob_calculator.py. The class should take a variable number of arguments that specify the number of balls of each color that are in the hat. For example, a class object could be created in any of these ways:

hat1 = Hat(yellow=3, blue=2, green=6)
hat2 = Hat(red=5, orange=4)
@navraj213
navraj213 / Assignment.md
Created August 13, 2021 22:49
Shape Calculator for FreeCodeCamp

Assignment

In this project you will use object oriented programming to create a Rectangle class and a Square class. The Square class should be a subclass of Rectangle and inherit methods and attributes.

Rectangle class

When a Rectangle object is created, it should be initialized with width and height attributes. The class should also contain the following methods:

  • set_width
  • set_height
  • get_area: Returns area (width * height)
  • get_perimeter: Returns perimeter (2 * width + 2 * height)
@navraj213
navraj213 / Assignment.md
Created August 13, 2021 21:17
Budget App

Assignment

Complete the Category class in budget.py. It should be able to instantiate objects based on different budget categories like food, clothing, and entertainment. When objects are created, they are passed in the name of the category. The class should have an instance variable called ledger that is a list. The class should also contain the following methods:

  • A deposit method that accepts an amount and description. If no description is given, it should default to an empty string. The method should append an object to the ledger list in the form of {"amount": amount, "description": description}.
  • A withdraw method that is similar to the deposit method, but the amount passed in should be stored in the ledger as a negative number. If there are not enough funds, nothing should be added to the ledger. This method should return True if the withdrawal took place, and False otherwise.
  • A get_balance method that returns the current balance of the budget category based on the d
@navraj213
navraj213 / Assignment.md
Created August 9, 2021 23:48
Time Calculator

Assignment

Write a function named add_time that takes in two required parameters and one optional parameter:

  • a start time in the 12-hour clock format (ending in AM or PM)
  • a duration time that indicates the number of hours and minutes
  • (optional) a starting day of the week, case insensitive

The function should add the duration time to the start time and return the result.

If the result will be the next day, it should show (next day) after the time. If the result will be more than one day later, it should show (n days later) after the time, where "n" is the number of days later.

@navraj213
navraj213 / arithmetic_arranger.py
Last active August 15, 2021 08:01
Arithmetic Formatter
def arithmetic_arranger(problems, display_nums = False):
if(len(problems) > 5):
return "Error: Too many problems."
arithmetic_arrange = ""
top_num = []
operator_line = []
sec_num = []
third_line = []
answer_line = []
@navraj213
navraj213 / ReadME.md
Last active August 5, 2021 03:40
Automatic Email Transmitter

Created by Navraj Singh

Use only for educational purposes and at your own discretion

WHAT YOU CAN CHANGE

SERVER

You can update the url of the email server @ line 12 (via first parameter) and also update the port forwarding (via second parameter) accordingly

THREADS

You can change the number of threads @ line 68 | Update the Number of threads your CPU has avaliable from 8 to whatever number. Keep in mind if your cpu doesn't have more threads than the number you specified, the program will not perform faster.

IDLE TIME

@navraj213
navraj213 / urlRequest.py
Last active August 18, 2021 17:30
Url Requester
from urllib.request import Request, urlopen #need requests and urlopener to open url
import threading #threading allows for multiple requests to be sent faster/*same time
import random #random allows for a random header per request to prevent 403 error
import time
class Colors: #just random colors
GREEN = '\033[92m'
RED = '\033[91m'
RESET = '\033[0m' #RESET COLOR
@navraj213
navraj213 / Main.java
Last active June 5, 2021 21:59
TicTacToe Game
class Main {
public static void main(String[] args)
{
System.out.println(
" ███▀▀██▀▀███ ██ ███▀▀██▀▀███ ███▀▀██▀▀███ \n" + //Small banner title on Title Screen
" █▀ ██ ▀█ █▀ ██ ▀█ █▀ ██ ▀█ \n" +
" ██ ▀███ ▄██▀██ ██ ▄█▀██▄ ▄██▀██ ██ ▄██▀██▄ ▄▄█▀██ \n" +
" ██ ██ ██▀ ██ ██ ██ ██ ██▀ ██ ██ ██▀ ▀██▄█▀ ██\n" +
" ██ ██ ██ ██ ▄█████ ██ ██ ██ ████▀▀▀▀▀▀\n" +