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
3719399c7bc9bde191d94d4229b0663d90840658
daofeng123/ClassCodes
/d15_plot_axes/p01_ndarray_convert.py
638
3.625
4
import numpy as np # 一组类型相同的元素:ndarray(数据集) : 类型不同的元素:DataFrame(记录) m = np.array([ [1, 2, 3, 4], [3, 4, 5, 6], [5, 6, 7, 8] ]) # print(m.item(11), m[1]) # # print(m.item(1, 1), m[1,1]) # # m.itemset(1, 88) # print(m) # # print(m.tolist()) # print(m.tobytes()) # # print(m.astype(dtype=np.float)) # m.tofil...
c51b6335647f9d34858b4bfb7326b12ce256335c
daofeng123/ClassCodes
/d16_plot_linalg/codes_numpy/statistics04_Histograms.py
825
3.84375
4
""" 频率统计计算 histogram(a[, bins, range, normed, weights, …]) |- 分段统计 histogram2d(x, y[, bins, range, normed, weights]) |- 计算两个数据样本的二维直方图。 |- 二维直方图是指落在矩形区域内的频率计算 histogramdd(sample[, bins, range, normed, …]) |- 多维直方图 bincount(x[, weights, minlength]) |- 计数非负整数数组中每个值的出现次数。 |- minlength指定返回的最小箱...
5abfadfa6ecf6408da8241b9d93941bfcd02eaf1
daofeng123/ClassCodes
/d16_plot_linalg/p04_sum_prod_gredient.py
844
3.625
4
""" gradient(f, *varargs, **kwargs) |- 两边的梯度:左边:下一个值-当前知 ,右边:当前值-上一个值 |- 中间:(下一个 - 上一个)/2 """ import numpy as np a = [ [1, 5, 6], [2, 6, 8], [6, 8, 10] ] # print(np.sum(a, axis=0)) # print(np.prod(a, axis=0)) # a = [ # [1, 5, 6], # [2, np.NaN, 8], # [6, 8, 10] # ] # print(np.nansum(a...
d2b4c0c2878194ea2014cbe5d0f7e2032263e018
daofeng123/ClassCodes
/d16_plot_linalg/codes_numpy/statistics02_average_var.py
929
3.640625
4
""" median(a[, axis, out, overwrite_input, keepdims]) |- 中间值 average(a[, axis, weights, returned]) |- 平均值(可以去加权) mean(a[, axis, dtype, out, keepdims]) |- 算术平均数 std(a[, axis, dtype, out, ddof, keepdims]) |- 标准差 var(a[, axis, dtype, out, ddof, keepdims]) |- 方差 nanmedian(a[, axis, out, overwrite_inpu...
50b8fd78af9da1b527be19da35aca8daa6e10f7b
nalin-adhikari/python-import-csv-to-mysql
/main.py
1,273
3.515625
4
import pandas as pd import mysql.connector as msql from mysql.connector import Error def main(): # Create a database "customer" before running this method. df = pd.read_csv("data/customer.csv", index_col=False, delimiter=",") try: conn = msql.connect(host='localhost', database='customer', user='...
d8a8de2abc3def1b08d679c70909c24b66a4a8dc
aototo/python_learn
/week2/FINDING.py
212
3.5625
4
epsilon = 0.1 y = 9 guess = y/2.0 while abs(guess*guess - y ) >= epsilon: guess = guess -((( guess**2 ) - y ) / (2*guess )) print(str(guess)) print(" Square root or " + str(y) + 'is about' + str(guess) )
29bf475491bbb765a9e739822fe09e7e383a1fef
aototo/python_learn
/week2/week2 bisection.py
878
4.15625
4
print("Please think of a number between 0 and 100!") high = 100 low = 0 nowCorrect = int(( high + low ) / 2) print('Is your secret number '+ str(nowCorrect) + '?') while True: input_value = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed...
94a6aa818da7db52e435be0161aaf42a0c540484
aakasht05/DojoAssignments
/Python/01_PythonFundamentals/01_strings_lists.py
643
3.921875
4
words = "It's thanksgiving day. It's my birthday,too!" listOne = [5, -4, 9, 10, 2, 0, 4] def findAndReplace(str): print str.find("day") print str.replace("day","month") return; def minMax(list): print min(list) print max(list) return; def firstAndLast(list): print list[0] ...
424f124cb997e9c61cdc9f0e28490d5a4f965cab
aakasht05/DojoAssignments
/Python/01_PythonFundamentals/13_stars.py
307
3.5
4
x = [4, 6, 1, 3, 5, 7, 25] x2 = [4, "Tom", 1, "Michael", 5, 7, "Jimmy Smith"] def draw_stars(input_list): for i in input_list: if (type(i) == int): print "*" * i elif(type(i) == str): print (i[0] * len(i)).lower() draw_stars(x) draw_stars(x2)
b759b3ffa71ba723c6285c257faf2478753f21b1
aakasht05/DojoAssignments
/Python/01_PythonFundamentals/05_compare_list.py
816
3.859375
4
list_one = [1,2,5,6,2] list_two = [1,2,5,6,2] list_three = [1,2,5,6,5] list_four = [1,2,5,6,5,3] list_five = [1,2,5,6,5,16] list_six = [1,2,5,6,5] list_seven = ['celery','carrots','bread','milk'] list_eight = ['celery','carrots','bread','cream'] def compareList(x,y): x.sort() y.sort() cou...
3446c66e4336bc94a01c9bd20bb86c1a9576f58e
RmdanJr/Discrete-Mathematics-Specialization
/2-Combinatorics-and-Probability/codes/dice-throw-avg-value.py
301
3.859375
4
# Average Value of a Dice Throw: Experiment from random import randint, seed from datetime import datetime seed(datetime.now()) num_rounds = 10**5 sum_of_values = 0 for _ in range(num_rounds): sum_of_values += randint(1, 6) print("The average is {}".format(sum_of_values/(num_rounds*1.0)))
a5ede91e1c02cbbf67acd78ca3ea31111f699da3
RmdanJr/Discrete-Mathematics-Specialization
/4-Number-Theory-and-Cryptography/codes/quiz_diophantine_equations.py
799
3.71875
4
# Diophantine Equations: Code def gcd(a, b): assert a >= 0 and b >= 0 and a + b > 0 while a > 0 and b > 0: if a >= b: a = a % b else: b = b % a return max(a, b) def extended_gcd(a, b): assert a >= b and b >= 0 and a + b > 0 if b == 0: d, x, y = a, ...
a8985fab935299ec7819774718acf910f3d66d46
Annxia/learn-automated-testing
/code/practice/caculate.py
175
3.53125
4
def caculate(list): list1 = [] idx = 0 for i in list: list1.append(sum(list[:idx + 1])) idx += 1 return list1 print(caculate([1, 2, 3, 4]))
f02ead41101d9781f211e2a0504238819d1e04e0
Annxia/learn-automated-testing
/code/pythonbasic/函数.py
751
3.625
4
# -*- coding: utf-8 -*- # @project : code # @author: Administrator # @file: 函数.py # @ide: PyCharm # @time: 2020/8/13 15:35 print("---") ''' 变量: 是对象的一个名字,方便使用这个对象 函数: 一段代码的名字,方便使用这段代码 None:说明函数没有返回值;或者return后面没有对象 如果return后面跟着一个对象,接收的是一个值,类型不变 如果return后面跟着多个对象,接收的是一个元组 ''' def login(): i = 1 while i...
a9adf0d6d1dd13f2a3eb57d009c6b22367bc26e1
Annxia/learn-automated-testing
/code/python进阶/day1/homework.py
427
3.515625
4
# -*- coding: utf-8 -*- # @project : code # @author: Administrator # @file: homeworkTeacher.py # @ide: PyCharm # @time: 2020/6/30 14:59 with open("./gbk编码.txt", "r", encoding="gbk") as f1, open("./utf8编码.txt", "r", encoding="utf8") as f2: str = f1.read() + "\n" + f2.read() print(str) filename = input("请输入新的文件...
df8a2ac9efae511ef2730b7f9f833787a1bfbd1d
qa-trainee/qa-trainee-learning-python
/python-practice/ATBS_S4_L11.py
956
4.03125
4
# ATBS_S4_L11.py is a proram that wrote to test my understanding of # Automate the boring stuff Section 4, Lecture 11 # try and except statements, bareback except, multiple except handle # You dont want your program to crash when it gets error / exceptions # So you try to execute, catch exceptions and then throw error...
3730c7b8b9bcfe096e8112d113616e28acfe57c4
qa-trainee/qa-trainee-learning-python
/python-practice/ATBS_S1_L8.py
928
3.984375
4
# ATBS_S1_L8.py is a proram that wrote to test my understanding of # Automate the boring stuff Section 1, Lecture 8 # functions, random.randint(), sys.exit(), pip, pyperclip # built in functions # module: built in functions are written and grouped in modules # you need to import modules # import random # this allows u...
04f7284ae75e0caf109cb678ef7993b95a1dc1d1
drewokane/AOC_2020
/advent_of_code_2020/day1.py
1,040
3.921875
4
import typing from collections import defaultdict from .data_tools import read_input def parse_data(input_string: str) -> typing.List[int]: return [int(s) for s in input_string.splitlines()] def double_sum(data: typing.List[int]): numbers = defaultdict(lambda: None) for n in data: if numbers[n...
7bbe2bf4078108379bff6f1b4edcf1d61dad66fd
Jeremiah-David/codingchallenges
/python-cc.py
1,363
4.15625
4
# Write a function called repeatStr which repeats the given string # string exactly n times. # My Solution: def repeat_str(repeat, string): result = "" for line in range(repeat): result = result + string return (result) # Sample tests: # import codewars_test as test ...
4f8b01f98db2f8a84e77a307bfe1d02db36ef09c
noelfonsecairri/python_learning
/functions_and_methods_homework.py
3,326
4.25
4
# Write a function that computes the volume of a sphere given its radius. # def vol(rad): # return (4 * 3.14 * (rad ** 3))/3 # print(vol(5)) ######## # Write a function that checks whether a number is in a given range (Inclusive of high and low) # my_list = list(range(0,10)) # def ran_check(num): # return num i...
8de86302b7866f2ab0dc15f795af77e692e5e436
noelfonsecairri/python_learning
/while.py
1,183
4.03125
4
# cleanest_cities = ["city1", "city2", "city3"] # user_input = "" # while user_input != "q": # user_input = input("Enter a city, or q to quit: ") # if user_input != "q": # for a_clean_city in cleanest_cities: # if a_clean_city == user_input: # print(a_clean_city + " is one of the cleanest cities") # bre...
0c76c7ffdd06cbacdedcda455ef5d47264048f4b
noelfonsecairri/python_learning
/nested_statements_and_scopes.py
786
3.953125
4
# x = 25 # def printer(): # x = 50 # return x # print(printer()) # print(x) # LEGB Rule for variables: # L: Local - Names assigned in any way within a function (def or lambda), and not declared global in that function # E: Enclosing function locals - Names in the local scope of any and all enclosing funtions (de...
55e74e7fa646c954cefac68cd885b63a639191a3
attaullahshafiq10/My-Python-Programs
/Conditions and loops/4-To Check Prime Number.py
646
4.1875
4
# A prime number is a natural number greater than 1 and having no positive divisor other than 1 and itself. # For example: 3, 7, 11 etc are prime numbers # Other natural numbers that are not prime numbers are called composite numbers. # For example: 4, 6, 9 etc. are composite numbers # Code num = int(input("...
4bf9dfccde5cda9a0223bdeb96ff8b2dad1f6e67
Dcooper15/python_algorithms1
/problem_2.py
747
3.5625
4
a = [1,2,3,4] b = [1,4,9,16] c = [1,4,5,6] d = [1,4,4,2] e = [1,16,9,4] f = [1,2,3,4,5] def some_function(a, b): dict_a = {} dict_b = {} boolean_stop = False if len(a) == len(b): for i in a: dict_a[i] = i for k in b: dict_b[k] = k for x in dict_a: ...
4d8f63d404193cc317b905144c36c9a330d8d2fc
Manasabp04/assignment
/functions.py
318
3.796875
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 14 15:06:26 2019 @author: Manasa """ def sum(num1,num2): result=num1+num2 print('result',result) #definig sum(100,39) #calling def sum(num1,num2): result=num1+num2 return result #definig res=sum(141,39) #calling print('res',res)
d8fd575f1909c83f63d5709729a1142977c58faf
Lucas-Servi/FCC-projects
/Probability-calculator/prob_calculator.py
872
3.625
4
import copy import random # Consider using the modules imported above. class Hat: def __init__(self,**colors): self.contents = [] for color in colors.keys(): self.contents += [color]*int(colors[color]) def draw(self, amount): if amount >= len(self.contents): return self.contents else:...
d3ee8ca92ad5f47c7f59c16735ab650c8f443fc8
LearnCodeWithNuMa/ExercicesPython
/exercices.py
2,677
3.609375
4
import random # Exercice 1 def pair(n): n = int(n) if n % 2 == 0: return True return False # Exercice 2 def age(n): n = int(n) if n >= 18: return "Majeur" return "Mineur" # Exercice 3 def sophie(): s = 1000 print(2020, "=", s, "€ ") for k in range(2021, 2041): ...
84b88b8c998f5eb97f2a395fd42bdf6346b5f24b
AjaniLevy/BankAccount
/courses/CS/CS1.1/Superhero/animal.py
583
3.765625
4
class Animal: def __init__(self, name, sleep_duration): self.name = name self.sleep_duration = sleep_duration def sleep(self): print( "{} sleeps for {} hours".format( self.name, self.sleep_duration)) def eat(self): print (f"{self.n...
9bbfb09002418b0aaa1be0916f084fe489cab4d7
hema2575/python-activities
/day2-filereadwithPython.py
693
3.546875
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 24 20:55:27 2020 @author: muthukumar """ import csv with open(r'C:\Users\muthukumar\Desktop\netflix_ratings.csv', newline ='') as csvfile: reader = csv.reader(csvfile) for row in reader: print(row) import csv import os csvpath = os.path.join("..", ...
d3954c29405b827fc433e27c730267b3f1fcf314
hema2575/python-activities
/nextflix.py
616
3.8125
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 28 17:17:27 2020 @author: muthukumar """ import os import csv csvpath = os.path.join(r'C:\Users\muthukumar\Desktop\netflix_ratings.csv') found = False with open(csvpath) as csvfile: csvreader = csv.reader(csvfile, delimiter=',') userCh = input("Enter the video yo...
06d59284fbf18167848a0e21d73a70b5ee34b555
hema2575/python-activities
/06_input.py
719
4.0625
4
#name = input("what is your name ? ") #namef = input ("What is your first name ?") #namen = input("What is your neighbor's first name ?") #codeexpf = int(input("How many months have you been coding ?")) #codeexpn = int(input("How many months have your neighbor been coding ?")) #total = codeexpf+codeexpn #age = int(inpu...
e7c68e5b5bb8c7cd2f0b69cfc434c5ca1d07017d
adamkvitek/Pyladies
/04/elipsa.py
315
3.546875
4
from math import pi def obsah_elipsy(a, b): """Vrátí obsah elipsy s poloosami daných délek""" # Jen samotný výpočet: return pi * a * b # print a input jsou "venku": a = float(input('Zadej délku poloosy 1: ')) b = float(input('Zadej délku poloosy 2: ')) print('Obsah je', obsah_elipsy(a, b))
474d577c612eb6497330b562cb4cd1c4d3ebd719
adamkvitek/Pyladies
/02/pokus2.py
894
3.796875
4
from random import randrange cislo = randrange(3) tah_cloveka = input('kámen, nůžky, nebo papír? ') if tah_cloveka == 'kámen': if cislo == 0: print('Počítač vybral kámen. Plichta. :-|') elif cislo == 1: print('Počítač vybral nůžky. Výhra! :-)') else: print('Počítač vybral papír. Pr...
2698c8bf4787ec975fce558238fcaa6cf75fd5e0
adamkvitek/Pyladies
/03/hexagon.py
211
3.8125
4
from turtle import forward, left, right, speed, exitonclick, shape shape('turtle') for i in range (6): for j in range(6): forward(45) left(60) forward(45) right(60) exitonclick()
a1683d8ecef216d18501ab263a5f554eba32cf54
rebeccagettys/ToolBox-MachineLearning
/learning_curve.py
1,707
3.84375
4
""" Exploring learning curves for classification of handwritten digits """ import matplotlib.pyplot as plt import numpy from sklearn.datasets import * from sklearn.cross_validation import train_test_split from sklearn.linear_model import LogisticRegression data = load_digits() print data.DESCR num_trials = 100 train_...
911ad3e62aebf423c1d5995011c9d835c833de3f
NathanSwindall/Springboard
/3 Preparing Data/Scrapy Tutorial/details.py
1,312
3.53125
4
import scrapy #remember the scrapy shell is pretty cool # fetch(url) to change the url in scrapy shell # scrapy runspider details.py -o details.json -> This is to run the file # This can get all the stuff for infinite scrolling websites. I think it would be cool to pull youtube data using this spider # Let's try to m...
2e4cf15b57e52cc59c07a0521de62aacab933343
ehayesr/snakify-final
/Integer_and_float_numbers.py
2,021
3.90625
4
#IMPORTING MATH FUNCTIONS #floor(x) — returns the largest integer less than or equal to x, #ceil(x) — returns the smallest integer greater than or equal to x, #sqrt(x) — returns the square root of x, #log(x) — returns the natural logarithm of x, #log(x,a) — returns the logarithm of x to base a, #pi is the mathematical...
d76f18fd681278cbfa3bca87c932ce837042e753
TrapTheOnly/Pizza
/Pizzas/Pizza.py
4,887
3.875
4
import abc from abc import ABCMeta import sqlite3 class Pizza(metaclass=abc.ABCMeta): @abc.abstractmethod def get_price(self): pass @abc.abstractmethod def get_status(self): pass class Pizza_None(Pizza): pizza_price=0 def __init__(self, ingredients, price): self.pizza_...
06921893916f9c8f1d02d9e219a66e00b79c19ae
acmillinoistech/lyftserver
/samples/starterpython/main.py
1,337
3.796875
4
''' Python Starter Code >> python main.py ''' import os import requests from datetime import datetime URL = "https://lyft-vingkan.c9users.io" TEAM = os.environ["TEAM_SECRET"] ''' Helper Methods ''' # Get Trips def get_trips(query): query["team"] = TEAM response = requests.get(URL + "/trips/", params=query) retur...
127e1bb0cd1802489b9003cefe73ee7d53929539
winkitee/coding-interview-problems
/51-60/53_group_words_that_are_anagrams.py
729
4.0625
4
""" Hi, here's your problem today. This problem was recently asked by AirBNB: Given a list of words, group the words that are anagrams of each other. (An anagram are words made up of the same letters). Example: Input: ['abc', 'bcd', 'cba', 'cbd', 'efg'] Output: [['abc', 'cba'], ['bcd', 'cbd'], ['efg']] Here's a sta...
bb69af4b9a1f55be425c9dbd16d19768cef3345d
winkitee/coding-interview-problems
/11-20/15_find_pythagorean_triplets.py
911
4.28125
4
""" Hi, here's your problem today. This problem was recently asked by Uber: Given a list of numbers, find if there exists a pythagorean triplet in that list. A pythagorean triplet is 3 variables a, b, c where a2 + b2 = c2 Example: Input: [3, 5, 12, 5, 13] Output: True Here, 5^2 + 12^2 = 13^2. """ def findPythagorea...
bc6e443021f727443ecdd2a0c4fa1fac36a91d6a
winkitee/coding-interview-problems
/91-100/94_top_k_frequent_words.py
1,134
4
4
""" Hi, here's your problem today. This problem was recently asked by AirBNB: Given a non-empty list of words, return the k most frequent words. The output should be sorted from highest to lowest frequency, and if two words have the same frequency, the word with lower alphabetical order comes first. Input will contain...
1af22ea47c378d08fb6f28c8a84f1153541b378f
winkitee/coding-interview-problems
/11-20/11_findCeilingFloor.py
2,134
3.984375
4
""" Hi, here's your problem today. This problem was recently asked by Apple: Given an integer k and a binary search tree, find the floor (less than or equal to) of k, and the ceiling (larger than or equal to) of k. If either does not exist, then print them as None. Here is the definition of a node for the tree. """ ...
5c1c1b11dc666990e8344bf2cd5cc8e2a663d46f
winkitee/coding-interview-problems
/71-80/80_make_the_largest_number.py
586
4.15625
4
""" Hi, here's your problem today. This problem was recently asked by Uber: Given a number of integers, combine them so it would create the largest number. Example: Input: [17, 7, 2, 45, 72] Output: 77245217 def largestNum(nums): # Fill this in. print(largestNum([17, 7, 2, 45, 72])) # 77245217 """ class larges...
f00af6368fa7a098549d3b6920ad1fd58333b4d7
winkitee/coding-interview-problems
/41-50/50_largest_BST_in_a_Binary_Tree.py
1,737
4
4
""" Hi, here's your problem today. This problem was recently asked by Twitter: You are given the root of a binary tree. Find and return the largest subtree of that tree, which is a valid binary search tree. Here's a starting point: class TreeNode: def __init__(self, key): self.left = None self.right = None...
7a69275ce48e888f44b9fc568b4e619593e1db1d
winkitee/coding-interview-problems
/71-80/78_string_compression.py
1,148
3.984375
4
""" Hi, here's your problem today. This problem was recently asked by Twitter: Given an array of characters with repeats, compress it in place. The length after compression should be less than or equal to the original array. Example: Input: ['a', 'a', 'b', 'c', 'c', 'c'] Output: ['a', '2', 'b', 'c', '3'] Here's a sta...
dd07fe905d62c6de15dd052c2b54ff82de8ced23
winkitee/coding-interview-problems
/31-40/34_contiguous_subarray_with_maximum_sum.py
876
4.21875
4
""" Hi, here's your problem today. This problem was recently asked by Twitter: You are given an array of integers. Find the maximum sum of all possible contiguous subarrays of the array. Example: [34, -50, 42, 14, -5, 86] Given this input array, the output should be 137. The contiguous subarray with the largest sum...
137010e46f66a45cca19151081784adf4ff593a7
winkitee/coding-interview-problems
/41-50/41_first_missing_positive_integer.py
860
4
4
""" Hi, here's your problem today. This problem was recently asked by Facebook: You are given an array of integers. Return the smallest positive integer that is not present in the array. The array may contain duplicate entries. For example, the input [3, 4, -1, 1] should return 2 because it is the smallest positive i...
ac5fd43b59069416ab60dc076ae1671452b4c9e8
winkitee/coding-interview-problems
/71-80/77_convert_roman_numerals_to_decimal.py
3,712
3.8125
4
""" Hi, here's your problem today. This problem was recently asked by Twitter: Given a Roman numeral, find the corresponding decimal value. Inputs will be between 1 and 3999. Example: Input: IX Output: 9 Input: VII Output: 7 Input: MCMIV Output: 1904 Roman numerals are based on the following symbols: I 1 IV ...
3a65bf1e00e3897174298a3dc7162b4c75c90742
GabuTheGreat/GabuTheGreat.github.io
/challange/recursion_1.py
467
4.1875
4
n= int(input("Enter number the first number: ")) def isPrime(num): """Returns True if num is prime.""" if (num == 1) or (num % 2 == 0) or (num % 3 == 0) : return False if (num == 2) or (num == 3) : return True check_var= 5 set_var = 2 while check_var * check_var <= num: ...
fb55487ed706eb7fa8e8fe073a622b66daccf712
mnikkel/adventofcode2019
/day6/orbits.py
680
3.625
4
f = open('input') INPUT = list(map(str.rstrip, list(f))) def generate_orbits(input): orbits = {} for orbit in INPUT: a, b, c = orbit.partition(')') if a in orbits: orbits[a].append(c) else: orbits[a] = [c] return orbits def count_orbits(orbits, origin, wei...
fda9fc82cb62d16684b30546598ffec2d3e75ee8
thedavekwon/AMNH_Meteorite_Challenge
/hack.py
280
3.65625
4
import pandas #rows = [1] #for x in range(27,63): #rows.append(x) #df = pandas.read_csv('standard-element-concentrations.csv', usecols = [3,4,5,6,7,8,10,12,15,18,23], skiprows=rows) df = pandas.read_csv('standard-element-concentrations.csv') print(df) #print(df == 46.7400)
be75d5368e7123927f0f909a6bcbc2fc95cf8fbb
j-f-eva/Basic-Python-
/listMethod.py
141
3.65625
4
#list method numbers = [1,2,3,4,5] #numbers.append(6) #numbers.insert(0, -1) #numbers.remove(3) numbers.clear() print(numbers)
34c8a5975c07165106bd94c0a7b2ac799473b292
xiangyu123/homework
/day01/Login.py
1,832
3.578125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- import getpass f1 = open('db','r') data = f1.read() f1.close() user_info_list = [] user_str_list = [i for i in data.split('\n') if i] # 移除data.split()生成的空元素 for item in user_str_list: temp = item.split('|') v = { 'name': temp[0], 'pwd': temp[1], ...
50c94fe38ed042492700e46f97fe3ac1d2867fb4
tijko/Project-Euler
/py_solutions_11-20/Euler_16.py
301
3.53125
4
# what is the sum of the digits 2**1000 ? from __future__ import print_function import timeit start = timeit.default_timer() def euler_16(): return sum(map(int, str(2**1000))) print("Answer: {}".format(euler_16())) stop = timeit.default_timer() print("Time: {0:9.5f}".format(stop - start))
ed4d6240bfc9cfaa8c9f14b26b281b639267268c
tijko/Project-Euler
/py_solutions_71-80/Euler_80.py
588
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # sum of the first 100 natural numbers decimal square root from __future__ import print_function import mpmath import timeit try: range = xrange except NameError: pass start = timeit.default_timer() def euler_80(): mpmath.mp.dps = 102 total = 0 r...
9de9240ad213237ecdabd6526586032e43c76a29
tijko/Project-Euler
/py_solutions_71-80/Euler_72.py
1,225
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # How many elements would be contained in the set of reduced proper fractions # for d ≤ 1,000,000? from __future__ import print_function import timeit import math try: range = xrange except NameError: pass start = timeit.default_timer() def is_prime(n): i...
577112cc74421ec8d535d101b31b59cfaa39f5a1
tijko/Project-Euler
/py_solutions_91-100/Euler_100.py
1,177
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21)×(14/20) = 1/2. The next such arrangement, for which there...
93e83b8840a3bcb5c849a5098aa4c4450aa05c40
league-python-student/level0-module1-GITHUBSARIKA
/_04_int/_2_simple_number_adder/simple_adder.py
424
4.0625
4
# Write a Python program that asks the user for two numbers. # Then display the sum of the two numbers from tkinter import messagebox, simpledialog, Tk if __name__ == '__main__': window=Tk() window.withdraw() numOne=simpledialog.askinteger("Simple Adder", "Enter a number") numTwo=simpledialog.as...
2df626989babccf02b29be16522cf6512f33a9a5
JangSoon-Woo/Python
/1000~10000/1000~2000/1427.py
133
3.953125
4
nums = input() nums = [int(n) for n in nums] ordered_nums = sorted(nums, reverse=True) for n in ordered_nums: print(n, end="")
ded2e86c9499063821af591a331fd137fa1640cb
PawelDabala/Python_Zadania
/zad_domo302.py
696
3.875
4
""" W tym zadaniu nie musisz pisać funkcji) Napisz program, który: poprosi użytkownika o podanie 2 liczb z klawiatury, wprowadzone dane zamieni na liczby naturalne, podzieli jedną liczbę przez drugą, wyświetli wynik. Dodatkowo należy zabezpieczyć się przed wszystkimi możliwymi błędami (niewłaściwe dane, dzielenie prz...
def3b32f670c0b78ee18d12e7ad3cd1605821391
PawelDabala/Python_Zadania
/zad_domo104.py
592
3.703125
4
""" Napisz funkcję o nazwie dogs_age, który przeliczy wiek psa w psich latach. funkcja powinna przyjmować wiek psa jako parametr, dla pierwszych dwóch lat, każdy rok życia psa jest równy 10.5 ludzkiego roku, powyżej dwóch lat, każdy rok życia psa, to 4 ludzkie lata, funkcja powinna zwrócić wiek psa. Przykład: azor = ...
cf99266eb9f52d4d4b8e1253150fd98bff8621f3
PawelDabala/Python_Zadania
/zadanie33.py
420
3.734375
4
""" Napisz funkcję phone, która przyjmie parametr number, który oznacza numer telefonu. Funkcja ma sprawdzić, czy podany numer znajduje się na liście numerów (wymyśl jakieś). Jeśli nie - musi zwrócić wyjątek typu Exception z komentarzem Nie ma takiego numeru!. """ def phone(number): lis_numbe=[1,2,3] if number...
75cf40ba426ba649e710ead7f80f04039737e156
PawelDabala/Python_Zadania
/zad_domo205.py
890
3.578125
4
""" Napisz funkcję censor, która przyjmie jako parametr dowolnie długi łańcuch tekstowy. Następnie: rozbije łańcuch tekstowy na listę wyrazów, sprawdzi, czy nie znajdują się w nim słowa niedozwolone, jeśli tak -- zamieni je na cztery gwiazdki (****) ponownie połączy listę w string i zwróci wartość. Słowa niedozwolone:...
5bdf5695562df1301cbd5277b2e1d22b1e7c0350
PawelDabala/Python_Zadania
/zadanie25.py
324
3.65625
4
""" Napisz funkcję mean(numbers), gdzie numbers to lista liczb dowolnego typu. Funkcja powinna zwrócić średnią arytmetyczną wszystkich elementów listy numbers. Czy znasz jakiś sposób, by ułatwić sobie pracę? """ import statistics def mean1(list1): return statistics.mean(list1) print(mean1([1, 2, 3]))
2783e1d70e0b9174a91da71cb19f99c78c94d516
Derexas/Euler
/41.py
540
3.609375
4
import math, time def isprime(x): m = int(math.sqrt(x))+1 for i in range(3,m,2): if x%i == 0: return False return True t = time.time() digits = [1,2,3,4,5,6,7]#,8,9] bigprime = 0 def pangen(ds, n, pan): global bigprime for i in range(0,len(ds), 2 if n == 0 else 1): l = list(ds) v = l.pop(i) p = pan...
504094123aaeb286b0cc8118fba5f64f0be8f29b
Poyx15/Tutorials
/Codecademy Practice/Python3/Coffee_Bot.py
2,969
3.984375
4
# Define your functions sizes = { "a" : "Small", "b" : "Medium", "c" : "Large", "A" : "Small", "B" : "Medium", "C" : "Large" } coffee_type = { "a" : "Brewd Coffee", "b" : "Mocha", "c" : "Latte" } milk_for_latte = { "a" : "Latte", "b" : "Non-fat Latte",...
7ddb79a6c8b6d3cd0778e7e12eeb27af72598c35
Poyx15/Tutorials
/Codecademy Practice/VisualizeData/DataFrame/ColumnOperation.py
287
4.1875
4
# import codecademylib # from string import lower import pandas as pd df = pd.DataFrame([ ['JOHN SMITH', 'john.smith@gmail.com'], ['Jane Doe', 'jdoe@yahoo.com'], ['joe schmo', 'joeschmo@hotmail.com'] ], columns=['Name', 'Email'] ) # Add columns here df['Lowercase Name'] = df['Name'].str.lower() ...
66143743dc777d61cda2d79196471d53b3617f5a
Poyx15/Tutorials
/Codecademy Practice/VisualizeData/BasicPlotLine/Subplot.py
586
3.75
4
# The command plt.subplot() needs three arguments to be passed into it: # # The number of rows of subplots # The number of columns of subplots # The index of the subplot we want to create from matplotlib import pyplot as plt months = range(12) temperature = [36, 36, 39, 52, 61, 72, 77, 75, 68, 57, 48, 48] f...
0bc796ab22f579985cb70424efc702d91743f05d
Poyx15/Tutorials
/Codecademy Practice/Python3/Scrabbles.py
1,437
3.984375
4
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] letter_to_points = {key:value for key, value in zip(letters, points)} #combine the le...
b6aef167f0cf292cfb93123a49fcef11d567ecf1
IonutPopovici1992/CyberSecurity
/Python/lists.py
273
3.921875
4
# Lists numbers = [23, 34, 67, 87, 102] # print(numbers) numbers[1] = 456 print(numbers) # numbers + [39, 321] # print(numbers) # append() numbers.append(120) print(numbers) print(numbers[:3]) numbers[:4] = [2, 4, 6, 8] print(numbers) numbers[:] = [] print(numbers)
3a5514818ca5f86bfe51b3c6950f6f7638536318
HarikrishnaSPillai/Turtle_Race
/main.py
965
3.984375
4
import random from turtle import Turtle, Screen is_Race = False screen = Screen() screen.setup(500, 400) user_bet = screen.textinput("Make a bet", "Which turtle will win?") colors = ["red", "orange", "yellow", "green", "blue", "purple"] start_pos = [-70, -40, -10, 20, 50, 80] all_turtles = [] for turtle_index in ran...
12755d48843583e41fcf02a5cd7b9efd4fb68c41
icr47/project_euler_python
/Project 5/project_5.py
203
3.546875
4
class Prob5: def find(self): i = 0 checklist = [11,13,14,16,17,18,19,20] while True: i+=20 if all(i % x == 0 for x in checklist): # continue loop print("heoh we found it! " + str(i))
0869d5fca365f0e318f7e4c41f6829acf4ce9954
girishgupta211/algorithm
/buuble_sort.py
268
4.0625
4
def bubble_sort(arr): for j in range(len(arr)): for i in range(len(arr)-1): if arr[i] > arr[i+1]: temp = arr[i+1] arr[i+1] = arr[i] arr[i] = temp print(arr) bubble_sort([3,4,7,8,1,2,5,6,9,10])
ac1286b81ee01b2eba09d46e13664b6a01e3970f
girishgupta211/algorithm
/reverse_number.py
196
3.859375
4
def reverse(num,digits): sum = 0 place = digits-1 while num>0: r = num%10 num = num//10 sum += r*(10**place) place -= 1 print(sum) reverse(1234,4)
02a1deb3c056441f4d35925b02ff5566bbfdff6c
iTrauco/dc-py-project
/python_game.py
1,687
3.75
4
# establish hero/goblin class # Added 'Hero' and 'Goblin' classes class Goblin(): def __init__(self, name, power, health): # defines function values of goblin class # respawn baseline stats self.name = name #just name until defined later, called with () self.power = power self.health = heal...
01e601d31a6c7ffbcda8dde3f5fd334e884d53e4
ALIKUSAMSON/Another
/nest.py
331
3.578125
4
users=[] new_user={ 'last':'sam', 'first':'dengima', 'username':"dengsam" } users.append(new_user) new_user={ 'last':'emma', 'first':'iranya', 'username':"irasa" } users.append(new_user) print(users) for user_dict in users: for k, v in user_dict.items(): print(k + ":" + v) pri...
68e4d2c4cd63e5101b3d2fb248d56ddc5d41fe16
alexfritsch10/Connect4
/agents/common.py
7,132
3.59375
4
from enum import Enum from typing import Optional import numpy as np from typing import Callable, Tuple class SavedState: pass BoardPiece = np.int8 # The data type (dtype) of the board NO_PLAYER = BoardPiece(0) # board[i, j] == NO_PLAYER where the position is empty PLAYER1 = BoardPiece(1) # board[i, j] == PL...
94822b85a1d7b6c727ca33c3879e5ccdbd7a9ebf
marcopetry/cch-seguranca
/cesar/cesar.py
1,504
3.671875
4
#!/usr/bin/env python # This Python file uses the following encoding: utf-8 from sys import argv, stdin, stdout from unidecode import unidecode # pip install unidecode ALL_CHARACTERS = [] OPERATION = 'ENCRIPTER' if argv[1] == '-c' else 'DECRIPTER' KEY_ENCRIPT = int(argv[3]) # quantas casas vai andar cada letra fo...
70c2d7599c808743262396d4a4182d026d807931
amarish-kumar/code-chef-beginner
/packaging.py
112
3.75
4
import math num=int(input()) for i in range(0,num): x=int(input()) size=math.floor((x/2)+1) print(size)
4b3c5e76bd2f906dcb585fa32ebe30c199722bd9
amarish-kumar/code-chef-beginner
/farmerplot.py
170
3.546875
4
n=int(input()) def gcd(x,y) : while y>0: x,y=y,x%y return x for i in range(n) : x,y=map(int,input().split()) gcdval=gcd(x,y) print(int(x*y/(gcdval*gcdval)))
744aa3b364239e7199f407a04b2fc51543b09397
amarish-kumar/code-chef-beginner
/palindrome.py
602
3.5
4
n=int(input()) def palindrome(intnum) : num=str(intnum) if len(num)==1: return True x=len(num)-1 for i in range(0,len(num)) : if num[i]==num[x]: x=x-1 if x==-1: return True else: return False def palin(sstr): string=str(sstr) if list(string)==list(reversed(string)) : return True else : retur...
dd93e9278e656156a1f262c1cc5dad38e925aef8
amarish-kumar/code-chef-beginner
/squareroot.py
92
3.828125
4
import math n=int(input()) for i in range(n) : num=int(input()) print(int(math.sqrt(num)))
e59ef6ba35205d75035ad103fa2181fe55688924
amarish-kumar/code-chef-beginner
/permutation.py
517
4
4
def findInverse(a) : inverse=[] for i in range(1,len(a)+1): pos=search(i,a) #print(pos) inverse.append(pos) return inverse def search(x,array) : for i in range(len(array)): if array[i] == x : return i+1 while True: n=int(input()) if n==0 : break x=input() array=list(map(int,x.split(' ',n-1...
91f34741f9fb761d1ce7d9de6c61d80db496ec94
kiendc/opal
/src/opal/core/solver.py
1,257
3.859375
4
import os class Solver: def __init__(self, name='', command=None, input=None, parameter='', output=None, **kwargs): self.name = name self.command = command self.args = [input, parameter, output] return def solve(self, problem, **kwargs): """ Th...
390be82853eab5a3c9e18d0489a4f0ddde9825d1
kiendc/opal
/examples/coopsort/sort.py
4,251
4
4
# All sorts of sorts in Python. # D. Orban, Dec 2011. from heapq import heappush, heappop def bubblesort(arr): done = False while not done: done = True for i in range(len(arr)-1): if arr[i] > arr[i+1]: arr[i], arr[i+1] = arr[i+1], arr[i] ...
a9b0df8ed83e9a4d9072a5adf933097ea5ac1226
arturbardzinski/Python_A_Z
/wisielec.py
447
3.9375
4
lives = 5 word = "artur" used_letters = [] user_word = [] def find_indexes(word, letter): indexes = [] for index, letter_in_word in enumerate(word): if letter == letter_in_word: indexes.append(index) return indexes for _ in word: user_word.append("_") while True: letter = inp...
d7a48040268466db9452f5d4773718c607eba4db
arturbardzinski/Python_A_Z
/exercise_book_9.py
798
3.71875
4
''' with open('data.txt', 'r') as f: dataf = f.read() print(dataf) ''' # zada pytanie i zapisze odp w pliku ''' print('Podaj mi swoje imię?') answer = input('>>> ') with open('name.txt', 'w+') as f: file = f.write(answer) print('Zapisałeś do pliku >>> {}.'.format(answer)) with open('name.txt', 'r') as f: ...
0f036e9d59a6b7e4d12401f3e453dd2f8cb6fcdb
toufiq007/Python-Tutorial-For-Beginners
/chapter nine/list_comprehension.py
1,044
4.25
4
# list comprehension # print a list to square number of 1-10 # traditional way num = list(range(1,11)) num_list = [i for i in range(1,11)] print(num) # def square_number(x): # square_list = [] # for i in x: # square_list.append(i**2) # return square_list # print(square_number(num)) square_l...
fbb50bc38f14354555cef3e2bf8cd66e2a3f9270
toufiq007/Python-Tutorial-For-Beginners
/chapter three/while_loop.py
412
4.21875
4
#loop #while loop # steps # first declare a variable # second write the while loop block # in while loop block you must declare a condition # find the odd and even number by using while number between 0-100 i = 0; while i<=100: print(f'odd number {i}') i+=2 # find the even and even number by using whi...
74bee5049a2462c78824fdee03bc35c9bcd6759e
toufiq007/Python-Tutorial-For-Beginners
/chapter twelve/lambda_expresion_intro.py
512
4.25
4
# lambda expression --> anonymous function # it means when a function has no name then we called it anonymous function # syntex # 1: first write lambda keyword # 2: second give the parameters # 3: then give : and give the operator tha'ts it def add(x,y): return x+y print(add(10,5)) add = lambda a,b : a+b p...
4024a43132422ded8732257256bfb91b98cf3582
toufiq007/Python-Tutorial-For-Beginners
/chapter thirteen/iterator_iterable.py
515
4.21875
4
# iterator vs iterables numbers = [1,2,3,4,5] # , tuple and string alls are iterables # new_number = iter(numbers) # print(next(new_number)) # print(next(new_number)) # print(next(new_number)) # print(next(new_number)) # print(next(new_number)) square_numbers = map(lambda x:x**2,numbers) # map , filter this al...
984abd1fbb4ee832ab5794314efa198b10e0ca44
toufiq007/Python-Tutorial-For-Beginners
/chapter five/exercise4.py
713
4.0625
4
number = [1,2,3,4,5,6,7,8,9,10,11] print(number) def odd_even(x): odd =[] even = [] for i in x: if i%2==0: even.append(i) else: odd.append(i) return odd,even print(odd_even(number)) # def odd_even(x): # odd = [] # even = [] # for...
c5b7e8d113a19bf700ce4fd39ea43d1cb9efe752
toufiq007/Python-Tutorial-For-Beginners
/chapter four/variable_scope.py
466
3.90625
4
# local variable only works in the local scope # global variable works in local scope also but you must declare it to gobal variable # x = 20 # # def function(): # global x # x = 10 # return x # print(x) # print(function()) # print(x) name = 'toufiq limon' # global variable or global scope def newfu...
e7557d739edf11756cbec9759a5e7afaefa7955e
toufiq007/Python-Tutorial-For-Beginners
/chapter two/exercise3.py
975
4.125
4
# user_name,user_char = input('enter your name and a single characte ==>').split(',') name,character = input('please enter a name and character ').split(',') #another times # print(f'the lenght of your name is = {len(name)}') # print(f'character is = {(name.lower()).count((character.lower()))}') # (name.lower()).c...
7b7fb1f8e2755592339caa37bbc5d0fb2ef9cb5e
toufiq007/Python-Tutorial-For-Beginners
/chapter fiftheen/generator_comprehention.py
515
3.9375
4
# def generator_number(x): # for i in range(x+1): # if i%2==0: # yield(i) # number = generator_number(10) # for num in number: # print(num) def list_comprehension(x): return (x**2 for x in range(x+1)) generator_object = list_comprehension(10) # print(generator_object) # for square ...
bd809f3954aded9bef550a88b32eb1a958b7b1b5
toufiq007/Python-Tutorial-For-Beginners
/chapter thirteen/zip_part2.py
978
4.1875
4
l1= [1,2,3,4,5,6] l2 = [10,20,30,40,50,60] # find the max number of those list coupe item and store them into a new list def find_max(l1,l2): new_array = [] for pair in zip(l1,l2): new_array.append(max(pair)) return new_array print(find_max(l1,l2)) # find the smallest numbers and stored...
41097f82056b1013fefd43169ac216060394710e
toufiq007/Python-Tutorial-For-Beginners
/chapter seven/add_delete_data.py
1,547
4.28125
4
# add and delete data form dictionaries user_info = { 'name' : 'Mostafiz', 'age' : 20, 'favourite_movie' : ['coco','terminator','matrix'], 'favourite_songs' : ['forgive me','ei obelay'], 'nickname' : ('lebu','manik','baba') } user_info['others'] = ['textile engnieering student at ptec'] # pri...
60b9af30be744aec3de24fd4f422c688570644f3
toufiq007/Python-Tutorial-For-Beginners
/chapter eleven/args_as_arguement.py
452
4.28125
4
# Args as arguements def multiply_nums(*args): print(args) print(type(args)) # [1,2,3,4,5] mutiply = 1 for i in args: mutiply *= i return mutiply # when you pass a list or tuple by arguemnts in your function then you must give * argument after give your list or tuple name number = [1,...
21647313d550a72c49db44ddb740922b2199c2e1
toufiq007/Python-Tutorial-For-Beginners
/chapter eight/set_intro.py
984
4.375
4
# set data type # unordered collection of unique items # i a set data type you can't store one data in multipying times it should be use in onetime # set removes which data are in mulple times # the main use of set is to make a unique collection of data it means every data should be onetimes in a set # s = {1,2,3,4...