Skip to content

Instantly share code, notes, and snippets.

View CavaTrendy's full-sized avatar

Giorgio Alessandro Motta CavaTrendy

View GitHub Profile
# Write a function named collatz() that has one parameter named number. If number is odd or even
#number is even, then collatz() should print number // 2 and return this value.
#If number is odd, then collatz() should print and return 3 * number + 1.
# First example def of collatz()
def collatz( number ):
if number % 2 == 0:
return " it is even number "
else:
return "it is an odd number"
@CavaTrendy
CavaTrendy / MIT - Exercise
Created December 21, 2017 11:48
MIT - Exercise
#### MIT SOLUTION###
#Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o'
#'u'. For example, if s = 'azcbobobegghakl', your program should print: Number of vowels: 5
s = 'azcbobobegghakl'
count = 0
for i in range(0, len(s)):
if s[i] == 'a'or s[i] == 'e'or s[i] == 'i'or s[i] == 'o'or s[i] == 'u':
count += 1
print("Number of vowels: "+ str(count))
@CavaTrendy
CavaTrendy / Tarot card reading exercise
Created April 11, 2018 01:59
Tarot card reading exercise
import random
user= input("Which tarot reading do you want 3(input 3) cards or 7(input 7) cards? or Quit ")
### major arcana
major = ['The Magician', 'The High Priestess', 'The Empress', 'The Emperor', 'The Hierophant', 'The Lovers',
'The Chariot', 'The Strength', 'The Hermit', 'The Wheel of Fortune', 'The Justice', 'The Hanged Man',
'The Death', 'The Temperance', 'The Devil', 'The Tower', 'The Star', 'The Moon', 'The Sun',
'The Judgement', 'The World', 'The Fool']
### minor arcana pentacle
minor_pentancles = ['1p', '2p', '3p', '4p', '5p', '6p', '7p', '8p', '9p', '10p', 'Jp', 'Qp', 'Kp']
minor_wands = ['1w', '2w', '3w', '4w', '5w', '6w', '7w', '8w', '9w', '10w', 'Jw', 'Qw', 'Kw']
@CavaTrendy
CavaTrendy / Module 1 Basic 0.py
Created April 30, 2018 10:55
Introduction to Python - Unit 1 Absolute Beginner
# Task 2 use a print() function with comma separation to combine 2 numbers and 2 strings
print("I'm picking you up at",16, "sharp not at ", 17,"Rember!")
# Task 3 display text describing an address, made from stings and variables of different
street = input ( "What is the name of your street?")
str_number = input ("And the number?")
print ("So it is", street, str_number)
# Task 4[ ] define a variable with a string or numeric value
num_newst = 50
@CavaTrendy
CavaTrendy / Module 1 Fundamentals 0.0
Created April 30, 2018 11:14
Introduction to Python - Unit 2 Fundamentals
# [ ] review and run example - note the first element is always index = 0
student_name = "Alton"
print(student_name[0], "<-- first character at index 0")
print(student_name[1])
print(student_name[2])
print(student_name[3])
print(student_name[4])
# [ ] review and run example
student_name = "Jin"
@CavaTrendy
CavaTrendy / Birthday countdown.py
Created June 13, 2018 04:37
Birthday Count Down
'''
Created with the help of Python Jumpstart by Building 10 Apps
'''
import datetime
def print_header():
print("----------------------------------")
print("BIRTHDAY APP")
@CavaTrendy
CavaTrendy / program.py
Created June 13, 2018 04:39
Weather for the Netherlands
import requests
import bs4
import collections
'''
Created with the help of Python Jumpstart by Building 10 Apps
'''
WeatherReport = collections.namedtuple('WeatherReport',
'cond, temp, scale, loc')
''''
This is the first part where we define teh main function of the program Weather App
@CavaTrendy
CavaTrendy / journal.py
Created June 13, 2018 04:41
Writing a Journal
'''
This is the Journal module
created with the help of Python Jumpstart by Building 10 Apps
'''
import os
def load(name):
'''
This method creates and load new journal
*****
*Author: Giorgio Alessandro Motta
*
*****
import datetime
import lxml.html as lh
import pandas as pd
import requests
from selenium import webdriver
@CavaTrendy
CavaTrendy / Web 3 Python - Transaction
Created July 23, 2019 07:10
How to write transaction on Infuria with data
####
# How to write transaction on Infuria with data by Giorgio Alessandro Motta
####
####
# Import
####
from web3 import Web3
import json