This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==> 2018-05-07 05:54:59 <== | |
# cmd: C:\Users\Admin\Anaconda3\Scripts\conda install pandas-datareader | |
+defaults::_ipyw_jlab_nb_ext_conf-0.1.0-py36he6757f0_0 | |
+defaults::alabaster-0.7.10-py36hcd07829_0 | |
+defaults::anaconda-5.1.0-py36_2 | |
+defaults::anaconda-client-1.6.9-py36_0 | |
+defaults::anaconda-navigator-1.7.0-py36_0 | |
+defaults::anaconda-project-0.8.2-py36hfad2e28_0 | |
+defaults::asn1crypto-0.24.0-py36_0 | |
+defaults::astroid-1.6.1-py36_0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def IQ(IQ_mean, IQ_std): | |
IQ_value_low = [] | |
IQ_value_high = [] | |
IQ_all = [] | |
for i in range(10000): | |
IQ_value = np.random.normal(IQ_mean, IQ_std) | |
IQ_all.append(IQ_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' In this link the description of problem: https://twitter.com/CutTheKnotMath/status/988401818915999744 ''' | |
import random | |
def bubblesortOnePass(l): | |
if len(l) == 1: | |
return l | |
else: | |
for i in range(len(l)): | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"It's a reworked version of Problem 14 that you find here: http://interactivepython.org/runestone/static/pythonds/Recursion/pythondsProgrammingExercises.html" | |
dizio_1 = { (2,2): 1, (3,4): 2, (4,6): 3, (5,7): 4, (9,10): 5, (9,11): 6, (13,15): 7, (16,19): 8, \ | |
(25,37): 9, (35,45):10 } | |
def createTab ( _Dict ): #create the graphic tab | |
dizio = _Dict | |
print('','Item', 'Weight', 'Value','\n', sep=" " ) | |
for key in dizio: | |
spazio = " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''' Here's the problem: https://www.hackerrank.com/challenges/python-sort-sort/problem''' | |
N,M = map(int,input('First number is the number of athletes,\n\ | |
second number is the number of attributes for each atlhete.\nWrite: ').split()) | |
print() | |
print("So we have {} athletes and {} in our database\n".format(N,M)) | |
L = [] | |
for i in range(1,N+1): | |
L.append(list(map(int,input('Write attributes for athlete number {} : '.format(i)).split()))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Here the description of the problem: https://www.hackerrank.com/challenges/bomber-man/problem ''' | |
from random import choice | |
from time import sleep | |
R, C, N = map(int, input().split()) # we take the number of rows, columns and seconds of the loop | |
Lista = [] # we create the grid where each element is randomnly chosen between '.'(free cell) and 'M'(marked bomb) | |
for r in range(R): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' There are ten coins, each blank on one side and numbered on the other side with numbers 1 through 10. | |
All ten coins are tossed and the sum of numbers landing face up is calculated. What is the probability that this sum is at least 45? | |
''' | |
import random | |
def toss_coin (x): | |
coin = random.choice ([0,x]) #a discrete uniform distribution between values of a sequence, in this case 2 values possible. | |
return (coin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import random | |
count = 0 | |
n = 1000000 #montecarlo simulation | |
for i in range (1000000): | |
z = float(random.uniform(0,(math.pi)/2)) #uniform distribution, it gives a random real number between (0, π/2) | |
y = float(random.uniform(0,z)) | |
x = float(random.uniform(0,y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' In what follows all number are uniformly distributed on [0,1]. Start with | |
a number So and the keep on generating the sequence S1,S2....until, for some | |
N, Sn > So for the first time. What is the expected value E(N) of that N ? ''' | |
import statistics | |
import random | |
# we proceed with Montecarlo method | |
Series_of_n = [] #we creat a list of 10 million elements (n = 10.000.000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def collatz(number): | |
if number % 2 == 0: | |
print(number // 2) | |
return (number // 2) | |
else: | |
print(3 * number + 1) | |
return (3 * number + 1) | |
NewerOlder