Skip to content

Instantly share code, notes, and snippets.

View Raj39120's full-sized avatar
😃

Raj_39120 Raj39120

😃
View GitHub Profile
import random
from random import randrange
a = []
for i in range(0, randrange(1, 20)):
n = random.randint(1, 100)
a.append(n)
b = []
for i in range(0, randrange(1, 20)):
n = random.randint(1, 100)
@Raj39120
Raj39120 / Classes_Calculator
Created April 30, 2020 13:27
Simple calculator using classes and user input
class Calculator:
def __init__(self, number_1, number_2):
self.number_1 = number_1
self.number_2 = number_2
print("The sum of the two numbers is: " + str(number_1+number_2))
print("The difference of the two numbers is: " + str(number_1-number_2))
print("The product of the two numbers is: " + str(number_1*number_2))
print("The quotient of the two numbers is: " + str(float(number_1)/float(number_2)))
print("Number 1 squared is: " + str(number_1**2))
print("Number 2 squared is: " + str(number_2**2))
import math
import functools
def sum_of_list_of_numbers():
list_of_numbers = list()
print("How many numbers do you want to include in this list?")
list_count = int(input())
for i in range(list_count):
list_of_numbers.append(int(input("Enter the number you want to add to the list: ")))
from random import randrange
def addition_problems():
a = randrange(0, 10, 1)
print(" " + str(a))
print("+")
b = randrange(0, 10, 1)
print(" " + str(b))
print("-----")
class Student:
def __init__(self, age, gender, first_name, last_name, identification, grade):
self.age = age
self.gender = gender
self.first_name = first_name
self.last_name = last_name
self.identification = identification
self.grade = grade
class Cost:
def __init__(self, time, sea, pool, umbrella, table, total_cost):
self.time = time
self.sea = sea
self.pool = pool
self.umbrella = umbrella
self.table = table
self.total_cost = total_cost
import time
x = time.time()
y = time.time()
count_of_seconds_passed = 0
print("Below you will see a count of how many seconds have passed since the Epoch which was January 1st, 1970.")
time.sleep(3)
print("After that you will see how many seconds have passed since the program started displaying the time since Epoch.")
time.sleep(3)
print(str(count_of_seconds_passed) + " seconds passed since start time")
while x < y:
name = str(input("Please enter your name over here (in the format of your name surrounded by quotation marks): "))
age = int(input("Please enter the age that you will turn on your birthday this year if it has not passed already: "))
date_of_birth = 2020-age
print("The year that you will turn 100 years old in is " + str(date_of_birth+100) + ".")
def practice_2():
number = int(input("Enter an integer over here: "))
if type(number) == float:
print("You have not entered an integer. Please try again and enter a valid number.")
return
if float(number/2.0) == number//2.0:
print("The number you entered is even.")
if float(number/2.0) != number//2.0:
print("The number you entered is odd.")
user_list = input("Enter your list of numbers here (separate each with a comma e.g. 1, 2, 3, 4, 5, 6): ")
y = input("Enter a number here and the program will print all of the numbers in your list less than this number: ")
def check():
if x < y:
print(x),
for x in user_list: