blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a0bb7d1e40305b400b3f64447cfc2af80c3a47a1
achang6/wallstory
/pytuts/monkey/calc_ke.py
503
4.1875
4
# calculate kinetic energy # welcome message print('This program calculates the kinetic energy of a moving object.') # receive mass m_string = input('Enter the object\'s mass in kilograms: ') # convert string input to float m = float(m_string) # receive velocity v_string = input('Enter the object\'s velocity in m/s:...
true
94c2f892a841e7e85e3b4b8668fa0c3c03aab561
JagritiG/object_oriented_python
/15_polymorphism.py
2,845
4.65625
5
# Example of polymorphism # Todo: Example of inbuilt polymorphic functions: print(len("Python")) # len() returns length of a string print(len([1, 2, 3, 4, 5])) # len() returns length of a list # Todo: Example of user defined polymorphic function def add(num1, num2, *args): return num1 + num2 + sum(num for ...
true
f72d71630eaebcdcf010cbc8c3abd3d5a8f2bfba
David-Lisboa/Python-Basico---Oceean
/02OperacoesMatematica.py
424
4.21875
4
# Operações Matematicas soma = 1 + 2 subtracao = 3 - 1 multiplicacao = 3 * 2 divisao = 5 / 3 divisao_int = 5 // 3 print(soma) print(type(soma)) print(subtracao) print(type(subtracao)) print(multiplicacao) print(type(multiplicacao)) print(divisao) print(type(divisao)) print(divisao_int) print(type(divisao_int)) p...
false
4ce07b2cd30f6087d42555e915e9369574f6dde0
trishulg/Lectures
/Lec4/SavingsProgram.py
548
4.25
4
# Get information from the user ? Input balance = float(input('How much do u want to save : ')) if balance <= 0: print('Looks like you already have enough') balance = 0 payment = 1 else: payment = float(input('How much will you save each period: ')) if payment <= 0: payment = float(input('e...
true
866f2ddd60097928168b3a1510f042e5cd4b9880
Latas2001/python-program
/if elif else.py
311
4.1875
4
n=input("Enter the no.") if n%2!=0: print("This is odd no.") print("Weird") for n in range(2,5):z elif n%2==0: print("not weird") break for n in range(6,20): elif n%2==0: print("weird") break elif n%2==0 and n>20: print("not weird") else: print("good bye"):
false
66e60bf7b0d5ef02153b9ba4bb0b99e405758a45
Latas2001/python-program
/birthday reminder.py
721
4.375
4
dict={} while True: print("_______________Birthday App________________") print("1.Show Birthday") print("2.Add to Birthday List") print("3.Exit") choice = int(input("Enter the choice: ")) if choice==1: if len(dict.keys())==0: print("nothing to show....") else: ...
true
74cf296823ec6ed1d27702f4e8e778b488badf00
shreyasingh18/HSBC-2021-WFS1-DEMOS
/python-examples/if_demo.py
264
4.21875
4
x = int(input("Enter value for x: ")) y = int(input("Enter value for y: ")) if x > y: print("if: x > y") print("if: x = ", x, "y = ", y) else: print("else: inside the else condition") print("else: x = ", x, "y = ", y) print("outside if condition")
false
d115b3c8fd28f43e7259473a048e960b1f65423d
shreyasingh18/HSBC-2021-WFS1-DEMOS
/python-examples/nested_list_demo.py
361
4.25
4
items = [[1, 4, 3], [5, 8, 9, 10]] #above list is nested list print(len(items)) #finding the number of items of the particular index print(len(items[0])) #for loop to iterate the list for x in items: print(x) print("--------------") for x in items: for y in x: print(y) print(items) #deleting the items...
true
fc3331e287fc69733621fe8b34ad67cddc70e270
anishmarathe007/Assignments
/bookManagement.py
1,199
4.1875
4
data = {} def insertIntoBook(name,author): if name not in data.keys(): data[name] = author print("Book Successfully Inserted!") else: print("Book with the same name already exists!") def search(name): if name in data.keys(): print(name, "Present. Author name is : ", data[name]) else: print(...
true
97a6b7d3bccc444a72db5cd4fa60b184aff9468a
shotokan/web_scraping_examples
/q1/d.py
879
4.6875
5
def _is_multiple_of_six(number): """ Function utility used to check if a number is multiple of six :param number: :return: """ return (number % 6) == 0 def _is_multiple_of_seven(number): """ Function utility used to check if a number is multiple of seven :param number: :return:...
true
26be92cae05d7c34988a82611d73208c5092ebd5
ktn-andrea/Scripts
/03/palindrom.py
735
4.15625
4
#!/usr/bin/env python3 def is_palindrome1(s): return s == s[::-1] def is_palindrome2(s): i = 0 p = False while i <= len(s)/2: if s[i] == s[len(s)-i-1]: p = True else: return False i += 1 return p def is_palindrome3(s): if len(s) < 2: ...
false
5dcb94625f39b6b106041a51f63baef27ce59177
jeremytedwards/data-structures
/src/data_structures/sort_insertion.py
1,801
4.125
4
# coding=utf-8 import random import timeit def sort_insertion(origin_list): """Implement insertion sort.""" if len(origin_list) == 0: return origin_list else: sorted_list = [origin_list.pop(0)] while len(origin_list) > 0: item = origin_list.pop(0) for index,...
true
d1fcc3ea09823f097bed3a97aaa43abd71a5ec9a
ayesha53/ayeshajawaid
/calculator.py
435
4.25
4
first_number=int(input("Enter number ")) second_number=int(input("Enter number ")) operator=input("Enter operator") if operator=="+": print(int(first_number)+int(second_number)) elif operator=="-": print(int(first_number)-int(second_number)) elif operator=="*": print(int(first_number)*int(second_number)) el...
false
8d2680094b60b6fd59369f3031bb725c952acfde
ravindrasinghinbox/learn-python
/python-w3schools-v1/list.py
1,427
4.1875
4
# mylist = ["a", "c", "b"] # print(mylist) # print(mylist[0]) # print(mylist[-1]) # print(mylist[1:2]) # thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"] # print(thislist[-4:-1]) # # change list value # mylist = ["a", "b", "c"] # mylist[0] = "A" # print(mylist) # # loop list ...
false
778636921c820b819ca1f8a698183fa15fc290a1
ravindrasinghinbox/learn-python
/python-w3schools-v1/if-else.py
786
4.40625
4
# if if(2>1): print("2 is greater than 1") # elif if(5<1): print("5 is less than 1") elif (4 > 2): print("4 is greater than 2") # else if(5<1): print("5 is less than 1") elif (4 < 2): print("4 is less than 2") else: print("No input") # short hand if if(4<5):print("4 is greater th...
false
2683e9f5a7b57b2281df5d8b05b8245cc319660a
sudiptoshahin/pythonmachinelearningbasic
/inputs.py
1,324
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: """ input() and raw_input() both function take a string as an argument and displays it as promot in shell. it waits for the user to hit enter for raw_input(), input line is treated as string and becomes the value returend by the function nput treats the typed line ...
true
c75d6af83883238345dd0330087cddb25e655803
shahnaaz20/debugging_part_4
/cipher2.py
927
4.34375
4
def encrypt(message): ascii_message = [ord(char)+3 for char in message] encrypt_message = [ chr(char) for char in ascii_message] return(''.join(encrypt_message)) def decrypt(message): ascii_message = [ord(char)-3 for char in message] decrypt_message = [ chr(char) for char in ascii_message] r...
false
75def06a03b2dd42b7af41318c36c5a53592247f
emojipeach/euler_problems_python
/0002.py
664
4.28125
4
print("""Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:""") print("""1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...""") print("""By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the su...
true
304bd6076896e403fd2973d669f1469b255220d4
CrystalBRana/LabProjects2
/q_n0_ 8.py
299
4.375
4
''' Write a Python program which accepts the radius of a circle from the user and compute the area. (area of circle =PI * r^2)''' radius = float(input("Enter the radius of circle in centimeter:")) area_of_circle = (3.14 * (radius**2)) print(f"The area of circle is {area_of_circle} square meter")
true
2a0b4735c4db4ba0b831028b3a8a26c242a007f9
CrystalBRana/LabProjects2
/q.no.10.py
402
4.1875
4
# Write a python program to convert seconds to day, hour, minutes and seconds. seconds = int(input('Insert second:')) seconds_in_day = 60*60*24 seconds_in_hour = 60*60 seconds_in_minute = 60 days = seconds // seconds_in_day hours = (seconds - (days * seconds_in_day))// seconds_in_hour minutes = (seconds - (days * sec...
true
af6475761f6aef23786189e00e99f2862639583a
SRaja001/MIT_Open
/HW/Problem_set_1.py
2,844
4.25
4
#Problem 0 #dob = raw_input('Please Enter your dat of birth MM/DD/YY: \n**') #user = raw_input('Please enter your last name: \n**') #print user, dob ###Problem 1 ## ##balance = float(raw_input("Please enter the balance on your credit card: ")) ##interest_rate = float(raw_input("Please enter the annual interest rate a...
true
a11a6374068185e7cf39fca250b1e9f04b3f7f59
jonathansilveira1987/EXERCICIOS_ESTRUTURA_DE_DECISAO
/exercicio20.py
1,267
4.28125
4
# 20. Faça um Programa para leitura de três notas parciais de um aluno. O programa deve calcular # a média alcançada por aluno e apresentar: # 1. A mensagem "Aprovado", se a média for maior ou igual a 7, com a respectiva média alcançada; # 2. A mensagem "Reprovado", se a média for menor do que 7, com a respectiva médi...
false
59f91514f7f4b3169801d00bf4a545fd1dddef91
jonathansilveira1987/EXERCICIOS_ESTRUTURA_DE_DECISAO
/exercicio23.py
592
4.25
4
# 23. Faça um Programa que peça um número e informe se o número é inteiro ou decimal. # Dica: utilize uma função de arredondamento. # Desenvolvido por Jonathan Silveira - Instagram: @ jonathandev01 # Função de Arredondamento # numero = float(input("Numero original: ")) # print("Arredondado :", round(numero)) numero ...
false
a8e840fc577193db202ed5af696cb221e77db59a
kaidokariste/python
/01_LearnPythonHardWay/03_raw_terminal_input.py
499
4.1875
4
print("How old are you"), age = input() # raw_input from python2 was renamed input in python3 print("How tall are you"), height = input() print("How much do you weight"), weight = input() print("So you're {} old, {} tall and {} heavy.".format(age,height,weight)) # you can define input text also as variable age = inp...
true
3a863353a9d02e208139ed825835b60db3adee0d
iEdwinTorres/backend-baby-names-assessment
/babynames.py
2,733
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # BabyNames python coding exercise. # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 """ Define the extract_names() function below and change main() to call it. For writing regex, it's nice to inc...
true
bb3aceaea7a1f8ef838d20a859ab58b9982c580a
flovera1/CrackingTheCodeInterview
/Python/Chapter1ArraysAndStrings/stringCompression.py
816
4.34375
4
''' Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the string has only ...
true
079970bfa071570a912ba12d321c469e46a844ab
NedyalkoKr/Learning-Python
/Lesson 9 - Modularity/function_basics.py
986
4.125
4
# defining a new function # x is the input to the function # functions can accept one, or more or none parameters # these parameters represent the initial data the function will use # internaly def square(x): # returning the output of a function return x * x print(square(5)) # we can choose to bind paramete...
true
43ce9efa69e5038b870c9bd863a26e2b4d9780fb
NedyalkoKr/Learning-Python
/Lesson 6 - Strings, Collections, and Iteration/lists.py
922
4.59375
5
# list is a ordered collection(sequence) of objects # lists are mutable # lists are iterable # creating list object using list literal form numbers = [1,2,3,4,5,6,7,8,9] fruits = ["apple", "orange", "pear"] # each list item position is map to a index that allows to reference and retrive that item print(numbers[0]) ...
true
4c38a7789b6010f9fcd1cc16758354234c4901f1
NedyalkoKr/Learning-Python
/Lesson 7 - Scalar Types, Operators, and Control Flow/nesting_conditionals.py
405
4.28125
4
h = 42 if h > 50: print("Greater than 50") else: # nesting is not a bad pattern, but in python is better to flat # than nested for readability if h < 20: print("Less than 20") else: print("Between 20 and 50") # the same logic bu using flat structure if h > 50: print("Greater t...
true
4387486343afdac38e51dd0971f9ce9637a2dd0e
luiseduardogfranca/Luis-Franca
/LP1-P1/Initial Knowledge Test/array_intersection.py
1,370
4.15625
4
def min_value(array): min = array[0] for value in array: if value < min: min = value return min # function to sort in ascending order def sort_array(array): new_array = [] for index in range(len(array)): min = min_value(array) new_array.append(min) ar...
true
4560924bf5c9fd07101e6cd2663c6add33352fff
luiseduardogfranca/Luis-Franca
/LP1-P1/Conditionals and Repetition Structure/playing_with_arrays.py
1,195
4.15625
4
def inverse_order(array): return [array[index] for index in range(len(array) - 1, -1, -1)] def left_shift(array): new_array = [None] * len(array) for index in range(len(array)): new_array[index-1] = array[index] return new_array # i did it this way to learn a new way def sort_by_decreas...
true
00752314ecbd8f9be2862896576e36e76eaa6305
ATHULKNAIR/PythonPrograms
/PrintSum.py
241
4.15625
4
# Write a program that takes three numbers and prints their sum. Every number # is given on a separate line. a = int(input('Enter First Number')) b = int(input('Enter Second Number')) c = int(input('Enter Third Number')) print(a + b + c)
true
6acd96fe92a6241537df088dd2df8dda02e7a6ac
rachelBurford/she_codes_python
/conditionals/dictionaries/Dictionaries_exercises/q1.py
850
4.125
4
prices = { "Baby Spinach": 2.78, "Hot Chocolate": 3.70, "Crackers": 2.10, "Bacon": 9.00, "Carrots": 0.56, "Oranges": 3.08 } quantity = { "Baby Spinach": 1, "Hot Chocolate": 3, "Crackers": 2, "Bacon": 1, "Carrots": 4, "Oranges": 2 } quantity2 = { "Baby Spinach": 2, ...
true
dcc907106126ba5a4491e86d9dca2aa648a365ee
vsingh1998/Code_in_place
/Lectures/Lecture4/add2numbers.py
652
4.25
4
""" File: add2numbers.py -------------------- This program asks for the user inputs of two numbers and prints their sum. """ def main(): print("This is a program to calculate sum of two numbers.") # ask the user to input first number num1 = input("Enter first number: ") # convert string into integer...
true
34f78ebc1dd9e983bb699b85fad673b75bb318e6
asnewton/Stack
/QueueByStack.py
570
4.1875
4
""" Implement Queue using Stacks """ from Stack import NewStack class Queue: myStack1 = NewStack() myStack2 = NewStack() def enQueue(self, item): Queue.myStack1.push(item) def deQueue(self): while Queue.myStack1.isempty() is not True: Queue.myStack2.push(Queue.myStack1.p...
true
3bdaa7792f2fb8796ea50a7fa59d9204a79db3d0
jakaprima/python-basic-minimalist
/tantangan/manipulasi_string_searching.py
508
4.28125
4
def LongestWord(sen): # first we remove non alphanumeric characters from the string # using the translate function which deletes the specified characters sen = sen.translate(None, "~!@#$%^&*()-_+={}[]:;'<>?/,.|`") # now we separate the string into a list of words arr = sen.split(" ") # the list max func...
true
a9ca0cdcc9546f3dc38ee1f5afe01071ae2d038f
V-Marco/miscellaneous
/tkinter_bootcamp/grid.py
420
4.53125
5
from tkinter import * # Create a root window root = Tk() # Create a label widget myLabel1 = Label(root, text = "Hello, World!") myLabel2 = Label(root, text = "Hi again!") myLabel3 = Label(root, text = " ") # Put them in the grid # The positions are relative! myLabel1.grid(row = 0, column = 0) myLabel2.grid(r...
true
bc63aacc6a2e74a5b190023f2fe991816e9cd332
ShivaniAsokumar/problems-py
/Find_Second_Max.py
2,532
4.15625
4
""" ! PROMPT: Find the second largest element in a given list. * Input: Array of numbers * Output: Second largest number ? What happens if an illegal argument is given. => Raise ValueError * Secong largest number is smaller than max but larger than all other values. // Brute Force Solution * Find the maximum usi...
true
38c04c9e3b6d113a3526adcda38fef3f12252623
CamilliCerutti/Python-exercicios
/Curso em Video/ex005.py
270
4.25
4
# ANTECESSOR E SUCESSOR # Faça um programa que leia um número Inteiro e mostre na tela o seu sucessor e seu antecessor. x = int(input('Digite um número: ')) ant = x-1 suc = x+1 print(f' O antecessor do número que você escolheu é: \n{ant} e o sucessor é {suc}')
false
d3f7181630d380ec71df0e9ba11851a48bd6eb1a
CamilliCerutti/Python-exercicios
/CURSO UDEMY/EXERCICIOS/EX003.PY
442
4.125
4
# Faça um programa que peça o primeiro nome do usuário. Se o nome tiver 4 letras ou menos escreva "Seu nome é curto"; se tiver entre 5 e 6 letras, escreva "Seu nome é normal"; maior que 6 escreva "Seu nome é muito grande" nome = input('Digite seu nome: ') letras = len(nome) if letras <= 4: print('Seu nome é curt...
false
8d2b9e08b1470ce89c4eca976b3c664ef3889d87
CamilliCerutti/Python-exercicios
/Curso em Video/ex075.py
740
4.28125
4
# ANALISE DE DADOS EM UMA TUPLA # Desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: # A) Quantas vezes apareceu o valor 9. # B) Em que posição foi digitado o primeiro valor 3. # C) Quais foram os números pares. tupla = (int(input('Digite um valor: ')), int(input('D...
false
5193fe9313b4172185dbf05d83b213253686697d
CamilliCerutti/Python-exercicios
/Curso em Video/ex028.py
613
4.1875
4
# JOGO DE ADVINHAÇÃO V1.0 # Escreva um programa que faça o computador “pensar” em um número inteiro entre 0 e 5 e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador. O programa deverá escrever na tela se o usuário venceu ou perdeu. from random import randint from time import sleep num = ...
false
009eb8f77f950e82f8a65bcb4f03ff6baf13395c
UlysseARNAUD-IPSSI/Module-python
/Chapitre 1 : Bases du langage Python/exercices/1.2 : Collections, boucles et dictionnaires/cityinfo.py
1,421
4.3125
4
#!/usr/bin/env python3 """ Variables utilisées """ infoCity = {'Lyon': (513275, 47.87, 'Lyonnais'), 'Paris': (2206488, 105.40, 'Parisiens'), 'Brest': (139163, 49.51, 'Brestois'), 'Bordeaux': (249712, 49.36, 'Bordelais'), } cities = ['Lyon', 'Paris', 'Brest'] """ Fonct...
false
f91d47047a5b5bf2aace76fee32407c1d6c13818
AnkitNigam1985/Data-Science-Projects
/Courses/DataFlair/pandas_pipe.py
2,450
4.3125
4
import numpy as np import pandas as pd #Pipe() used to apply any operation on all elements of series or dataframe #Creating a function to be applied using pipe() def adder(ele1, ele2): return ele1+ele2 #Series print("\nSeries:\n") dataflair_s1 = pd.Series([11, 21, 31, 41, 51]) print("Original :\n",dataflair_s1)...
false
7d9fec9bce16a86e0da440ca9c06c3b29d4a5d7d
RaimundoJSoares/Programs-in-Python
/Maior_e_menorNumero.py
443
4.125
4
a = int(input( 'Digite um numero')) b = int(input('Digite o segundo numero')) c = int(input('Digite o terceiro numero')) #verificando quem é o menor menor = a if b < a and b < c: menor = b if c < a and c < b: menor = c print('O menor valor digitado foi {}'.format(menor)) #Verificando quem é o maior maior = a if...
false
20b94d8b7f160bb48e2371e38165ed44558046ff
namphung1998/Comp123_code
/Final/Files/Q5.py
1,052
4.28125
4
import turtle # Your job in this question is to write a function named # drawSquares. The drawSquares draws a series of squares # each one next to the other. The drawn squares start with # 10 pixels to a side, and get bigger by 10 until they # reach the input max size, after which they get smaller # until they reach 1...
true
90987e465b35469819d8c421424500fe06dbd2de
mitcheccles/tensortrade
/tensortrade/core/clock.py
1,184
4.5625
5
from datetime import datetime class Clock(object): """A class to track the time for a process. Attributes ---------- start : int The time of start for the clock. step : int The time of the process the clock is at currently. Methods ------- now(format=None) Get...
true
d55539e09d65135646d3a27fc82ecb7e0cc33a18
BenjaminAage/TileTraveller
/tile_traveller_def.py
2,707
4.46875
4
# https://github.com/BenjaminAage/TileTraveller/blob/master/tile_traveller_def.py # 1. Which implementation was easier and why? # - It was quite hard to implement program #1 (without functions), as you had to figure out # all the factors to have the program up and running. However, the function program (#2) w...
true
f6875ce5510fbe4dce11a13281b5b0b1784a8899
jeowsome/Python-Adventures
/Rock-Paper-Scissors/Find positions/main.py
473
4.34375
4
# put your python code here numbers = input().split(' ') # read the input then create a new list for positions to_find = input() to_print = [] # when "iterating over the list of numbers", append all the found occurrences for i in range(len(numbers)): if numbers[i] == to_find: to_print.append(str(i...
true
7ee8bd96405b9f6a0d8b200d4627e4f371511db3
jgazal/DSA_Python-FAD
/Python_FAD/Capitulo3_LoopsCondicionais/Range.py
423
4.15625
4
print("Range") print("-----") # Imprimindo números pares entre 50 e 101 for i in range(50, 101, 2): print(i) print("\n") for i in range(3, 6): print (i) print("\n") for i in range(0, -20, -2): print(i) print("\n") lista = ['Morango', 'Banana', 'Maça', 'Uva'] lista_tamanho = len(lista) for i in range(0, l...
false
d449cdfec0e9cde9c047ed06aa6cf30360c9e108
mauricioTechDev/daily-code-wars
/python/running-out-of-space.py
746
4.15625
4
# Kevin is noticing his space run out! # Write a function that removes the spaces from the values and # returns an array showing the space decreasing. For example, # running this function on the array ['i', 'have','no','space'] # would produce ['i','ihave','ihaveno','ihavenospace']. # SOLUTION W...
true
3a5e51c219a91504012fa87e2f3db7abacd392f7
raysmith619/Introduction-To-Programming
/exercises/prroduct.py
664
4.34375
4
# product.py """ Write a function product(factor1, factor2, factor3) that returns the product of the values factor1, factor2, factor3. Test it on the following: .5, .4, .3; 1, 2, 3; -1, -1, -1; """ def product(factor1, factor2, factor3): """ Do product of 3 factors, returning the product ...
true
9b25fa00573645aa4941e852ecbbc8499bee599a
raysmith619/Introduction-To-Programming
/exercises/functions/friends_family/simple_friends/list_friends.py
498
4.15625
4
#list_friends.py 23Sep2020 crs, Author # Simple List Example """ Just list a list of friends names """ # Initial list of friends names my_friends = [ "Ray Smith", "Phil Fontain", "Rich Parker", ] # Simple loop to print out names from list for name in my_friends: print(name) r''...
false
f692537aac14503d8da3feecc163026fcc780f1c
raysmith619/Introduction-To-Programming
/exercises/turtle/turtle_onclick_rainbow.py
837
4.4375
4
# turtle_on_click_rainbow.py 27Nov2020 crs, from turtle_onclick """ Adding color to turtle_onclick.py Operation: Repeat: 1. Position the mouse inside graphics screen 2. Click mouse (button one) A line is draw to the mouse position """ from turtle import * rainbow = ["red", "orange", "y...
true
9cd3b65a6842ca1e873263202533ec990ff8f7ef
AxelSiliezar/ME021-Python
/Me021-Python/HW01/HW01_03.py
305
4.21875
4
import math #given M = input ("Enter value for M: ") M = float(M) m = input ("Enter value for m: ") m = float (m) r = input ("Enter value for r: ") r = float (r) G = 6.674*10**(-11) #Nm^2/kg^2 #G = universal gravitational constant F = ((G)*(M*m/r**2)) print ("The value of F is: ",(F))
false
092092f0e0f92fa658a28b8a4ff6898a52868c1f
sashakrasnov/datacamp
/21-deep-learning-in-python/3-building-deep-learning-models-with-keras/03-fitting-the-model.py
1,348
4.5
4
''' Fitting the model You're at the most fun part. You'll now fit the model. Recall that the data to be used as predictive features is loaded in a NumPy matrix called predictors and the data to be predicted is stored in a NumPy matrix called target. Your model is pre-written and it has been compiled with the code from...
true
f544c60fe5e01e1b88821505f3293bce45f8261b
sashakrasnov/datacamp
/21-deep-learning-in-python/4-fine-tuning-keras-models/06-building-your-own-digit-recognition-model.py
2,475
4.5625
5
''' Building your own digit recognition model You've reached the final exercise of the course - you now know everything you need to build an accurate model to recognize handwritten digits! We've already done the basic manipulation of the MNIST dataset shown in the video, so you have X and y loaded and ready to model ...
true
5a936e185653a9333474874e60db2dd78565cb30
sashakrasnov/datacamp
/22-network-analysis-in-python-1/1-introduction-to-networks/03-specifying-a-weight-on-edges.py
1,641
4.3125
4
''' Specifying a weight on edges Weights can be added to edges in a graph, typically indicating the "strength" of an edge. In NetworkX, the weight is indicated by the 'weight' key in the metadata dictionary. Before attempting the exercise, use the IPython Shell to access the dictionary metadata of T and explore it, f...
true
e1b882e222d1cc893c2bcf8512372943370b71c2
sashakrasnov/datacamp
/06-importing-data-in-python-2/3-diving-deep-into-the-twitter-api/03-load-and-explore-twitter-data.py
1,212
4.53125
5
''' Load and explore your Twitter data Now that you've got your Twitter data sitting locally in a text file, it's time to explore it! This is what you'll do in the next few interactive exercises. In this exercise, you'll read the Twitter data into a list: tweets_data. Instructions * Assign the filename 'tweets.txt...
true
1575384d98d8fbab917cfe024e3686b910f42d54
sashakrasnov/datacamp
/15-statistical-thinking-in-python-1/1-graphical-exploratory-data-analysis/05-computing-the-ecdf.py
1,722
4.40625
4
''' Computing the ECDF In this exercise, you will write a function that takes as input a 1D array of data and then returns the x and y values of the ECDF. You will use this function over and over again throughout this course and its sequel. ECDFs are among the most important plots in statistical analysis. You can writ...
true
20eebc469dec4f8c152a61f7ea5c04b53092e976
sashakrasnov/datacamp
/24-data-types-for-data-science/4-handling-dates-and-times/03-pieces-of-time.py
1,804
4.25
4
''' Pieces of Time When working with datetime objects, you'll often want to group them by some component of the datetime such as the month, year, day, etc. Each of these are available as attributes on an instance of a datetime object. You're going to work with the summary of the CTA's daily ridership. It contains the...
true
0f35c9a6a623c41d4590847e59962315672ce2b3
sashakrasnov/datacamp
/29-statistical-simulation-in-python/2-probability-and-data-generation-process/07-driving-test.py
2,037
4.65625
5
''' Driving test Through the next exercises, we will learn how to build a data generating process (DGP) through progressively complex examples. In this exercise, you will simulate a very simple DGP. Suppose that you are about to take a driving test tomorrow. Based on your own practice and based on data you have gathe...
true
206f83801de4bbda63c100e3026939cf9085e7f6
sashakrasnov/datacamp
/26-manipulating-time-series-data-in-python/1-working-with-time-series-in-pandas/06-calculating-stock-price-changes.py
1,590
4.25
4
''' Calculating stock price changes You have learned in the video how to calculate returns using current and shifted prices as input. Now you'll practice a similar calculation to calculate absolute changes from current and shifted prices, and compare the result to the function .diff(). ''' import pandas as pd yahoo ...
true
dbad60a48570c819043be5067ba14a0748a48fd3
sashakrasnov/datacamp
/29-statistical-simulation-in-python/4-advanced-applications-of-simulation/01-modeling-corn-production.py
1,494
4.3125
4
''' Modeling Corn Production Suppose that you manage a small corn farm and are interested in optimizing your costs. In this exercise, we will model the production of corn. For simplicity, let's assume that corn production depends on only two factors: rain, which you don't control, and cost, which you control. Rain is...
true
19fb72baf7e1c430977fc551d85e516d2e87dadc
sashakrasnov/datacamp
/09-manipulating-dataframes-with-pandas/4-grouping-data/03-computing-multiple-aggregates-of-multiple.columns.py
1,806
4.25
4
''' Computing multiple aggregates of multiple columns The .agg() method can be used with a tuple or list of aggregations as input. When applying multiple aggregations on multiple columns, the aggregated DataFrame has a multi-level column index. In this exercise, you're going to group passengers on the Titanic by 'pcl...
true
db126fa6dca8af406e3eb64cec30bb4e302f7ef4
sashakrasnov/datacamp
/24-data-types-for-data-science/3-meet-the-collections-module/04-safely-appending-to-a-keys-value-list.py
1,648
4.75
5
''' Safely appending to a key's value list Often when working with dictionaries, you know the data type you want to have each key be; however, some data types such as lists have to be initialized on each key before you can append to that list. A defaultdict allows you to define what each uninitialized key will contai...
true
0453443a2fd4382dd5faf56577be5ed76779b069
sashakrasnov/datacamp
/08-pandas-foundations/1-data-ingestion-and-inspection/07-plotting-series-using-pandas.py
1,935
4.84375
5
''' Plotting series using pandas Data visualization is often a very effective first step in gaining a rough understanding of a data set to be analyzed. Pandas provides data visualization by both depending upon and interoperating with the matplotlib library. You will now explore some of the basic plotting mechanics wit...
true
a8550d5ba734efaadd56fd5332aa2666f8b2fefa
sashakrasnov/datacamp
/06-importing-data-in-python-2/2-interacting-with-apis-to-import-data-from-the-web/01-loading-and-exploring-a-json.py
924
4.65625
5
''' Loading and exploring a JSON Now that you know what a JSON is, you'll load one into your Python environment and explore it yourself. Here, you'll load the JSON 'a_movie.json' into the variable json_data, which will be a dictionary. You'll then explore the JSON contents by printing the key-value pairs of json_data ...
true
1f9b6dc325f192935d30604dae151f875e5ad35c
sashakrasnov/datacamp
/21-deep-learning-in-python/1-basics-of-deep-learning-and-neural-networks/02-the-rectified-linear-activation-function.py
1,716
4.625
5
''' The Rectified Linear Activation Function As Dan explained to you in the video, an "activation function" is a function applied at each node. It converts the node's input into some output. The rectified linear activation function (called ReLU) has been shown to lead to very high-performance networks. This function ...
true
8bb2983a52a9607911c0ea69f4a453fef39b45de
sashakrasnov/datacamp
/08-pandas-foundations/2-exploratory-data-analysis/09-separate-and-summarize.py
1,569
4.125
4
''' Separate and summarize Let's use population filtering to determine how the automobiles in the US differ from the global average and standard deviation. How the distribution of fuel efficiency (MPG) for the US differ from the global average and standard deviation? In this exercise, you'll compute the means and sta...
true
6b582bf7eb3e5e3fc4ae9912c68cd2be5dccac6d
sashakrasnov/datacamp
/14-interactive-data-visualization-with-bokeh/1-basic-plotting-with-bokeh/08-plotting-data-from-pandas-dataframes.py
1,796
4.21875
4
''' Plotting data from Pandas DataFrames You can create Bokeh plots from Pandas DataFrames by passing column selections to the glyph functions. Bokeh can plot floating point numbers, integers, and datetime data types. In this example, you will read a CSV file containing information on 392 automobiles manufactured in ...
true
cf5ed84b81c429740decf635f089ce6cf2b1b1a4
sashakrasnov/datacamp
/24-data-types-for-data-science/2-dictionaries--the-root-of-python/06-working-with-dictionaries-more-pythonically.py
1,852
4.25
4
''' Popping and deleting from dictionaries Often, you will want to remove keys and value from a dictionary. You can do so using the del Python instruction. It's important to remember that del will throw a KeyError if the key you are trying to delete does not exist. You can not use it with the .get() method to safely d...
true
4ea71b51359e8486ed5c5e65bea639653363814b
sashakrasnov/datacamp
/19-machine-learning-with-the-experts-school-budgets/2-creating-a-simple-first-model/06-combining-text-columns-for-tokenization.py
2,114
4.125
4
''' Combining text columns for tokenization In order to get a bag-of-words representation for all of the text data in our DataFrame, you must first convert the text data in each row of the DataFrame into a single string. In the previous exercise, this wasn't necessary because you only looked at one column of data, so...
true
1b100714dada7b59a0ebab1e83f8de2d942aead0
sashakrasnov/datacamp
/28-machine-learning-for-time-series-data-in-python/3-predicting-time-series-data/01-introducing-the-dataset.py
1,453
4.53125
5
''' Introducing the dataset As mentioned in the video, you'll deal with stock market prices that fluctuate over time. In this exercise you've got historical prices from two tech companies (Ebay and Yahoo) in the DataFrame prices. You'll visualize the raw data for the two companies, then generate a scatter plot showing...
true
ff58963682d6b0c385af84e7cfd8e569ebb0f43c
sashakrasnov/datacamp
/21-deep-learning-in-python/2-optimizing-a-neural-network-with-backward-propagation/01-coding-how-weight-changes-affect-accuracy.py
2,751
4.4375
4
''' Coding how weight changes affect accuracy Now you'll get to change weights in a real network and see how they affect model accuracy! Have a look at the following neural network: https://s3.amazonaws.com/assets.datacamp.com/production/course_3524/datasets/ch2ex4.png Its weights have been pre-loaded as weights_0. ...
true
c909f3767520223e6be10318e530cbc924ef2b76
sashakrasnov/datacamp
/24-data-types-for-data-science/2-dictionaries--the-root-of-python/01-creating-and-looping-through-dictionaries.py
1,832
4.90625
5
''' Creating and looping through dictionaries You'll often encounter the need to loop over some array type data, like in Chapter 1, and provide it some structure so you can find the data you desire quickly. You start that by creating an empty dictionary and assigning part of your array data as the key and the rest as...
true
a31ee59404efdb8fa7481075543179c1fec6412b
sashakrasnov/datacamp
/08-pandas-foundations/1-data-ingestion-and-inspection/05-reading-a-flat-file.py
1,610
4.4375
4
''' Reading a flat file In previous exercises, we have preloaded the data for you using the pandas function read_csv(). Now, it's your turn! Your job is to read the World Bank population data you saw earlier into a DataFrame using read_csv(). The file has been downloaded as world_population.csv. The next step is to r...
true
341a39673f57049a3f28d111b7b4e46428714cc8
sashakrasnov/datacamp
/26-manipulating-time-series-data-in-python/1-working-with-time-series-in-pandas/04-set-and-change-time-series-frequency.py
1,210
4.1875
4
''' Set and change time series frequency In the video, you have seen how to assign a frequency to a DateTimeIndex, and then change this frequency. Now, you'll use data on the daily carbon monoxide concentration in NYC, LA and Chicago from 2005-17. You'll set the frequency to calendar daily and then resample to month...
true
5a33d4bb2add5882a2a6637aecf90330ed47776d
sashakrasnov/datacamp
/14-interactive-data-visualization-with-bokeh/1-basic-plotting-with-bokeh/09-the-bokeh-columndatasource.py
1,733
4.125
4
''' The Bokeh ColumnDataSource (continued) You can create a ColumnDataSource object directly from a Pandas DataFrame by passing the DataFrame to the class initializer. In this exercise, we have imported pandas as pd and read in a data set containing all Olympic medals awarded in the 100 meter sprint from 1896 to 2012...
true
f8cdaee2db28f409fc8bf13ea75d0abb9a509a99
sashakrasnov/datacamp
/22-network-analysis-in-python-1/4-bringing-it-all-together/08-finding-important-collaborators.py
1,909
4.125
4
''' Finding important collaborators Almost there! You'll now look at important nodes once more. Here, you'll make use of the degree_centrality() and betweenness_centrality() functions in NetworkX to compute each of the respective centrality scores, and then use that information to find the "important nodes". In other ...
true
21fce1ba844f4c7273ed86a18e21b7725bc92f5f
sashakrasnov/datacamp
/24-data-types-for-data-science/1-fundamental-data-types/06-determining-set-differences.py
1,822
4.65625
5
''' Determining set differences Another way of comparing sets is to use the difference() method. It returns all the items found in one set but not another. It's important to remember the set you call the method on will be the one from which the items are returned. Unlike tuples, you can add() items to a set. A set wil...
true
8b9d573be4b1eebe8a6d3ee66252f8c3442890a0
sashakrasnov/datacamp
/29-statistical-simulation-in-python/2-probability-and-data-generation-process/03-game-of-thirteen.py
1,668
4.40625
4
''' Game of thirteen A famous French mathematician Pierre Raymond De Montmart, who was known for his work in combinatorics, proposed a simple game called as Game of Thirteen. You have a deck of 13 cards, each numbered from 1 through 13. Shuffle this deck and draw cards one by one. A coincidence is when the number on t...
true
d2f59c0803cbe2036e08d903216d7fb254a8fa1b
sashakrasnov/datacamp
/29-statistical-simulation-in-python/1-basics-of-randomness-and-simulation/05-simulating-the-dice-game.py
1,556
4.46875
4
''' Simulating the dice game We now know how to implement the first three steps of a simulation. Now let's consider the next step - repeated random sampling. Simulating an outcome once doesn't tell us much about how often we can expect to see that outcome. In the case of the dice game from the previous exercise, it's...
true
f8bf2d9477abd2cfef2629ad87f03ce171d34e26
sashakrasnov/datacamp
/22-network-analysis-in-python-1/3-structures/01-identifying-triangle-relationships.py
2,208
4.125
4
''' Identifying triangle relationships Now that you've learned about cliques, it's time to try leveraging what you know to find structures in a network. Triangles are what you'll go for first. We may be interested in triangles because they're the simplest complex clique. Let's write a few functions; these exercises wi...
true
fd12b8f0353d46fac24d7d2efd50ba1185a290a5
sashakrasnov/datacamp
/07-cleaning-data-in-python/4-cleaning-data-for-analysis/06-custom-functions-to-clean-data.py
2,461
4.21875
4
''' Custom functions to clean data You'll now practice writing functions to clean data. The tips dataset has been pre-loaded into a DataFrame called tips. It has a 'sex' column that contains the values 'Male' or 'Female'. Your job is to write a function that will recode 'Male' to 1, 'Female' to 0, and return np.nan f...
true
b754d2966c71ec0c22f1af9caa7bdf933f8c3616
sashakrasnov/datacamp
/11-analyzing-police-activity-with-pandas/1-preparing-the-data-for-analysis/03-dropping-rows.py
1,300
4.46875
4
''' Dropping rows When you know that a specific column will be critical to your analysis, and only a small fraction of rows are missing a value in that column, it often makes sense to remove those rows from the dataset. During this course, the driver_gender column will be critical to many of your analyses. Because on...
true
c6c9a3c3dc132e3cfb2cfc349f23350c9d163dba
sashakrasnov/datacamp
/04-python-data-science-toolbox-2/3-bringing-it-all-together!/07-writing-a-generator-to-load-data-in-chunks-3.py
1,737
4.46875
4
''' Writing a generator to load data in chunks (3) Great! You've just created a generator function that you can use to help you process large files. Now let's use your generator function to process the World Bank dataset like you did previously. You will process the file line by line, to create a dictionary of the co...
true
5ca7c9d133c9dcf4a63deed0f3741827294f3203
sashakrasnov/datacamp
/32-introduction-to-pyspark/2-manipulating-data/03-selecting.py
1,895
4.5
4
''' The Spark variant of SQL's SELECT is the .select() method. This method takes multiple arguments - one for each column you want to select. These arguments can either be the column name as a string (one for each column) or a column object (using the df.colName syntax). When you pass a column object, you can perform o...
true
6ed2d41343506384911094ba689c134531af95a4
sashakrasnov/datacamp
/26-manipulating-time-series-data-in-python/4-putting-it-all-together-building-a-value-weighted-index/03-import-index-component-price-information.py
1,973
4.125
4
''' Import index component price information Now you'll use the stock symbols for the companies you selected in the last exercise to calculate returns for each company. ''' import pandas as pd import matplotlib.pyplot as plt listings = pd.read_excel('../datasets/stock_data/listings.xlsx', sheet_name='nyse', na_value...
true
7056ea7898204358ce56b6d531df2f3fe587ffcb
sashakrasnov/datacamp
/10-merging-dataframes-with-pandas/2-concatenating-data/04-concatenating-pandas-dataframes-along-column-axis.py
2,317
4.15625
4
''' Concatenating pandas DataFrames along column axis The function pd.concat() can concatenate DataFrames horizontally as well as vertically (vertical is the default). To make the DataFrames stack horizontally, you have to specify the keyword argument axis=1 or axis='columns'. In this exercise, you'll use weather dat...
true
0a7757a9fa33be538833f52f832c9872ff36c672
sashakrasnov/datacamp
/10-merging-dataframes-with-pandas/1-preparing-data/04-sorting-dataframe-with-the-index-and-columns.py
2,593
4.96875
5
''' Sorting DataFrame with the Index & columns It is often useful to rearrange the sequence of the rows of a DataFrame by sorting. You don't have to implement these yourself; the principal methods for doing this are .sort_index() and .sort_values(). In this exercise, you'll use these methods with a DataFrame of tempe...
true
32de5c51962ed107e39b8c67a51b85be88214d39
sashakrasnov/datacamp
/27-visualizing-time-series-data-in-python/4-work-with-multiple-time-series/01-load-multiple-time-series.py
1,332
4.125
4
''' Load multiple time series Whether it is during personal projects or your day-to-day work as a Data Scientist, it is likely that you will encounter situations that require the analysis and visualization of multiple time series at the same time. Provided that the data for each time series is stored in distinct colu...
true
0b8caa4f6f082d1f8c456b94dc1e87903a66f69e
sashakrasnov/datacamp
/24-data-types-for-data-science/2-dictionaries--the-root-of-python/04-adding-and-extending-dictionaries.py
2,763
4.65625
5
''' Adding and extending dictionaries If you have a dictionary and you want to add data to it, you can simply create a new key and assign the data you desire to it. It's important to remember that if it's a nested dictionary, then all the keys in the data path must exist, and each key in the path must be assigned indi...
true
bbfd20e82c8d9bfe591e3345ed94c2e94702eb7e
sashakrasnov/datacamp
/12-introduction-to-databases-in-python/4-creating-and-manipulating-your-own-databases/06-updating-individual-records.py
2,179
4.28125
4
''' Updating individual records The update statement is very similar to an insert statement, except that it also typically uses a where clause to help us determine what data to update. You'll be using the FIPS state code using here, which is appropriated by the U.S. government to identify U.S. states and certain other...
true
9d47888970d4d2bba4d9555352eb0a23c2e17a2d
sashakrasnov/datacamp
/18-linear-classifiers-in-python/3-logistic-regression/01-regularized-logistic-regression.py
1,519
4.1875
4
''' Regularized logistic regression In Chapter 1 you used logistic regression on the handwritten digits data set. Here, we'll explore the effect of L2 regularization. The handwritten digits dataset is already loaded, split, and stored in the variables X_train, y_train, X_valid, and y_valid. The variables train_errs an...
true
4d1c8c000e06f5459daf9ce36ffc09a46bab346d
sashakrasnov/datacamp
/17-supervised-learning-with-scikit-learn/1-classification/02-k-nearest-neighbors-predict.py
2,532
4.28125
4
''' k-Nearest Neighbors: Predict Having fit a k-NN classifier, you can now use it to predict the label of a new data point. However, there is no unlabeled data available since all of it was used to fit the model! You can still use the .predict() method on the X that was used to fit the model, but it is not a good indi...
true
b574a6df1c7c3fda951b2db54dee2bf19c76a8db
geohotweb/programing
/ecuaciones/leyendo_numeros.py
279
4.34375
4
#Este programa va leyendo numeros y mostrandolos por pantalla mientras los numeros que se introducen sean positivos. num = int(input('Introduce un numero: ')) while num >= 0: print(num) num = int(input('Introduce otro numero: ')) print('Ha finalizado mi trabajo, adiós!.')
false
aa1b56ed11db7fd4ed50f0346226807a05b6db15
geohotweb/programing
/ecuaciones/vocales_consonantes.py
664
4.125
4
#Este programa determina si el caracter introducido es vocal mayuscula o vocal minuscula y si es consonante mayuscula o minuscula tambien dice si hay un caraccter desconocido. #! usr/bin/python letra_o_vocal = input('Introduce la primera vocal o consonante: ') mayusculas1 = 'BCDFGHJKLMNPQRSTVWXYZ' minusculas1 = 'bcd...
false
eda2584a11a3e4fb1a77f8082ce455df3b4c4713
Xinyuan-wur/algorithms-in-bioinformatics
/clustering/assignment_kmeans_skeleton.py
1,917
4.25
4
#!/usr/bin/env python """ Author: Student number: Implementation of the k-means clustering algorithm Hints: - write a function to obtain Euclidean distance between two points. - write a function to initialize centroids by randomly selecting points from the initial set of points. You can use the random.sample() me...
true
c162c550ba25f29822159f0c4fca5421e1dedd37
12reach/PlayWithPython
/primary/functions.py
1,622
4.6875
5
#!/usr/bin/python3 # functions and parameters are two important part of a program # a function do the repetitive job so that we need not write same thing more and more # functions do many things # we will see it later in our detailed functions series # let us define a function that pass two parameters and those param...
true