blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
07a6b7202e6a4239a126ea03abfd36cae136c410
programiranje3/v2020
/Lab7/lab7.py
12,032
3.765625
4
from pathlib import Path from sys import stderr import csv import pickle import shelve # # Task 1 # # Write a function that reads in the content of the given text file, sorts it, # and writes the (sorted) content to new textual files. # Assume that the content of the given file consists of file names, some # of which ...
7c5051c7f7d4aab25671abaf06daec319d6e5882
programiranje3/v2020
/Lab8/lab8.py
8,734
4.21875
4
# # The task is to write a Python program (script) that determines which countries # gave the largest number of athletes who are considered to be among the 100 greatest # sport stars ever. # To that end, the program should do the following: # - collect names of the "100 Greatest Sport Stars Ever" from: # https://ivan...
154def32f16bb73f034597476d75d721daea11cd
poros/talk-write-more-decorators-and-fewer-classes
/intro/enum_example.py
114
3.53125
4
from enum import Enum Color = Enum("Color", ("RED", "GREEN", "BLUE")) >>> print(repr(Color.RED)) <Color.RED: 1>
cbd3efab6ae2e7f0b0156fc95361cc715a1cd5f1
OfekMerhav/AdvancedCalculator
/calculator_variables.py
963
3.796875
4
""" calculator_variables modulo which contains the calculator variables """ """"""""""""""""""""""""" CALCULATOR VARIABLES """"""""""""""""""""" # WARNING: Don't include brackets ([]) in the opening/closing set opening_parentheses_set = ['('] closing_parentheses_set = [')'] IN_CAL...
24fbf318ccb55a4e5e70ee587167cd8e23106990
wesenu/python_basics
/part7/thread_Queue.py
828
3.734375
4
from multiprocessing import Process, Queue def pow_square(value, queue): for i in value: queue.put(i*i) def pow_cube(value, queue): for i in value: queue.put(i*i*i) if __name__ == "__main__": my_numbers = range(3) queue = Queue() process_pow_square = Process(target=pow_square,...
295e88280784b96ed46df24db16bea9513de05cb
wesenu/python_basics
/part5/operations_overloading_5_1.py
892
3.53125
4
class TestAttribute: def __init__(self, name): self.name = name def __getattr__(self, item): print("in __getattr__") if item == "age": self.__dict__[item] = 3 return self.__dict__[item] else: raise AttributeError(item) def __setattr__(sel...
e1ccdb176b914df1fd8f082d04549e6f41fdbf13
ungsur/CSAinPython
/fibonaccifuncs.py
1,078
3.734375
4
from functools import lru_cache from typing import Generator def fib1(n): if n < 2: return n else: return fib1(n-2) + fib1(n-1) def fib2(n): cache = {0:0,1:1} if n not in cache.keys(): cache[n] = fib2(n-2) + fib2(n-1) return cache[n] @lru_cache(maxsize=None) def fib3(n): ...
8ecad4af5221e4ce75f180dc2c840431af35cbf6
shubs202k/Machine-Learning-A-Z
/Data Preprocessing/S_Data_Preprocessing_Template.py
868
3.78125
4
#Data Preprocessing #Importing the Libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #Importing the Dataset dataset = pd.read_csv('Data.csv') X = dataset.iloc[:,:-1].values #take all columns except last one Y = dataset.iloc[:,3].values #take values of last column #Splitting the Dataset...
cddc10f2fb3571e8d55ac0bc8393f5fe1aabd2cb
Priyojeet/man_at_work
/python_100/string_manipulation1.py
322
4.34375
4
# Write a Python program to remove the nth index character from a nonempty string. def remove_char(str, n): slice1 = str[:n] slice2 = str[n + 1:] #print(slice1) #print(slice2) return slice1 + slice2 l = str(input("enter a string:-")) no = int(input("enter a number:-")) print(remove_char(l, no)...
c12c56e3edd5621df90ef80810d5e44b8bb28685
Priyojeet/man_at_work
/se2tsk1ex2.1.py
141
3.90625
4
l = [] s = str(input("enter the string:-")) for i in s: l.append(i) print(l) # comprehension char_l = [char for char in s] print(char_l)
97a822a515d3434b42b402aebbcb5513b01334f4
Priyojeet/man_at_work
/python_100/decision_making_nested_if_else.py
562
4.125
4
# check prime number with nested loop number = eval(input("enter the number you want:-")) if(isinstance(number,str)): print(" please enter an integer value") elif(type(number) == float): print("you enter a float number") else: if (number <= 0): print("enter an integer grater then 0") elif (numb...
b9524a0c8ca767b6a3938b2e63d2d5bd47326603
Priyojeet/man_at_work
/python_100/decesion_making.py
555
4.03125
4
"""Decision making is anticipation of conditions occurring while execution of the program and specifying actions taken according to the conditions. Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome. You need to determine which action to take and which statements to execute if out...
d1ffc011daf5da403f8f25d2458315735a8ef92c
Priyojeet/man_at_work
/se2tsk1es1.2.py
566
4.03125
4
def myfilter(func, arg): l = [] for i in arg: if func(i): l.append(i) return l def isprime(arg): prime = True if(arg>1): for i in range(2, arg): if(arg%i == 0): prime = False if(prime==True): return True ...
c0a12260a9ce9f8740e2442d8106c9bc81d397ba
Priyojeet/man_at_work
/Practice_files/fibonacci.py
501
3.9375
4
def fib(n): a = int(input("enter the 1st number:-")) b = int(input("enter the 2nd number:-")) print(a,b,end=" ") while(n-2): c = a+b a = b b = c print(c, end=" ") n = n-1 fib(6) def fib_rec(n): if(n<=1): return n else: return(fib_rec(n-1) ...
0f5a46b0d892f763d7f40d1eb6244dbbfe802122
Priyojeet/man_at_work
/python_100/recursion_geomatric.py
187
3.625
4
# program to calculate the geometric sum of n-1. def sum(r, n): if n < 2: return 1 else: geoSum = r**(n-1) geoSum += sum(r, n-1) return geoSum print(sum(2,7))
0847ac51eabd0a047489f4363b77302c67103d2d
Priyojeet/man_at_work
/Practice_files/checkNo_inList.py
152
3.65625
4
def is_group(group_data, n): for value in group_data: if n == value: return True return False print(is_group([1,2,3,4], 3))
14fa9e83d1626740b76aaef3bd4b291ff2a37e64
Priyojeet/man_at_work
/Practice_files/count_length.py
392
4.03125
4
l = int(input("enter the length of your list:-")) lst =[] for i in range(l): element = int(input("enter the elements you want:-")) lst.append(element) def count_length(arg): count=0 for j in arg: count+=1 print(count) '''def while_count(arg): count = 0 while(arg[count] != None): ...
1ba2fd1762f2610f15ab1300411d724b3d36a70b
Priyojeet/man_at_work
/Practice_files/sum_ofFirstn.py
207
3.796875
4
import sys def sum(arg): sum_num = (arg*(arg+1))/2 return sum_num try: n = int(input("enter the number you want:-")) except: error= sys.exc_info()[0] print(error) else: print(sum(n))
a9f5beaab50f1d1ba130b530f75706910f8f7d48
felixjchen/learning
/algos/rollDice.py
636
3.71875
4
pipsPerDice = 6 def cost(dice): pipCount = [0] * pipsPerDice # Get all dice states, O(n) for i in dice: pipCount[i-1] += 1 print(pipCount) minCost = float("inf") # O(1) for i in range(0, pipsPerDice): # opposite side of the dice has highest cost, x2 cost opposite...
65c53d20185adb62aca775c76b64bed8e5cf87d9
Mboso87/PROVE_PYTHON
/ESEMPIO_gestione_ERR.py
439
3.640625
4
def divisore(a,b): try: ris=a/b print('risultato=' +str(ris)) except ZeroDivisionError: print('errore divisore = 0') divisore(9,4) divisore(7,0) def moltiplic(): try: a=int(input("metti a: ")) b=int(input("metti b: ")) ris=a*b prin...
57c946e54caa1457540c145297bbe8475192f6fb
xunihao1993/haohao_code
/练习/类方法.py
1,150
3.953125
4
# -*- coding: utf-8 -*- class Person: def eat(self): print("麻辣时我的最爱") # 使用装饰器 classmethod 修饰的方法 就是类方法 @classmethod def test(cls): # cls 表示当前类 print('类方法 test') print(cls) @classmethod def create(cls): p=cls() p.age = 1 return p Person.te...
90451a31951fea1bad672f59763b3146f6b162d7
xunihao1993/haohao_code
/练习/类的内置函数.py
777
3.8125
4
# -*- coding: utf-8 -*- class Person: def __init__(self,name): self.name=name def __setattr__(self, key, value): # 当设置对象成员属性的时候,系统会自动调用 print(key,value) def __getattr__(self,item): #访问不存在的属性时,系统会自动调用 print(item) return 123 def __delattr__(self,item): ...
fadeb5f63fcaeb8aaaaa350317bd786e3ee72444
chreib/snakepy
/worm.py
1,898
3.546875
4
from direction import Direction def circular(v, upper_value): if v < 0: return upper_value elif v > upper_value: return 0 else: return v class Worm: # positions: von links oben nach unten, rechts def __init__(self,color,start_position,size_fields): self.COLOR = col...
fec4237326076e8a4441282bdf09b00660f03cdc
mambosambatango/my_second_js
/bubble_sort.py
295
3.546875
4
data = [6, 15, 4, 2, 8, 5, 11, 9, 7, 13] for i in range(len(data)): for j in range(len(data) - i - 1): # ソート済みの部分以外でループ if data[j] > data[j + 1]: # 前のほうが大きいとき data[j], data[j + 1] = data[j + 1], data[j] print(data)
0862a345a5b5422d0e062f977015a95ef4ad3f3b
dipsuji/coding_pyhton
/coding/flatten_tree.py
1,266
4.1875
4
class Node: """ create node with lest and right attribute """ def __init__(self, key): self.left = None self.right = None self.val = key def print_pre_order(root): """ this is pre order traversal """ if root: # First print the data of root print...
44e6ef8dd8212448ed8684262c52fcc71da35d4e
dipsuji/coding_pyhton
/udemy_leetcode/Hash Map Facebook Interview Questions solutions/majority_element.py
846
4.1875
4
""" - https://leetcode.com/problems/majority-element/ Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Exa...
52a44cb7207fc30dde637cd917fd6e4f03957d04
dipsuji/coding_pyhton
/udemy_leetcode/Google Interview Questions solutions/move_zeros.py
1,038
4.03125
4
# from typing import List # # # class Solution: # """ # Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. # Example 1: # # Input: nums = [0,1,0,3,12] # Output: [1,3,12,0,0] # # Example 2: # # Input: nums = [...
e250d9ab7c2d2b4b83156eea29c6872b2ac1252a
dipsuji/coding_pyhton
/coding/fibonacci.py
476
3.953125
4
def fibi(n): """ Nth Fibonacci Fn = Fn-1 + Fn-2 :param n: :return: """ a, b = 0, 1 for i in range(n): # fibonacci series is next no. is sum of previous two number. temp = a a = b # now nth fibonacci no. is sum of previous two number. b = temp+b ...
0045f7f9c3c0e13656f0b5f5c815f7cb17ac13bc
dipsuji/coding_pyhton
/udemy_leetcode/Microsoft Interview Questions solutions/missing_number.py
1,121
4.15625
4
from typing import List """ Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the mi...
4fa06084ae496eabeb8a8d60beec75e8f12c7711
lehmanwics/programming-interview-questions
/src/general/Python/17_numbers_to_words.py
4,890
4.21875
4
""" Numbers to words.py Author: Raymond Perez (github.com/Raymond-P) Description: given a number write it out in words. Only supports natural numbers (positive ints). Logic: Our number system in english has a few general rules* when it comes to naming a number. 1- unique names: -numbers 0-19 -decimals...
77e3b9062540fd72f2a1deb8f3ccf652d982ad0d
lehmanwics/programming-interview-questions
/src/general/Python/4_fibonachi_numbers.py
1,402
4.28125
4
""" 4. Write fibonacci iteratively and recursively (bonus: use dynamic programming) """ # Fibonachi recursively (function calls itself) def fib(nth_number): if nth_number == 0: return 0 elif nth_number == 1: return 1 else: return fib(nth_number-1) + fib(nth_number - 2) ...
f1f67d3ede1b29d5fac288d562d648fc1952b017
nharinathreddy/EVA4
/Modules/train_model.py
2,000
3.6875
4
'''Train model function in PyTorch. Training your deep learning model Reference: [1] No References ''' from tqdm import tqdm class train: def __init__(self): self.train_losses = [] self.train_acc = [] # Training def execute(self,net, device, trainloader, optimizer, criterion,epoch):...
242b623a7a7ce971e299c3aafa24473fbd240dac
Wonseokkyang/RLCatMouse
/env.py
12,551
3.5
4
"""##################################################################### ## RL Cat and Mouse - environment ## ######################################################################## # # Name: Won Seok Yang # ## PRE: # Maze environment for RL cat and mouse game. # Respon...
26b113c1d0386dd0c66ffc7cea05dbd13e185802
Mandelliant/folder-to-repo
/librarian/librarian/book_class.py
1,081
3.59375
4
import csv import random class Book(object): def __init__(self): self.csvfile = r'/Code files/Nextbook/library.csv' def what_book(self): with open(self.csvfile, 'rt') as f: reader = csv.DictReader(f) rows = [row for row in reader if row['status'] == 'to read'.lower()] ...
6ddf6f86eb14d11cf933ab710ba9da94939a68dd
KevinGage/MachineLearning
/py_flappybird/bird.py
2,588
3.5
4
import pyglet.app class bird(): def __init__(self, x, y, max_y, batch, size = 25 ): self.score = 0 self.high_score = 0 self.start_x = x self.start_y = y self.x = x self.y = y self.max_y = max_y self.gravity = 0.6 self.lift = 10 self.velocity = 0 self.size = size self....
053d66fcdc03b6ebda66a44e303cc70d8f3e062b
KevinGage/MachineLearning
/py_MountainCar_Q/main.py
6,245
4
4
#!/usr/bin/python3 import gym import numpy as np import matplotlib.pyplot as plt # import the game env = gym.make("MountainCar-v0") # reset and initialize the game env.reset() # define a learning rate LEARNING_RATE = 0.1 # how important are future rewards over current rewards? DISCOUNT = 0.95 # how many episodes to...
41092aa4f8271ecf8cd4796339ef70a70017ac4e
S1rK/AI-Ex2
/Data/Example.py
1,284
3.609375
4
from typing import Dict, KeysView class Example(object): __features: Dict[str, str] def __init__(self, features: Dict[str, str]): """ :param features: a dictionary between attributes and their values (including the class/label) """ self.__features = features def __getitem...
935726112481fa8173f8e4bc7a817225d123d126
sarma5233/pythonpract
/python/operators.py
2,108
4.40625
4
a = 10 b = 8 print("ARITHMETIC operators") print('1.Addition') print(a+b) print() print('2.subtraction') print(a-b) print('3.Multiplication') print(a*b) print('4.Division') print(a/b) print('5.Modulus') print(a%b) print('6.Exponentiation') print(a**b) print('7.floor Division') print(a//b) print("Comparision Operators"...
ca4e63fd884d441ca7d97abdbccec71b342e0fb5
sarma5233/pythonpract
/flow_controls/if.py
126
4.03125
4
num1 = 100 num2 = 200 if (num1>num2): print("num1 is greater than num2") else: print ("num1 is less than num2")
8fb2558f6f9bed68720ee257727e9be5840cbe0d
sarma5233/pythonpract
/flow_controls/while.py
210
4.15625
4
n = int(input("enter a number:")) sum = 0 total_numbers = 1 while total_numbers <= n: sum += total_numbers total_numbers += 1 print("sum =", sum) average = sum/n print("Average = ", average)
c8ff41d4b83e1b1285f1acde17504d2236b453c6
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e32_flying_home.py
1,297
4.15625
4
""" Flying home The variable flight containing one email subject was loaded in your session. You can use print() to view it in the IPython Shell. Import the re module. Complete the regular expression to match and capture all the flight information required. Only the first parenthesis were placed for you. Find all the m...
1b9c1477a582dddc5858752599c65ac4051f3211
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/14-Cluster Analysis in Python/e11_Visualize_clusters_with_matplotlib.py
1,498
3.921875
4
""" Visualize clusters with matplotlib We have discussed that visualizations are necessary to assess the clusters that are formed and spot trends in your data. Let us now focus on visualizing the footfall dataset from Comic-Con using the matplotlib module. The data is stored in a Pandas data frame, comic_con. x_scaled...
9e4a9dc1e8910efd21605dcb9485cb12c9b00861
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e15_extract_education_levels.py
746
3.796875
4
""" Extract education levels Complete the line that identifies respondents with associate degrees, that is, people with 14 or more years of education but less than 16. Complete the line that identifies respondents with 12 or fewer years of education. Confirm that the mean of high is the fraction we com...
fa7afe7b83e2d11110183c186ed9019e7043d306
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/05-Working_with_Dates_and_Times/e22_how_many_hours_elapsed_around_daylight_saving.py
1,348
4.5625
5
""" How many hours elapsed around daylight saving? Let's look at March 12, 2017, in the Eastern United States, when Daylight Saving kicked in at 2 AM. If you create a datetime for midnight that night, and add 6 hours to it, how much time will have elapsed? You already have a datetime called start, set for March 12, 20...
aebbbf1807433e0e4840a3f06ac99743db2a30b1
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/13-Machine_Learning_with_Tree-Based_Models_in_Python/e5_entropy_vs_gini_index.py
1,420
3.953125
4
""" Entropy vs Gini index In this exercise you'll compare the test set accuracy of dt_entropy to the accuracy of another tree named dt_gini. The tree dt_gini was trained on the same dataset using the same parameters except for the information criterion which was set to the gini index using the keyword 'gini'. X_test, ...
afb5a251bfa0ba326669aa7ae14f0004c54d914e
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/12-Introduction_to_Deep_Learning_in_Python/e1_coding_the_forward_propagation_algorithm.py
1,574
4.375
4
""" Coding the forward propagation algorithm The input data has been pre-loaded as input_data, and the weights are available in a dictionary called weights. The array of weights for the first node in the hidden layer are in weights['node_0'], and the array of weights for the second node in the hidden layer are in weigh...
a5437c79e37d03fd36f379c41ee2f84ea191bb79
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/02-python-data-science-toolbox-part-2/e33_writing_an_iterator_to_load_data_in_chunks3.py
1,534
4.15625
4
""" Writing an iterator to load data in chunks (3) The packages pandas and matplotlib.pyplot have been imported as pd and plt respectively for your use. Instructions 100 XP Write a list comprehension to generate a list of values from pops_list for the new column 'Total Urban Population'. The output expression ...
c1a72827d922ed8468dd66d50a7c0d2d4c897ce8
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/02-python-data-science-toolbox-part-2/e18_list_comprehensions_vs_generators.py
1,679
4.5
4
""" List comprehensions vs generators generators does not store data in memnory like list if there a very large list then use generators. There is no point in using large list instead use generators In this exercise, you will recall the difference between list comprehensions and generators. To help with that task, t...
7278153d5148595cd0bc4cfb92ccef72cd4706c7
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/10-Supervised_Learning_with_scikit-learn/e28_centering_and_scaling_your_data.py
1,912
4.28125
4
""" Centering and scaling your data You will now explore scaling for yourself on a new dataset - White Wine Quality! Hugo used the Red Wine Quality dataset in the video. We have used the 'quality' feature of the wine to create a binary target variable: If 'quality' is less than 5, the target variable is 1, and otherwi...
8e49e89f6da5a4604e291e890242918923f64497
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/06-Writing_Functions_in_Python/e18_understanding_the_scope.py
235
3.609375
4
""" Understanding scope What four values does this script print? """ x = 50 def one(): x = 10 def two(): global x x = 30 def three(): x = 100 print(x) for func in [one, two, three]: func() print(x)
246c365f2c3f7f10c249933ead07532244770291
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/03-cleaning_data_in_python/e36_pairs_of_restaurants.py
1,325
4.125
4
""" in this exercise, you will perform the first step in record linkage and generate possible pairs of rows between restaurants and restaurants_new. Both DataFrames, pandas and recordlinkage are in your environment. Instructions Instantiate an indexing object by using the Index() function from recordlinkage. ...
e8024d1b1c160807b8133e08f1f7872b94537a56
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e18_comparing_cdfs.py
857
3.765625
4
""" Comparing CDFs Evaluate the normal cumulative distribution function using dist.cdf. Use the Cdf() function to compute the CDF of log_income. Plot the result. """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy import stats from empiricaldist import Cdf from scipy.sta...
5b718cdb7f238284afaa3e3a5080213062c4bf15
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e3_palindromes.py
782
4.28125
4
""" The text of a movie review for one example has been already saved in the variable movie. You can use print(movie) to view the variable in the IPython Shell. Instructions 100 XP Extract the substring from the 12th to the 30th character from the variable movie which corresponds to the movie title. Store it ...
8ed952e9af6654f4bc6ab7ddd570bc06a677c0e7
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e26_computing_correlations.py
529
3.75
4
""" Computing correlations From the brfss DataFrame, select the columns 'AGE', 'INCOME2', and '_VEGESU1'. Compute the correlation matrix for these variables. """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy import stats from empiricaldist import Pmf from scipy.stats import...
d4cf7f2383afe7107d2218d684df69e3f9e4c9e8
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/05-Working_with_Dates_and_Times/e16_the_long_and_the_short_of_why_time_is_hard.py
1,779
4.46875
4
""" The long and the short of why time is hard As before, data has been loaded as onebike_durations. Calculate shortest_trip from onebike_durations. Calculate longest_trip from onebike_durations. Print the results, turning shortest_trip and longest_trip into strings so they can print. """ from datetime im...
864eec9f94be641ef1dc93b9b3866f15a0d4ae20
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/12-Introduction_to_Deep_Learning_in_Python/e6_scaling_up_to_multiple_data_points.py
2,345
3.6875
4
""" Scaling up to multiple data points Instructions 100 XP Import mean_squared_error from sklearn.metrics. Using a for loop to iterate over each row of input_data: Make predictions for each row with weights_0 using the predict_with_network() function and append it to model_output_0. Do ...
9aa4a68742400f5dff59647d53bfb1e0e7d91a14
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e32_making_predictions.py
1,169
4.21875
4
""" Making predictions At this point, we have a model that predicts income using age, education, and sex. Let's see what it predicts for different levels of education, holding age constant. Using np.linspace(), add a variable named 'educ' to df with a range of values from 0 to 20. Add a variable named 'age' ...
1f649c93ee146f5365f9fc18fc79fdc50d783139
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e22_jittering.py
739
3.53125
4
""" Jittering Add random noise to age with mean 0 and standard deviation 2.5. Make a scatter plot between weight and age with marker size 5 and alpha=0.2. Be sure to also specify 'o'. """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy import stats from empiricaldist import P...
7e486404b32bb6b34085ee5fc263fbb2437cd3b6
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/09-Statistical_Thinking_in_Python_Part2/e7_linear_regression_on_appropriate_anscombe_data.py
1,403
4.125
4
""" Linear regression on appropriate Anscombe data Compute the parameters for the slope and intercept using np.polyfit(). The Anscombe data are stored in the arrays x and y. Print the slope a and intercept b. Generate theoretical and data from the linear regression. Your array, which you can create with np.array(), sh...
dab0d9344df34e3f0730c2b87683c050d701e011
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/04-regular_expression_in_python/e2_artificial_reviews.py
1,271
4.15625
4
""" The text of two movie reviews has been already saved in the variables movie1 and movie2. You can use the print() function to view the variables in the IPython Shell. Remember: The 1st character of a string has index 0. Instructions Select the first 32 characters of the variable movie1 and assign it to the variabl...
d6edfc93a1be2a9273666d1e38e47276130a0bff
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/11-Unsupervised_Learning_in_Python/e26_NMF_learns_topics_of_documents.py
6,280
3.65625
4
""" NMF learns topics of documents The NMF model you built earlier is available as model, while words is a list of the words that label the columns of the word-frequency array. After you are done, take a moment to recognise the topic that the articles about Anne Hathaway and Denzel Washington have in common! Instructi...
886f69bac93d63239264b2acc16d8de3e172821f
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/13-Machine_Learning_with_Tree-Based_Models_in_Python/e10_evaluate_the_10_fold_cv_error.py
1,976
3.71875
4
""" Evaluate the 10-fold CV error In this exercise, you'll evaluate the 10-fold CV Root Mean Squared Error (RMSE) achieved by the regression tree dt that you instantiated in the previous exercise. In addition to dt, the training data including X_train and y_train are available in your workspace. We also imported cross...
d602de2e2931e2c8118ad2c75b1d05470b712c4c
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/14-Cluster Analysis in Python/e21_Extract_RGB_values_from_image.py
1,007
3.984375
4
""" Extract RGB values from image There are broadly three steps to find the dominant colors in an image: Extract RGB values into three lists. Perform k-means clustering on scaled RGB values. Display the colors of cluster centers. To extract RGB values, we use the imread() function of the image class of ma...
920c150afcb96d1a8948bd69e0f6b639ced54324
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/05-Working_with_Dates_and_Times/e33_how_long_per_weekday.py
969
4.09375
4
""" How long per weekday? Pandas has a number of datetime-related attributes within the .dt accessor. Many of them are ones you've encountered before, like .dt.month. Others are convenient and save time compared to standard Python, like .dt.weekday_name. Add a new column to rides called 'Ride start weekday', which...
b6eb4dde3b6ef947df4922a52e971102397f01e9
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/07-Exploratory_Data_Analysis_in_Python/e7_compute_birth_weight.py
818
4.3125
4
""" Compute birth weight Make a Boolean Series called full_term that is true for babies with 'prglngth' greater than or equal to 37 weeks. Use full_term and birth_weight to select birth weight in pounds for full-term babies. Store the result in full_term_weight. Compute the mean weight of full-term bab...
da0366075c5a0e96f901397e25cf0eeb5f4b2801
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/08-Statistical_Thinking_in_Python_Part1/e11_comparing_percentiles_to_ecdf.py
1,881
3.671875
4
""" Comparing percentiles to ECDF The percentile variables from the previous exercise are available in the workspace as ptiles_vers and percentiles. Note that to ensure the Y-axis of the ECDF plot remains between 0 and 1, you will need to rescale the percentiles array accordingly - in this case, dividing it by 100. ...
bd179cd04a97772c6f5259058da94cc31412fb7e
sarmabhamidipati/UCD
/Specialist Certificate in Data Analytics Essentials/DataCamp/14-Cluster Analysis in Python/e20_FIFA_18_defenders_revisited.py
1,865
3.640625
4
""" FIFA 18: defenders revisited These are typically defense-minded players. In this exercise, you will perform clustering based on these attributes in the data. The following modules have been pre-loaded: kmeans, vq from scipy.cluster.vq, matplotlib.pyplot as plt, seaborn as sns. The data for this exercise is stored ...
a293865d2d7368e0fe57a7677018b9df969bbb04
jwlibre/web_scraping
/web_scrape_1.py
867
3.59375
4
import requests from bs4 import BeautifulSoup import pdb page = requests.get("https://www.bbc.co.uk/news") # create an instance of the BeautifulSoup class, which will parse the html (content) from the requests response soup = BeautifulSoup(page.content, 'html.parser') # puts the html content into a nicer format with...
fef3d8a8eb810bfeebd65a7951b14f2f55c514c8
DiniH1/python_concatenation_task
/python_concactination_task.py
507
4.21875
4
# Task 1 name = "" name = input("What is your name? ") name_capitalize = name.capitalize() print(name_capitalize + " Welcome to this task!") # Task 2 full_name = "" full_name = input('What is your full name? ') first_name = (full_name.split()[0]) first_name_capitalize = first_name.capitalize() last_name = (full_name.s...
49bd02e0ac41e779a6a195e6d1b690f69e809921
TheeSolomon/Finished-Miniprojects
/Blackjack Game.py
10,849
3.96875
4
import random # Global Variables for defining the cards. suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs') ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Te...
e4df22a91b02ed4743b788e39444beb4dfb62a1d
vumbumy/programmers
/coding_test_2/quiz1.py
743
3.578125
4
def merge(s1, s2, min_len): for i in range(min_len): b = s1[len(s1) - min_len + i:] f = s2[:min_len - i] if b == f: return s1[:len(s1) - min_len + i] + b + s2[min_len - i:] return s1 + s2 def solution(s1, s2): min_len = min(len(s1), len(s2)) merge1 = merge(s1, s2,...
9bc5de64618ae357462a943f0111ed7772a21ec3
aashu122/codex
/prac2.py
2,785
3.71875
4
"""strg = "hello my name is ashu" def ctr(s): d = {} for i in s: if i in s: d[i] = d[i] + 1 else: d[i] = 1 print("All character is strg" + str(d)) print(ctr(strg)) """ # install modules """from sys import modules for num, module_name in enumerate(modules): prin...
2ae3f62714952207aaf401db24a148f92a9871d1
AtxTom/Election_Analysis
/PyPoll.py
1,017
4.125
4
# The data we need to retrieve. # 1. The total number of votes cast # 2. A complete list of candidates who received votes # 3. The percentage of votes each candidate won # 4. The total number of votes each candidate won # 5. The winner of the election based on popular vote. # Add our dependencies. import csv import o...
7e8f6f3ac32a80f9dd3d694b9bd3473aa34e90e1
lengfc09/Financial_Models
/NLP/Codes/code-gensim-120-doc2vec.py
2,319
3.8125
4
# This script illustrates doc2vec in gensim. Actually this is more of # a collection of code snippets, not really a runnable script. In this # example, we assume that we're interested in sentence-level data (not # document-level data; in any case, the code would stay very similar # if you update it to work on whole doc...
8cc535e9b57f4e15670a79635f3306ec971dbc94
lengfc09/Financial_Models
/NLP/Codes/code-nltk-NER.py
2,186
3.9375
4
# This file shows how to do named entity recognition (NER) using NLTK. import nltk sentence = '''In Hong Kong, I like to ride the MTR to visit the HK Space Museum and some restaurants rated well by Andy Hayler.''' to_sentence = nltk.word_tokenize(sentence) ta_sentence = nltk.pos_tag(to_sentence) # Tag the...
fceebe8dfa503b1bfe1925f59e1a06c7f14a3851
lengfc09/Financial_Models
/NLP/Codes/code-sklearn-k-means-clustering.py
792
4.3125
4
# This script illustrates how to use k-means clustering in # SciKit-Learn. from sklearn.cluster import KMeans import numpy as np # We create a numpy array with some data. Each row corresponds to an # observation. X = \ np.array( [[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], ...
ac7d5491c2ed052cbc296be4e0b00ea7f4a7554c
Asana-sama/Learn5
/Task1.py
799
4.1875
4
# Создать программно файл в текстовом формате, записать в него построчно данные, # вводимые пользователем. Об окончании ввода данных свидетельствует пустая строка. def file_input(name="task1.txt"): file = open(name, "w") input_string = input("Введите строку:") while (input_string != ""): file.write...
302334f9a7cd8ac3ae4ff61777bc7926899baca4
sanraj99/practice_python
/prime_number.py
509
4.15625
4
# A Prime number can only divided by 1 and itself def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True def getPrimes(max_number): list_of_primes = [] for num1 in range(2, max_number): if is_prime(num1): list_of_primes.app...
27bc4b04ebef70d78bc5b560f0648908488495ec
inwk6312winter2019/week4labsubmissions-RipudamanKaushikDal
/lab5-task6.py
298
3.78125
4
class Point(): def __init__(self,x,y): self.x=x self.y=y def __add__(self,other): if isinstance(other,Point): sum=(self.x+other.x,self.y+other.y) return sum else: sum=(self.x+other[0],self.y+other[1]) return sum p1=Point(3,4) p2=Point(7,3) print(p1 + (4,5)) print(p1 + p2)
2feb2d0f23e7416c2c1cc67c505791cf8e4e052b
Indian-boult/algoexpert-1
/quick-sort/main.py
521
3.90625
4
def quickSort(array): helper(array, 0, len(array) - 1) return array def helper(array, low, high): if (low >= high): return partitionIndex = partition(array, low, high) helper(array, low, partitionIndex - 1) helper(array, partitionIndex + 1, high) return def partition(array, low, high): pivot = ar...
52d2d2e9b4bbaccf017f167b515a7068227b9fce
showell/elm-py
/src/ListKernel.py
1,502
3.8125
4
""" Lists - Each list is actually a series of List instances. """ import functools import itertools @functools.total_ordering class List: def __init__(self, v): self.v = v def __iter__(self): xs = self.v while xs is not None: (h, lst) = xs xs = lst.v ...
07756c70e79e8ecb15994f1649116841b7355b8e
Shivansh-Bajaj/crawler
/crawler/crawler.py
1,808
3.546875
4
import urllib.request from urllib.parse import urlparse,urljoin import re from bs4 import BeautifulSoup import sqlite3 global start_url class crawler(): '''/////////////****************/////////////// //// welcome user //// //////////////////////////////////////////// crawler is class to...
7f1aec9ae9324307aa04639e7c6b6483794e65bc
sourav-gomes/Python
/Part - I/Chapter 9 - File IO/06_practise_03.py
269
3.5
4
for i in range(2, 21): with open(f"/home/joseph/Downloads/python/Chapter 9 - File IO/tables/Multiplication_table_for_{i}.txt", 'w') as f: for j in range(1, 13): f.write(f"{i}x{j}={i*j}") if j != 12: f.write('\n')
44d8081a59bd6ff8b8ca962af866214547273ecb
sourav-gomes/Python
/Part - I/Chapter 4 - List & Tuples/01_lists.py
436
3.84375
4
# Create a list using [] a = [1, 4, 67,23] list1 = [12, "joseph", False,20.99 ] # we can also create list with diff datatypes # Print the list using print() print(a) print(list1) # Accessing list using Index print(a[2], a[0]) print(list1[1],list1[2]) # Change the value of list strings a[3] = 343 print(a) list...
4f97b96ca9683d7dea5defd2201e10d4408b169b
sourav-gomes/Python
/Part - I/Chapter 3 - Strings/03_string_functions.py
854
4.28125
4
story = "once upon a time there was a boy named Joseph who was good but very lazy fellow and never completed any job" # String Functions # print(len(story)) # gives length of the string # print(story.endswith("job")) # returns True or false. In this case True. # print(story.count("a")) # returns how many ...
b79a137c9f02c076e43d751bbaec2b0ede6f6603
sourav-gomes/Python
/Part - I/Chapter 5 - Dictionary & Sets/03_Sets_in_python_and methods.py
1,726
4.375
4
''' a = (1, 2, 3) # () means --> tuple print(type(a)) # prints type --> <class 'tuple'> a = [1, 2, 3] # [] means --> list print(type(a)) # prints type --> <class 'list'> a = {1, 2, 3} # {x, y,....} means --> set print(type(a)) # prints type --> <class 'set'> a = {1:3} # {x:...
967824b5d1c65e646ff24afe713435819315de49
sourav-gomes/Python
/Part - I/Chapter 10 - Object Oriented Programming/02_self.py
955
3.828125
4
class Employer: company = "Microsoft" def getSalary(self, sign): # self is automatically passed. You can pass another print(f"Salary is of the employee working at {self.company} is {self.salary}\n{sign}") # passes signature 'B/R, Joseph' @staticmethod # You can by-pass the 'self' par...
5a40e588576cfd1d0264c4b12bb7b3537af87a6e
sourav-gomes/Python
/Part - I/Chapter 5 - Dictionary & Sets/07_practise_06-08.py
555
3.890625
4
favLang = {} a = input("Enter your favourite computer language Mark: ") b = input("Enter your favourite computer language John: ") c = input("Enter your favourite computer language Anna: ") d = input("Enter your favourite computer language Susan: ") e = input("Enter your favourite computer language Susan: ") favLang['...
9b8caea99975ec46927f77431970f87269c28432
sourav-gomes/Python
/Part - I/Chapter 5 - Dictionary & Sets/04_practise_01.py
487
3.921875
4
myDict = { 'Khata': 'Book', 'Kalam': 'Pen', 'Paani': 'Water' } print('Your options are: ', myDict.keys()) a = input("Enter a Hindi word (from above list):\t") # print('The meaning of your word is:\t', myDict[a]) # Will work but the problem with this statement is that it will throw error when the we input ...
4eac7fb384eed809c5283663274640f79f0ea71b
sourav-gomes/Python
/Part - I/Chapter 3 - Strings/06_practise_02.py
323
4.0625
4
letter = '''\nDear <NAME>,\n Greetings of the day! We are pleased to inform you that you have been selected. Have a great day ahead! Regards, Joseph <DATE> ''' name = input("Enter Your Name: ") date = input("Enter Date: ") letter = letter.replace("<NAME>", name) letter = letter.replace("<DATE>", date) print(lette...
163d43d6b1c1b4c47b031f0197589aedb389e5d3
sourav-gomes/Python
/Part - I/Chapter 4 - List & Tuples/07_practise_02_marks.py
338
3.8125
4
m1 = int(input("Enter marks of Student no. 1: ")) m2 = int(input("Enter marks of Student no. 2: ")) m3 = int(input("Enter marks of Student no. 3: ")) m4 = int(input("Enter marks of Student no. 4: ")) m5 = int(input("Enter marks of Student no. 5: ")) MarksOfStudents = [m1, m2, m3, m4, m5] MarksOfStudents.sort() print...
adab908560428b9b54fdac66d310351b546b8d7b
sourav-gomes/Python
/Part - I/Chapter 7 - Loops in Python/13_practise_10_multiplication-rev.py
184
3.71875
4
# Using while loop n = int(input("Enter a number\n")) t = 12 # while t > 0: # print(f"{n}x{t} = {n*t}") # t -= 1 for t in range(12, 1, -1): print(f"{n}x{t} = {n*t}")
4f4db5c8a8edcaf08af561c7db648cb81ad17215
sourav-gomes/Python
/Part - I/Chapter 9 - File IO/04_practise_01.py
508
4.0625
4
f = open('another.txt') # open file another.txt in read mode by default txt = f.read() ''' # Harry's way of doing it using string functions if 'twinkle' in txt or 'Twinkle' in txt: print("Twinkle is present in the file!") else: print("Twinkle is NOT present in the file!") ''' # Another way of doing it us...
2fb3fd80576640992a6b23c4179e353c9c817bcc
sourav-gomes/Python
/Part - I/Chapter 10 - Object Oriented Programming/07_practise_05.py
1,737
3.828125
4
import random import collections class Train: global s1 s1 = set() # global s def __init__(self, tname, fare, seats): self.name = tname self.fare = fare self.seats = seats for i in range(self.seats): s1.add(i+1) print(f"List just after instantiat...
5ad957791a4a721e101a3a72f28d81d8f3769fd3
lovellup/PicrossSolver
/board.py
1,077
3.5
4
from square import Square from rule import Rule class Board: def __init__(self, dimensions, horizontal_rules, vertical_rules): self.dimensions = dimensions self.board = [] self.validate_rules(horizontal_rules) self.horizontal_rules = horizontal_rules self.validate_rules(ver...
e9af59fe615ccc77d4c80c3014b5033bb56c445d
yanis-fourel/42ai-bootcamp-python
/module02/ex03/csvreader.py
1,453
3.5625
4
import csv class CsvReader(): def __init__(self, filename=None, sep=',', header=False, skip_top=0, skip_bottom=0): try: with open(filename) as f: csvreader = csv.reader(f, delimiter=sep) # for row in csvreader: # print(row) d...
1d9b386690f906834a38e282f015f30f4e690736
yanis-fourel/42ai-bootcamp-python
/module00/ex01/exec.py
236
3.796875
4
import sys from typing import List def reverse_and_swap_case(strings: List[str]) -> str: concact = ' '.join(strings) return concact[::-1].swapcase() if __name__ == '__main__': print(reverse_and_swap_case(sys.argv[1:]))
22f684c1ea3a1f78b58f9b8db35238d5041091ce
suneeshms96/python-password-validator
/python-password-validator.py
795
4.28125
4
digit_count = 0 alpha_count = 0 char_count = 0 lower_count = 0 #we can change password strength requirement here..! required_digit_count = 5 required_alpha_count = 2 required_char_count = 4 required_lower_count = 2 uname = input('Enter your username: ') word = input('Enter a password : ') for w in str(word): if ...
edce6b1ff7f9c76787d540e7a38857f52f4c8e95
vajrang/vsgi
/classes/utils.py
247
3.828125
4
def chunk(lst, num_chunks): """Chunks a given list into number of chunks >>> chunk([0, 1, 2, 3, 4, 5, 6, 7], 3) [[0, 3, 6], [1, 4, 7], [2, 5]] """ retval = [lst[i::num_chunks] for i in range(num_chunks)] return retval
75afc09c87bd6e97ffff7eb9100c8bc2642b0ab6
oleg/incubator
/programming-machine-learning/index.py
2,008
3.671875
4
import numpy as np def load_pizza(): return np.loadtxt('pizza.txt', skiprows=1, unpack=True) def train(x, y, iterations, lr): """ :param x: estimation :param y: ground truth :param iterations: number of iterations :param lr: learning rate :return: """ w = 0 b = 0 for i in...