blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5a006bb50950bc8ffb07f2f2852a7bf8e7c85849
willcanniford/python-notes
/deep_learning/gradient_descent.py
4,276
4.28125
4
import pandas as pd import numpy as np def sigmoid(x): """ Calculate sigmoid """ return 1 / (1 + np.exp(-x)) def sigmoid_prime(x): """ # Derivative of the sigmoid function """ return sigmoid(x) * (1 - sigmoid(x)) # Define the learning rate and inputs/result for our example learnrat...
1923f804dbc15adb9c09a14853a8ce618026948f
roksavsk/Python-Basic-Steve-Trevor
/lectures/advanced_data_types/filter.py
243
3.578125
4
old_list = [1, 5, 4, 6, 8, 11, 3, 12] new_list = list(filter(lambda x: (x % 2 == 0), old_list)) print(new_list) def foo(x): if x % 2 == 0: return True return False new_list_1 = list(filter(foo, old_list)) print(new_list_1)
6c5c0986f67337f925edebb1ddb9f9c4771c375c
gilescaunter/sprites
/sprites2.py
974
3.5625
4
import pygame from pygame.locals import * from car import Car import random pygame.init() WHITE = (255, 255, 255) width, height = 640, 480 screen = pygame.display.set_mode((width, height)) allSpritesList = pygame.sprite.Group() playerCar = Car(60, 80, width, height, 5, 1) car1 = Car(30, 80, width, height, 5, 1) ...
118fb9dfb899ac44d1d28708d5cc673ea7d0d6d6
parthtyagi27/ml-stuff
/linear_regression/multivariate.py
1,539
3.96875
4
import numpy as np import math import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split import random main_dataframe = pd.read_csv("placement_data.csv") dataframe, test_dataframe = train_test_split(main_dataframe, test_s...
b0490f9110fea6e4335ccd5c23285559ae924b06
coriftech/task
/condition.py
102
3.875
4
x = 5 y = 6 if(x > y): print ("x is greater") else: print("y is greater") print ("goodbye")
d989002af2c4e04daf8f53664f37297698df151e
SuYuxi/yuxi
/Algorithms/Stack/20. Valid Parentheses.py
321
3.609375
4
class Solution(object): def isValid(self, s): stack = list() Mapping = {'}': '{', ']': '[', ')': '('} leftBracket = ['{', '[', '('] for char in s: if(char in leftBracket): stack.append(char) elif(char in Mapping): if(not stack or stack.pop() != Mapping[char]): return False return not stack...
42337879675ba43243211547a74dbb4815532f92
LabheshLalka11/SortingAlgorithms-Python
/MergeSortAlgorithm.py
1,003
4.0625
4
''' The Time Complexity of Merge Sort is : O(n*Log n) The Space Complexity of Merge Sort is : O(n) ''' array = [5,4,2,6,8,-1] def MergeSort(array): if len(array)<=1: return array else: mid = len(array)//2 l_array = array[:mid] r_array = array[mid:] MergeS...
87933262d7a901576baa0aa0ec5de16373877801
modeverv/deep-learning
/1.py
1,503
3.765625
4
# conding: utf-8 import numpy as np import matplotlib.pyplot as plt # データの作成 # x = np.arange(0, 6, 0.1) # 0から6まで0.1刻みで生成 # y = np.sin(x) # グラフの描画 # plt.plot(x, y) # plt.show() # リスト a = [1, 2, 3, 4, 5] print(a[2]) print(a[0:2]) # ディクショナリ me = {'height': 100} print(me['height']) me['weight'] = 70 print(me) # ブーリアン...
b3810cbc5d584ecbcf76c3cdd510d3afe29e71f3
whigg/python_gnss_plot
/basic_plots.py
5,048
3.875
4
#!/usr/bin/python3 import matplotlib import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import os """ basic_plots.py - function definitions for basic plots from static datasets. linear plots require x and y dataframes cdf plots require 1D dataframe all plots take title, ...
fb24c1583d7443ed4dd58a85db61f818fe9f7eb5
VictorCeronN/Mision_04
/Rectangulos.py
1,407
4.21875
4
# Autor: Victor Manuel Ceron Navarrete # Descripcion: Calcula el perímetro y área de dos rectángulos y da el area mayor #Calcula el área de un rectángulo con su base y altura def calcuA(b, h): return b*h #Calcula el perímetro de un rectángulo con su base y altura def calcuP(b,h): return (2*b)...
9b2a76b1c90eece5164269bb4ec1a3a4eb68e5db
xieqing181/Pythonwork-Chapter9
/roll_dies.py
625
3.78125
4
from random import randint class Die(): def __init__(self, sides = 6): '''def a die with 6 sides''' self.sides = sides def roll_die(self): x = randint(1,self.sides) return x die_6sides = Die() for i in range(1,11): print(str(i)+ " time trying: " + str(die_6sides.roll_die())) die_10si...
bc9dff7284f9a69af536bdcb7a5286c7d36c176b
sebasgarcep/ComputationalProblems
/PrimePairSets/main.py
3,002
3.84375
4
""" Approach: Determine pairwise if both primes can be concatenated. Imagine that every number is a vertex in a graph and that edges exist when they can be concatenated. Then use recursive search to find primes lower than it that form a fully connected graph of size 5. Search until the prime is larger than the smallest...
e877e1dd504cdaf405eecfa0b788457bcfbb6a23
Lukisn/WRseminar
/tests/demo/demo_util.py
2,372
3.84375
4
#!/usr/bin/env python3 """Module demonstrating the basic usage of the command line utilities.""" from util.cmdline import Spinner, Progress from util.cmdline import prompt_continue, prompt_yes_no, YES, NO from util.cmdline import prompt_input_str, prompt_input_int, prompt_input_float from util.cmdline import prompt_sur...
453cc79072e30f9aaa6a4fd0fd39159e75eb9c03
tylerthecoder/Association-Of-Practical-Programming
/problems/0_duplicate_character/tylertSolution.py
851
3.96875
4
# this program both computes the answer for the input file and checks if it is correct # to run the program run the command `python tylertSolution.py` in the terminal while in the directory filename = "input.txt" inputFile = open(filename, "r") filename = "output.txt" outputFile = open(filename, "r") def hasDuplicat...
54342e53dffe9cedb2d75be88677ed71099dce8a
ninjadq/pygorithm
/bag.py
1,035
3.578125
4
class BagNode: def __init__(self,value = None): self._value = value self._next = None @property def value(self): return self._value @value.setter def value(self, value): self._value = value @property def next_node(self): return self._next @next...
837e80c02733f5d68925c7257c0a6f61acf892e9
Shinjoku/projeto-integrado-b
/Server/recognition.py
463
3.625
4
#!/usr/bin/env python import speech_recognition as sr # Palavras que sao reconhecidas como gatilhos para que o som seja diminuido KEYWORDS = ( 'ola', 'alo', 'o som ta muito alto', 'hi', 'hello', "it's too loud here" ) def recognize(audioSource): # Inicializa reconhecedor ...
a0c6603f06370102161fa6605dd916ed8fee5b0c
Tsucreator/scraping_practice
/sc_practice/sc_dotpro.py
1,568
3.671875
4
# このように書くと、特定の関数のみimport出来ます。 from bs4 import BeautifulSoup html = '''\ <html> <body> <h1 class="class1">Hello, world</h1> <h2>This is Dot-pro</h2> <p class="class2">Mac</p> <p class="class2">Windows</p> <p class="class2">Linux</p> <a class="class3" href="http://foo.com">こちらをクリック!</a> </body> </html>\ ...
50741e2a960c9bc0158f8c32819083126e4928bc
nikiknak/fundamentos_de_informatica
/ejercicios guia 1/ej5 G1.py
276
4.1875
4
#5: Realizar un programa que lea tres números por teclado y calcule el promedio de ellos. num1 = int(input("ingrese un número:")) num2 = int(input("ingrese otro numero:")) num3 = int(input("ingrese otro numero:")) promedio = (num1 + num2 + num3) / 3 print(int(promedio))
9d2bc9bd1cec59d3073a0ed2c47b2943e614fb04
mariesstl/SWDV-610-3W-20SP2
/Lesson 6/assignment2binarysearchtree.py
7,606
3.984375
4
# Using the list from the previous question, # show the binary search tree resulting from the # list as a parameter to the buildHeap method. # Show both the tree and list form. # Binary Search Tree property: # keys that are less than the parent are found in the left subtree, # and keys that are greater than the paren...
ba4371b0bbf5887f980188c5074c35c04f1a2c28
yz5308/Python_Leetcode
/Algorithm-Medium/406_Queue_Reconstruction_by_Height.py
1,385
3.9375
4
class Solution: def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]: people_dict = {} for p in people: h,k = p[0], p[1] people_dict.setdefault(h, []) people_dict[h].append(k) result = [] for h in sorted(people_dict.keys(), reve...
12ab81223600df7d50419988a5d585bdd7273498
dblilienthal/titanic-predictions-heroku
/titanic-app.py
5,691
3.625
4
import streamlit as st import pandas as pd from sklearn.tree import DecisionTreeClassifier from sklearn.preprocessing import LabelEncoder # Create the header st.write(""" # Would you survive on the titanic? This app shows you your probability of survival if you were on the titanic. """) st.text('By Derek Lilienthal')...
de833497be083219e1988854c463105b78927d64
nikhilvarshney2/GUVI
/Player/set-13/124.py
252
3.703125
4
def gcd(a,b): if a==b: return a if a>b: return gcd(a-b,b) return gcd(a,b-a) def LCM(a,b): return a*b//gcd(a,b) n = int(input()) l = list(map(int,input().split())) lcm = 1 for u in l: lcm = LCM(lcm,u) print(lcm)
b334c5d2322d2c9b47e73a6712cd8ad0a71dd228
Sean-0831/2018-OOP-python-museum
/어인정 분류.py
495
3.5
4
while(True): a = input() list_a = a.split() list_a.reverse() #print(list_a) #i = list_a[0] + ' ' + 'INJEONG' + '\n' if len(list_a) < 3: i = list_a[1] + ' ' + list_a[0] + '\n' elif list_a[0] == 'INJEONG': i = list_a[1] + ' ' + list_a[0] + '\n' elif list_a[1] == '...
f33c3e35a8f9c5216f571a0dc48995585833c6de
angerborn/puzzles
/project_euler/41/main.py
716
3.671875
4
import itertools import sys sys.path.append("../../lib") import primes ps = primes.below(10 ** 6) largest_found = 0 # NOTE: numbers with digits 1..8 & 1..9 are always divisible by 3 # so only necessary to try up to 7 digits. # Read more: https://en.wikipedia.org/wiki/Divisibility_rule for permutation in itertools.per...
3ef8c78292032927d399a8618dabce79958e31cf
WellSantos/python_devops
/Section-03/function-02.py
704
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- carrinho = [] produto1 = {"nome":"tenis","valor":59.90} produto2 = {"nome":"meia","valor":9.90} produto3 = {"nome":"short","valor":19.90} produto4 = {"nome":"camisa","valor":39.90} carrinho.append(produto1) carrinho.append(produto2) carrinho.append(produto3) carrinho.app...
0621c922aa4a88d2798e10f3357786175b56e626
ads2100/100code
/day7.py
967
4.3125
4
#week2 #day7 print("hello") print('hello') # assign string to a variable a="hello saudi development" print(a) ################################### # assign multistring to a variable by using three quotes a=''' im learning a python programming language here tp develop my self and gitting a good knowledge , we are finis...
3abb546920155e0f82deb483de9ede3c33b59eef
nmessa/Python-2020
/Lab Exercise 11.12.2020/problem4.py
443
4.1875
4
## Lab Exercise 11/12/2020 Problem 4 ## Author: ## This program replaces all elements in the list (except first and last ## elements) with the larger neighbor def replaceLargerNeighbor(lst): #Add code here return lst #Code to test the function myList = [1,2,3,4,5,8,7,9] print (myList) p...
e31db5fb1146f30b9d833371b033e6d155d16403
Navyashree008/list_2
/ex.py
108
3.703125
4
def add(a,b): a = 2 b = 3 total = a+b print(total) x = 10 y = 20 add(x,y) print(x+y)
b251567f0ced78f4ec77cd300039065c6748b5cd
nishantchaudhary12/Starting-with-Python
/Chapter 8/alphabeticTelephoneNumberTranslator.py
998
4.03125
4
#Alphabetic Telephone Number Translator def print_num(user_input): user_input = user_input.upper() for ch in user_input: if ch == 'A' or ch == 'B' or ch == 'C': print('2', end='') elif ch == 'D' or ch == 'E' or ch == 'F': print('3', end='') elif ch == 'G' or ch ...
738ffa05d3c5d6e6727a65e10e6d568fc3420b36
lop3ziv4n/python-learning
/process_data/rename_index.py
509
4.0625
4
# Rename index import numpy as np import pandas as pd values = np.arange(9).reshape(3, 3) index = list('abc') data_frame = pd.DataFrame(values, index=index) print(data_frame) new_index = data_frame.index.map(str.upper) print(new_index) data_frame.index = new_index print(data_frame) print(data_frame.rename(index=str...
6f7f3ee8086f2e434d68bd8ffbba9d0131bf8810
vporta/DataStructures
/string/american_flag_x.py
3,476
3.59375
4
""" american_flag_x.py Sort an array of strings or integers in-place using American flag sort. Non-recursive. $ python string/american_flag_x.py < resources/shells.txt """ import sys from typing import List from queue import LifoQueue class AmericanFlagX: R = 256 CUTOFF = 15 @staticmethod def _char_a...
19cbc875877993ab6734d29bcf0281f0797852a7
dev-di/python
/advent_03_map.py
3,089
4.03125
4
#Advent of code day 3 import input_module def get_direction(direction_steps): return direction_steps[0:1] def get_steps(direction_steps): return int(direction_steps[1:]) def add_to_coordinate(val, coordinate, coordinates): if not coordinate in coordinates: coordinates[coordinate] = val...
7a9e22f3f2ca3ca4ee84601cec7303c512f9e533
Alexanderlacuna/python_folder
/corona/play_area/test5.py
609
3.796875
4
def binary_search(arri,search_item): arri=sorted(arri) start=0 end=len(arri)-1 index=None while (start<=end ): mid=((start+end)//2) print(mid) if (arri[mid]==search_item): index=mid break else: if (arri[mid]>search_item): end=mid-1 else: start=mid+1 return index def linear_searc...
40f595ee75c7db3865d25dc8bdb6b53727e13d42
laisdeghaide/CS50x
/2. Python/pset6/readability/readability.py
855
3.546875
4
import cs50 def main(): text = cs50.get_string("Text: ") letter = count_letters(text) word = count_words(text) sentence = count_sentences(text) L = float(letter) / float(word) * 100 S = float(sentence) / float(word) * 100 index = round(0.0588 * L - 0.296 * S - 15.8) if index...
ed33f5edb36bfd52a2bef4b3d491c118761a96e2
yzl232/code_training
/mianJing111111/Google/Print combinations of strings from List of List of String.py
1,243
3.984375
4
# encoding=utf-8 ''' Print combinations of strings from List of List of String Print combinations of strings from List of List of String Example input: [[quick, slow], [brown, red], [fox, dog]] Output: quick brown fox quick brown dog quick red fox quick red dog slow brown fox slow brown dog slow red fox slow red dog...
ddc67e360671a980074c7e4d3b758569a349b985
subreena10/list
/duplicate.py
182
3.546875
4
n = [19, 17, 12, 17, 17, 18, 10, 17, 14, 12, 19, 17, 12, 13, 11] duplicate_list=[] for d in n: if d not in duplicate_list: duplicate_list.append(d) print(duplicate_list)
7384c16e40dc8ec271b54f4c24f9d5bbf507923a
sureshvenkat91/rock_paper_scissors_game
/rockpapsec.py
4,448
4.03125
4
from sys import exit from random import choice from colorama import init, Fore, Style MOVES = ["rock", "paper", "scissors"] class Player: def __init__(self): """Initializes the player class. When the game starts, all players have randomly attributed previous moves both for them...
7d5368454713beaa66c68e4f58d24cd8076e6ea1
Jaydeep-07/Python-Assignments
/Assignment 2/Assignment2_8.py
210
3.96875
4
def Print(n): for i in range(1, n + 1): n = 1 for j in range(1, 6): if i>=j: print(n, end=" ") n=n+1 else: print(" ",end=" ") print() no = int(input("Enter No Of Rows :")) Print(no)
7a1f7c92d00bd68412dd392034ae00caffd646ea
sachin4653/Hackerrank_question
/sequnce.py
65
3.5
4
n=int(input()) p=0 while p<n: p=p+1 print(p,end="")
0b44b18f760c58ff169f7fa9365cee00ea080551
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/jcbjos008/question2.py
520
3.5
4
'''Joshen Credelio Jacob 16/04/14''' #cost of item cost=eval(input('Enter the cost (in cents):\n')) deposit=0 tot_deposit=0 while tot_deposit<cost: deposit=eval(input('Deposit a coin or note (in cents):\n')) tot_deposit+=deposit change=tot_deposit-cost if change > 0: print('Your change is:'...
cc852300ce92271c5efba6708bf3fbeb038efc16
mbouzid/MetaOA
/scripts/getMax.py
1,035
3.625
4
import sys import re import os assert (len(sys.argv) > 1), "An argument must be given" dir = sys.argv[1] def list_files_recursive(path): """ Function that receives as a parameter a directory path :return list_: File List and Its Absolute Paths """ files = [] # r = root, d = directories, f =...
2764b601ef3df041593d9b7b12d0ef590ef2768c
ttpro1995/code_gym
/challenge/is_smooth.py
661
3.703125
4
# __name__ = "Thai Thien" # # __link__ = "https://app.codesignal.com/challenge/7kZavbM3FBC85FtNA" __author__ = "Thai Thien" __email__ = "tthien@apcs.vn" def isSmooth(arr): """ An array is called smooth if its first and its last elements are equal to one another and to the middle :param arr: the array of in...
7de423b548653cab27711d392e3fd328f81ba9d8
sqiprasanna/coding-questions
/Arrays/kadane_s_algorithm.py
1,055
3.875
4
# Given an array containing both negative and positive integers. Find the contiguous sub-array with maximum sum. # Input: # The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N denoting th...
e24a780afa5f6f66a858d25065c478b928eac10d
MasonEcnu/PythonStarter
/src/main/com/mason/高级特性/list_builder.py
508
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os # 列表生成器 # List Comprehensions list(range(1, 11)) # 列表生成式 ll = [x * x for x in range(1, 11) if x % 2 == 0] print(ll) # 生成全排列 ll = [m + n for m in 'ABC' for n in 'XYZ'] print(ll) ll = [d for d in os.listdir(".")] print(ll) d = {'x': 'A', 'y': 'B', 'z': 'C'} ll =...
55764340547e72c686e44362a0ac0f5f32aba7d9
masha-mulenko/Programming-Basics
/homeworks/serhiy.semyz_SemyzSerhiy/homework 2/homework2.py
1,021
3.8125
4
print ('-=Приветствуем вас на нашем сайте,для продолжения работы заполните анкету=-') name = input('Как вас зовут?\n') surname = input('Какая ваша фамилия?\n') age = input('Сколько вам лет?\n') hobby = input('Какое ваше хобби?\n') mail = input('Введите свой E-mail\n') print ('Спасибо, давайте уточним информацию') nam...
1f9a856b859b5493bd461838e6a333fd1ad6d185
Zitelli-Devkek/GUI-Tkinter-Python
/interfaz etiquetas y btn.py
468
3.671875
4
import tkinter as tk window = tk.Tk() #window.geometry("300x300")# label1 = tk.Label(text="Holaxd", foreground = "green", background="black") label2 = tk.Label (text = "main teemo", foreground = "blue", background="black") label3 = tk.Label (text= "adiós", foreground = "red", background="black") label1.pack() l...
6c152f25f4ab571128410550680770bb8c735dcd
jdiodati20/hangman
/Book/chap6.py
859
3.828125
4
s = "Camus" print(s[0]) print(s[1]) print(s[2]) print(s[3]) print(s[4]) r1 = str(input()) r2 = str(input()) s = "Yesterday I wrote a " + r1 + ". I sent it to " + r2 + "." print(s) s = "aldous Huxley was born in 1894." s = s[0].upper() + s[1:] print(s) s = "Where now? Who now? When now?" l = [] l.append(s[:s.index...
37567a908936aa8a35a1da63dd102905ce6125be
Brian-Musembi/ICS3U-Unit3-01-Python-addition
/addition.py
475
4.1875
4
#!/usr/bin/env python3 # Created by: Brian Musembi # Created on: 29 April 2021 # This program adds two numbers together def main(): # this function adds two numbers together # input num1 = int(input("Please enter the first number: ")) num2 = int(input("Please enter the second number: ")) # proc...
925e4f8dfc2b470f8fc28613a7f96adb0a49f244
alanwutke/python
/valores_variaveis.py
182
3.890625
4
# invertendo valores de variáveis # modo padrão: x = 10 y = 'Luiz' z = x x = y y = z print(f'x={x} e y={y}') # no Python x = 10 y = 'Luiz' x, y = y, x print(f'x={x} e y={y}')
890a4bb910aea48304cdeda59b34420e4ca2ad7f
nyamba/algorithm
/abramov/ABR0606.py
316
3.765625
4
def is_rectangle(a): """ >>> is_rectangle([1, 2, 3, 4]) YES >>> is_rectangle([5, 6, 7, 89]) NO """ if max(a) < sum(a) - max(a): print "YES" else: print "NO" if __name__ == "__main__": from sys import stdin is_rectangle([int(i) for i in stdin.read().split()])
ec0d8dba542174bb381e074a50c568df53a6184a
isaac-friedman/lphw
/ex25.py
1,265
4.3125
4
def break_words(stuff): """breaks stuff into words by spaces""" words = stuff.split(' ') return words def sort_words(words): """Sorts the words alphabetically""" return sorted(words) def print_first_word(words): """Pops and prints the first word. words -- a list of words obtained from break_words(stuff) By t...
4015471fff8c3bb02eb73097c0b658f2214c37ee
kcaashish/PythonJamProjects
/src/part3_q10.py
1,024
3.796875
4
import numpy as np import random import matplotlib.pyplot as plt def monteCarloPi(trials): # trials = int(input("Enter the number of trials:")) trial_list = list(range(1, trials + 1)) circle_points = 0 square_points = 0 calculated_pies = list() for i in range(0, trials): rand_x = rand...
09acdc1996c4f1f86a30887a457195b31af91bbb
zero-miao/alg_sort
/bubble/__init__.py
1,638
4.09375
4
def bubble_sort(lst): """冒泡排序 时间复杂度: 最优: n^2 最差: n^2 空间复杂度: 最优: 1 最差: 1 比较次数: 最优: n^2 最差: n^2 无论什么顺序, 都是 (n^2, 1) 稳定 >>> lst = [7,6,5,4,3,2,1] >>> bubble_sort(lst) [1, 2, 3, 4, 5, 6, 7] >>> lst [1, 2, 3, 4, 5, 6, 7] >>> b...
b7a9efd88f24d8a6b156000b129599a9ec599d5e
keyhamilton/algo-especial
/fabio_lista01/fabiol1q31.py
327
3.671875
4
# entrada binario = int(input('digite um binario de 4 digitos: ')) # processamento mil = binario // 1000 cem = binario % 1000 // 100 dez = binario % 1000 % 100 // 10 uni = binario % 10 decimal = mil * 2**3 + cem * 2**2 + dez * 2**1 + uni * 2**0 # saida print('o binario {} equivale a {} em decimal'.format(binario, dec...
cee0c0399ae8a122f2933c5286f25ece7b447b0d
Karamya/python_lookup
/list_comprehension.py
1,734
3.828125
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 25 13:51:32 2016 @author: perumal """ from functools import reduce """ Filter provides an elegant way to filter out those elements which are true if applied to a function """ lst = [3, 5, 12, 6, 7, 8, 9, 20] print(list(filter(lambda x: x> 10, lst))) print(list(map(lamb...
ea1d772708c8a4e3eea55761b30a645d5f12c7db
zhoucong2/python-
/day2-oneself/练习(运算符).py
136
3.90625
4
# x=1 # y=2 # print(x is y)#值为false x=[1,2,3] y=[1,2,3] print(x is y)#值为false print(x is not y) #值为true print(id(x),id(y))
e292f842371593eb25760ce5212ba5460306aeec
LyonDon/python-learning
/read_document.py
424
3.96875
4
with open('learning-python.txt') as file_object: ''' contents=file_object.read() print(contents) ''' for line in file_object: l=line.replace('python','C') print(l.rstrip()) # print(line) pass ''' lines=file_object.readlines() for line in lines: line.replace('python','C') pass with open('learning-pyth...
7f75e241f4cbbb4a2874c4a61884b4fb840e0e86
kaitlynshelby/Nim
/ksorum_project2_extraFeatures.py
7,757
3.984375
4
# Kaitlyn Sorum # TCSS 142 # Charles Bryan # 12/11/2015 # Programming Project 2 - Nim Game # Extra Features: Players can choose a different character to use # in place of the 'O' stone. Players can also choose if they want to # enable hints. import random def main(): play_again = 'y' while play_again.lower()...
16178fa0a3ae5091e94262919365b27cc0b9471b
frannythebanny/NAO-EPITECH
/bazar/behaviors/rssfeed/languageProcessing.py
4,536
3.59375
4
import os, re, pickle class LanguageProcessing: "This class provides methods to process language (eg: detect lang)." def __init__(self, sDictionaryPath = "/opt/appu/data/pkl"): "The path where the data are stored/to be stored." self.sDictionaryPath = sDictionaryPath # TODO : throw an exception if it's not ...
f2bfd993a55897cab0d7e18a078f334037ab01ce
marianneslamich/citypython
/guess-the-capital.py
483
4.0625
4
import random from list_of_countries import COUNTRIES def main(): countries = list(COUNTRIES.keys()) country_to_guess = random.choice(countries) capital = input("What is the capital of " + country_to_guess + "? ").strip() if capital.lower() == COUNTRIES[country_to_guess]\ ...
613c7ae0e926bf00ee210c7876c8af56e2a86d5f
237rahul/competative-programming
/WEEEK 1/DAY 5/PROBLEM 1.py
1,201
3.8125
4
import unittest def find_rotation_point(words): low=0 high=len(words)-1 while(low<high): mid=(low+high)//2 if (words[mid]<words[mid-1] and words[mid]<words[mid+1]): return mid low=mid+1 if (mid+1==high): return high # Tests ...
d8a2bf50823f01429b978f7a44126bb7f072cbfa
habibabdo/firstpython
/math.py
321
3.859375
4
import math print('SQRT OF 5 = ' +str(math.sqrt(25))) print('SQRT OF 5 = ' +str(math.sqrt(15))) x=math.sqrt(25) print(x) print('math.floor of 2.6 IS ' + str(math.floor(2.6))) print('math.ceil of 2.6 IS ' + str(math.ceil(2.6))) print('POW:') print(3**2) print (math.pow(3,2)) import math as m print (m.pow(3,2)) ...
51ade974a691a55e7a77859eea3a6f754d05288c
acmujica/japans_theaters_now
/media.py
1,000
3.78125
4
import webbrowser class Movie(): """The class Movie describes the basic building blocks to describe the parts of our movie_tile. For more information about the arguments please see the __init__ function. """ def __init__(self, title, storyline, poster_url, trailer_url, release_date): """Ar...
d2b97f0ede1b1be3e54343649a50ba396ec94d4e
clodaghlalor1995/hackerrank
/Day2Operators.py
517
3.828125
4
#!/bin/python import math import os import random import re import sys # Complete the solve function below. def solve(meal_cost, tip_percent, tax_percent): tip = meal_cost*(float(tip_percent)/100) tax = meal_cost*(float(tax_percent)/100) total = meal_cost + tip + tax print(int(round(total...
1cde634ce314ef46009477dc34e1990226f29c76
Jalbanese1441/WiFi-Password-Finder-Program
/WiFi Password Finder Program.py
8,531
3.59375
4
import os import os.path # Necessary for me to work with file structures import time #This lets me add in sleep commands cls = lambda: os.system("cls") #This allows me to clear the console def setUp(networks): # This will set up the program by grabbing all of the network names file=open("temp.bat","w+") # Cerates th...
47b184efe9f826d5b9024904ed50c3c395fe74d0
oliviaclyde/hello-world
/exercises/ex11.py
334
4.21875
4
print("How old are you?", end=' ') age = int(input()) print("How tall are you?", end=' ') height = (input()) print("How much do you weigh?", end=' ') weight = int(input()) print(f"So, you're {age} old, {height} tall and {weight} heavy.") #Practicing formatting of a string weather = "It is {} today." print(weather.for...
c65e95d1b25a86af9aab47667caf1d5c7ce1958c
timswyzen/discordTCG
/cards/Siphon Power.py
438
3.578125
4
#!/user/bin/env python from cardList import addCard import mechanics import math #Simple variables NAME = "Siphon Power" COST = 4 RARITY = 'C' DESC = "Draw a card for every 2 Nodes you control." TARGETS = None TYPE = "PlyInteraction" #What happens when you play it async def playFunc(ply, enemy, target): for _ in ra...
9a7c2043da41a1642d0cdcafbbca51db4bfed0b3
tataurova/lessons-gb-python
/client_server_app/lesson_7/01_slots.py
2,131
4.03125
4
# --------------------- Атрибут __slots__ ---------------------------------- # В обычной ситуации в Python в объекты можно добавлять новые атрибуты # вне описания класса: """ class BasicClass(object): def __init__(self, x, y): self.x = x self.y = y # Создадим объект нашего класса. bc = BasicClass...
feed5c3f7e1c373652dd0fa2a25a4d618715a832
stephano1215/Enterprise_Credit_Predict
/pyfinmod/wacc.py
3,255
3.6875
4
from statistics import mean import pandas as pd def _company_debt(column): """ Uses balance sheet to get company debt. Works only with YahooFinanceParser :param column: Yahoo Finance page parsed to dataframe with pyfinmod.yahoo_finance.YahooFinanceParser :return: series of debt values by date """ ...
09590a1e6560371051d5d73a0e6fc3ac8dbed896
SamuelBUSSON/python_devoir1
/date.py
657
3.515625
4
import numpy as np import pandas as pd file = pd.read_csv("crimeMontreal.csv", encoding = "ISO-8859-1") dataframe = pd.DataFrame(file) #Transformation en dataframe ls_date = dataframe["DATE"].unique() #Liste des DATES max = 0 date_max = 0 for x in ls_date: data = dataframe[(dataframe["DATE"] == x)] total = d...
57caa7be8357c8d9c5f3b7deb21adf68be96b752
Anjalics0024/GitLearnfile
/Project/practice.py
534
4
4
import random def play(): user = input("What is your choice 1. Rock for r 2.Paper for P 3.Scissor for S") computer = random.choice(['r','p','s']) if user == computer: return 'Its a Tie ' if is_win(user,computer): print("You WOn!") print("You loss") def is_win(player, opponent)...
945bbb6df94b34683fb03e0be5226cb5f9ee42d0
nikhiljsk/Programming
/Python/Pycharm/hello_world/recursion.py
119
3.671875
4
def rec(n): if n == 0 or n == 1: return 1 else: return n*rec(n-1) a = rec(5) print(a)
21635fe9746e1939560730975295c4b8ee2d70ba
myGitRao/myPythonJourney
/17_FunctionDocstring.py
678
3.90625
4
# Function : Reusability, defined by keyword def , return type , input & output # In maths as x * y = z is function, similarly in python # Docstring : for 100 lines of code, if someone has written some function, # you can always check what does the function does by printing the doc string def myFunction (a,b): ...
e311922c745e5c1195911b80b09e4cf983de7e05
vhenrik/AvaliacaoAlgoritmos
/Celsius_Fahrenheit.py
134
3.734375
4
c=float(input("Informe a temperatura em graus Celsius: ")) f=c *1.8000 + 32.00 print(c,"em Celsius são iguais a:",f,"Fahrenheit")
d5f4101d319e8a8cfb225a60c9eb1d7773e8bb3e
SFDO-Tooling/Snowfakery
/snowfakery/utils/scrambled_numbers.py
2,257
3.71875
4
from random import Random, randint from copy import copy from math import log from functools import lru_cache @lru_cache() def randomizer(key): return Random(key) @lru_cache() def mask_for_key(key, numbits): r = copy(randomizer(key)) return r.getrandbits(numbits) SHIFT1 = 10 SHIFT2 = SHIFT1 * 100 SHIF...
60d6ced7587367d3120d393be3ee38abedfc0cfd
kevm314/Connect-4-AI
/util_eval.py
8,206
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 24 19:51:21 2019 @author: kevorkmouradian """ import copy def UTILITY(state): if red is winner: return 10000 elif yellow is winner: return -10000 def EVALUATION(state): return 2 #return ...
0a9c108af847c2bf4df10cf6a84b46170d14fcb7
FarzanaEva/Data-Structure-and-Algorithm-Practice
/InterviewBit Problems/Two Pointers/sort_by_color.py
704
3.921875
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 11 22:24:16 2021 @author: Farzana Eva """ """ PROBLEM STATEMENT: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and...
3dfd8d58560948766c07f14dfb69892c2fb0e04d
rossrea/IQT-Projects
/Lab 2F Man A Rag.py
253
4.0625
4
#str1 = "anagram" #str2 = "manarag" if str1 def is_anagram(str1, str2): list1 = list(str1) list1.sort() list2 = list(str2) list2.sort() return (list1 == list2) print(is_anagram('anagram' , 'manarag' )) print(is_anagram('cat' , 'hat '))
52678e8e5638553f567982c619db788f0d54b832
TiMusBhardwaj/pythonExample
/python-and-mongo-master/Tree/sink-nodes-containing-zero-bottom-binary-tree.py
1,626
3.84375
4
# https://www.techiedelight.com/sink-nodes-containing-zero-bottom-binary-tree/ class Node: # Constructor to create a new node def __init__(self, data): self.data = data self.left = None self.right = None def __repr__(self): return str(self.data) # Print Tree data using pr...
b5dc6378c93b56f6b76bba2154a962a154b8a7d9
lacerda92/exercicios-python
/ex019 sorteando um item na lista.py
1,244
4.21875
4
#um professor quer sortear um dos seus quatro alunos para apagar o quadro. #faça um programa que ajude ele,lendo o nome deles e escrevendo o nome do escolhido import random aluno1 = input('NOME DO ALUNO: ') aluno2= input('NOME DO ALUNO: ') aluno3 = input('NOME DO ALUNO ') aluno4 = input('NOME DO ALUNO ') pop...
bfa0cf62a3fd1aec2808393e97a0b659ed90c1fa
valdinei-mello/python
/map.py
1,205
4.5
4
""" MAP Com o map, fazemos mapeamento de valores para função. ------------------------------------ import math def area(r): Calcula a área de um circulo return math.pi * (r ** 2) print(area(2)) print(area(5.3)) raios = [2, 5, 7.1, 0.3, 10, 44] # Forma comum areas = [] for r in raios: areas.append(...
f63e00ac53330284c7a2a1909967d35589739763
vladglazov/OOV
/pr1.py
212
3.796875
4
def Sum(list, s=0): for i in list: s += i return s arr1 = [1, 2, 3, 4, 5] # 15 arr2 = [5, -3, 4, -10] # -4 arr3 = [] # 0 print(Sum(arr1)) print(Sum(arr2)) print(Sum(arr3))
70ee494ccd4126d67e289d7504864bfa4e6ed0d8
Guruprasadsd/PythonSem6
/DAY-1/prg18.py
110
3.6875
4
c=int(input("Enter temperature in celcius")) f=int(c*9/5+(32)) print("{} in farrenheit is {}".format(c,f))
bf19c2d25ff3d44c32554f43ebfaae9305799d7e
jarroba/Curso-Python
/Ejercicios/8.2.-futbolistas.py
2,860
3.625
4
# -*- coding: utf-8 -*- def file_to_list(file_dir): """ Función que dado la dirección de un fichero de texto plano, devuelve un una lista en la que cada elemento de la lista es una linea del fichero :param file_dir: String :return: List """ # TODO def split_list_football_play...
74fed3bf4941dbe733265a3b64920e3fef448cf6
hbzhinsa/Leetcode_python
/isanagram.py
701
3.515625
4
# https://leetcode.com/explore/interview/card/top-interview-questions-easy/127/strings/882/ #%% s='absc' t='csba' class Solution: def isAnagram(self, s: str, t: str) -> bool: if len(s)!=len(t): return False else: mapt={} maps={} for i in s: ...
aed562bb7c71e994283e6dfbd39452e6569a0219
Selen34/geekbrainspython
/homework3/task_5.py
593
4
4
# task 5 # 5. В массиве найти максимальный отрицательный элемент. # Вывести на экран его значение и позицию в массиве. from random import randint #size = int(input('ENTER ARRAY SIZE: ')) size = 10 noise = 10 arr = [randint(-noise, noise) for _ in range(size)] print (arr) target = -(noise * 2) idx = -1 for i in range(s...
b16ef6cdda6441e2a3c14a557d3f3a6711de6b48
shumpei-noda/getTips
/tips_count.py
669
3.546875
4
import sys import json def count(paths): n_tips_list = [] for path in paths: with open(path, 'r') as open_json: tips_json = json.load(open_json) n_tips = 0 for tips in tips_json: n_tips += len(tips_json[tips]['tips']) n_tips_list += [n_tip...
a18d0daf7e9188266d48e514f4e31f1d3391c684
big-roc/Python3Projects
/problem36/demo03.py
422
3.828125
4
# coding:utf8 import math def is_sqr(n): a = int(math.sqrt(n)) return a * a == n def main(): # 题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少? num = 1 while True: if is_sqr(num + 100) and is_sqr(num + 168): print(num) break num += 1 if __name__ == '__ma...
2e425631ae7a77f6bcce69a7639897b0dc7319af
cgarate/intro-to-cs-w-python
/midterm-p4.py
1,398
4.1875
4
# Write a function called getSublists, which takes as parameters a list of integers # named L and an integer named n. # assume L is not empty # assume 0 < n <= len(L) # This function returns a list of all possible sublists in L of length n without # skipping elements in L. The sublists in the returned list should be o...
aa1d0830473d947cc6d9b0d2cb60a3787c87a1ef
IronTailed/isprime
/isprime/isprime.py
1,417
3.71875
4
def checklist(x,list1): tf = False for n in list1: if x % n == 0: tf = True if x % n != 0: pass return tf #so I just realized that checklist() and checkfactor are the same thing ^_^ def checkfactor(x, list1): tf = False for n in list1: if x % n == 0: tf = True break else: pass return tf ...
a25b6d6dda92833b2de5308918b3f8a7806d267e
milenaS92/HW070172
/L04/python/chap3/exercise06.py
867
4.09375
4
# This program calculates the slope of a line trough 2 points def main(): print("This program calculates the slope of a line trough 2 points") valid = False while valid == False: cord1 = input("Enter the first coordinates separated by a comma (x,y): ") list1 = cord1.split(",") x1 = ...
fd907b6e8117b67e9f3b9091624fa8f6a1ec6b66
patrick-luo/Leet-Code
/029. Divide Two Integers.py
1,675
3.703125
4
"""This solution uses addition repititively to find largest power n of 2 such that 2**n*b < a. Then you keep subtracting these multiples of b of the form 2**i*b for smaller powers until the remainder is smaller than b. Each time you subtract, take the previous quotient and multiply by two. If there is any remaining in ...
3093c91e9599e0987f24a63d7b86a406ff5fbea5
armaanjaat/python
/whatapp_bot.py
548
3.6875
4
import pyautogui import time from datetime import datetime now = datetime.now() current_time = now.strftime("%H:%M:%S") #print("Current Time =", current_time) user = input("Please enter the message to be sent") time = int(input("Please tell the time interval between each message") num = int(input("Please enter the n...
095062043dbcf847b64991d7176fe9c1b311f3c3
Jayshri-Rathod/loop
/ex14.py
1,066
3.59375
4
x=1 i=1 while i<=8: space=1 while space<=8-i: print(" ",end="") space+=1 j=1 while j<=x: print("*",end="") j+=1 x+=2 print() i+=1 # x=1 # i=65 # while i<=70: # space=1 # while space<=70-i: # print(" ",end="") # space+=1 # j=1 ...
016044357cd76a6e3e80c8ebc533cec13ab591d6
MoisesAvendanio/MetodosOrdenamiento
/QuickSort.py
592
3.890625
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 25 23:04:33 2019 @author: Crudist """ def QuickSort(list): izq = [] cen = [] der = [] if len(list) > 1: pivote = list[0] for i in list: if i < pivote: izq.append(i) elif i == pivote: ...
79c27e9f6ffae9e734307e315d43b2c186b89784
stijnuijen/Travel-Search-Engine
/flaskr/helpers.py
507
3.65625
4
import re def query(string): query_string = string.replace(' ', '+') return query_string.lower() def paginate(results, n, page): """ Function to create a pagination object that takes the full results list, number of results per page n and the current page as input. Returns the pagination resu...
037b0f690118233d94541a8b2ed72bc68e04f7ef
RandyG3/Python
/07-Strings-Methods/the-find-and-index-methods.py
709
3.984375
4
# Method: A function that acts upon a specific object browser = "Google Chrome" # Where is C by index position. Finds, returns index, if not, -1 print(browser.find("C")) # Stops at 1st occurrance print(browser.find("Ch")) # Stops at 1st occurrance print(browser.find("o")) # Stops at 1st occurrance print(browser.fin...
386662079490dab6685d2e3e633e7305cb9a9436
kevinywlui/CryptoProject
/dec.py
1,305
3.546875
4
########## Cryptography Project ######### ############### Elliptic Curves ############## ## Kevin Lui -- Derek Hollowood ## from time import time from stest import stest from ecur import ecmult from random import randint from sys import stdout from collections import deque def dec(p,k): #Dual Elliptic Curve Dete...
d52ecd1ea04758b8fb816b12c05350d84a137046
santigandolfo/deduccion-genero-por-nombre
/program.py
5,507
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import csv import unidecode # Input: The path of the male names table and the female names # Output: Three sets, one for the male names, one for the female names # and one for all the names which were originally in both tables def generate_list_of_m...
0a50b67a8e071637030b266045f7dcac5e4b7885
ParvathyGS/My-learnings
/Python/pass.py
107
3.734375
4
num = [1,2,3,4,5,6,7,8] for x in num: if x == 4: pass print("pass when values is " + str(x)) print(x)