Skip to content

Instantly share code, notes, and snippets.

View GitAronas's full-sized avatar

Amar Doshi GitAronas

View GitHub Profile
@GitAronas
GitAronas / Ex 01 Hello, World.py
Last active August 21, 2023 15:07
Solutions to the book Python Programming Exercises, Gently Explained by Al Sweigart
print('Hello World!')
s = input('What is your name?\n')
print(f'Hello, {s}')
@GitAronas
GitAronas / palindrome.py
Created June 11, 2022 05:52
Efficient Palindrome Checking
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 11 10:57:33 2022
@author: Amar Doshi
"""
def is_palindrome(var):
if type(var) is not str:
var = str(var)
@GitAronas
GitAronas / fibo.py
Created May 11, 2022 08:40
Infinite Fibonacci number generator
def fibo():
'''
Infinite Fibonacci sequence generator
f = fibo()
Generate number with: next(f)
'''
p, q = 0, 1
while True:
p, q = q, p + q
@GitAronas
GitAronas / FizzBuzz_v00.py
Last active September 18, 2023 17:04
FizzBuzz - Multiple Solutions
def fizzBuzz(n):
for i in range(1, n + 1):
three = (i % 3 == 0)
five = (i % 5 == 0)
if three and five:
print('FizzBuzz')
elif three:
print('Fizz')
elif five:
@GitAronas
GitAronas / collatz.py
Last active May 11, 2022 08:41
Collatz sequence generator
def collatz(n):
if n < 1:
raise ValueError("Only positive integers are allowed")
s = [n]
while n > 1:
if n % 2 == 0:
n //= 2
else: