blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
018fd7991faeacf03e61a1507ce0f610a1d4a668
activehuahua/python
/pythonProject/base/capitalize.py
191
3.84375
4
import string def normalize(name): return name.capitalize() L1 = ['adam','LISA','barT'] #L2 = list(map(normalize,L1)) L2 = [] for item in L1: L2.append(item.capitalize()) print(L2)
6aadee1fb4f03b5d670437f74b278c635e0e1162
vvakrilov/python_basics
/08. Pre_Exam/01. Moon.py
226
3.6875
4
import math average_speed = float(input()) fuel_per_100km = float(input()) distance = 384400 * 2 time = math.ceil(distance / average_speed) + 3 fuel = fuel_per_100km * distance / 100 print(f"{time}\n" f"{int(fuel)}")
d6d0137403291e598d5956738617f460063b5d87
Hozok/HTTPServer
/index.py
1,036
3.671875
4
#coding:utf-8 import cgi import hashlib import os print("Content-type: text/html; charset=utf-8") # Pour préciser que tout ce qui va suivre après dans un print est du code HTML en utf-8. html = """<!DOCTYPE html> <head> <meta charset="utf-8"> <title>Test test</title> </head> <body> """ # Voici donc le code html au...
ff8aefc5ef0f915ff846e3ca6b4f2c4a1e3dd2b2
cs-fullstack-fall-2018/python-review-ex2-jpark1914
/python_review2.py
657
3.9375
4
#====Phase 1===== import random randomNumber = random.randint(0,10) #====Phase 2===== guessedNum = int(input("Guess a number between 0 - 10")) print("First guess is always wrong try again") #====Phase 3===== while(guessedNum != randomNumber and guessedNum != 'q'): guessedNum = int(input("")) if(guessedNum ...
0d8ee3ca062285e1762d040a441c919cac13359b
geekidharsh/elements-of-programming
/primitive-types/reverse-int.py
417
3.96875
4
# given an int, return the reverse of itself. # inp: 1234 # return: 4321 # perform operation on |x| and return along with the sign of x. using built in function abs() def reverse_int(x): rev = 0 x_remaining=abs(x) while x_remaining: rev = 10*rev + x_remaining%10 x_remaining //=10 return -rev if x < 0 else r...
504d40da67dda945eeb6b5a0dd07c3276aa95a78
mircica10/pythonDataStructuresAndAlgorithms
/ds-lists.py
1,969
3.859375
4
class List: def __init__(self, val, next = None): self.val = val self.next = next def printList(self, list): res = '' if list is None: return '' while list is not None: res += str(list.val) + ',' list = list.next return res[0:l...
0a6efc745543a184c93b1d05bb545e983f33c7a6
whyisee/Hadoop-Cluster-Easy
/python/P201/pc_jjxs.py
4,089
3.515625
4
#!/bin/env python import urllib.parse #负责url编码处理 import urllib.request from lxml import etree import os def loadPage(url, filename): """ 作用:根据url发送请求,获取服务器响应文件 url: 需要爬取的url地址 filename : 处理的文件名 """ #print ("正在下载 " + filename) headers = {"User-Agent" : "Mozilla/5.0 (Windows...
20bb7e744f18c0d3cb607f1828025e24f33af802
Disunito/hello-world
/python_work/Chap_five/hello_admin.py
1,092
4.25
4
#5-8 Make a list of five or more usernames, including the name 'admin'. #Imagine you are writting code that will print a greeting to each user after #they log in to a website. Loop through the list, and print a greeting #each other. # -If the username 'admin', print a special gretting, such as Hello admin, # would...
2c242bc4614f993ebb781cc6bd42a5f008945bc1
newjokker/PyUtil
/Z_other/Game/LearnPygame/列表转棋盘.py
1,705
3.640625
4
# -*- coding: utf-8 -*- # -*- author: jokker -*- import pygame import sys import random def run(): clock = pygame.time.Clock() # 定时器 screen = pygame.display.set_mode([320, 400]) x, y = (0, 0) heigt, width = (10, 10) while True: for event in pygame.event.get(): if event.ty...
0b01d2e7921a6d0c9dfcb0fb39c98b009000cd18
ahmedmeshref/Leetcode-Solutions
/test.py
733
3.78125
4
def PreorderTraversal(strArr): preorderArr = [] def preOrderCalculator(node_ind, num_missing_leafs): # base case if node_ind >= len(strArr) or strArr[node_ind] == "#": return 2 preorderArr.append(strArr[node_ind]) left_child = (node_ind * 2) + 1 - num_missing...
99771f9937180fcdf72db09959efd454a762d6eb
GuilhermeFariasn7/infosatc-lp-avaliativo-02
/questao7.py
1,362
4.3125
4
#7- Faça 4 listas: Filmes,jogos,livros e esporte ->> FILMES = ["O poderoso chefão","Parasitas","Fast and Furious", "O menino do pijama listrado","Tá dando onda"] #A - adicionar itens a lista: FILMES.append("frozen") FILMES.append("Diario de um banana") print(FILMES) JOGOS = ["Cs go","LOL","Valorant","GTA V","The last...
d37927187ae5ef4fbd630ad10acaca899f7e0ae3
ljyxy1997/WUST
/4.29/class5-列表操作,多维列表.py
609
3.96875
4
a_list=[1,2,30,30,30,4,2] print(a_list) a_list[0]=100#修改列表中第0个元素 print(a_list) a_list.append(200)#列表最后加元素 print(a_list) a_list.insert(2,300)#在列表中插入一个元素 print(a_list) del a_list[2]#删除列表第3个元素 print(a_list) a_list.remove(30)#删除一个叫30的元素 print(a_list) a=a_list.pop()#弹出列表中最后一个元素 print(a) print(a_list) b=a_list.pop(1)#弹出...
348b6cf0b4c9584fb8020ee730cd7e84172a53df
mukund7296/python-3.7-practice-codes
/kjson.py
117
3.5
4
import json # some JSON: x = '{ "name":"John", "age":30, "city":"New York"}' y=json.loads(x) print(y['age'])
556e3818d1299c7ae4cc156ec68e3221dc0d499e
lll-Mike-lll/botstock
/try_29_random number.py
372
3.859375
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 27 15:02:02 2019 @author: Lenovo """ import random nums = [x for x in range(10)] random.shuffle(nums) print(nums) # ============================================================================= # nums = [x for x in range(100)] # print(nums) # ===========================...
b62f93479867a32bee366e5193b9490d8ef70384
A-N-A-R-K-H/Matrix_Factorization-Recommendation_Engine
/best_model.py
7,333
3.703125
4
""" Colby Wise COMS6998 - Homework1 Matrix Factorization Factorizers a N x M user:item matrix into U: N x r and V: r X M matrices where: - U - User : feature matrix - V - Movie: feature matrix Calculates mean squared error (MSE) and mean reciprocal rank (MMR) on test data after the training data decomposition """ ...
e3d4bf1b5481690bb35eb1d9f482b1b60543bd7b
nihald16/Python-Programs
/split.py
145
3.71875
4
string="hi i am a programer" print(type(string)) a=string.split(" ") print(a,"\n",type(a)) a="-".join(string) print(a) print(type(a))
717bbb395428edb399c64e9847e90a5820920c08
Tanmay53/cohort_3
/submissions/sm_028_sagar/week_13/day_4/session_1/count_occurences_string.py
327
3.78125
4
string = 'masaischool' occr = {} #occurences of each character for char in string: isFound = False for key in occr: if(key == char): isFound = True occr[key] = occr[key]+1 break # print(char,isFound) if(isFound == False): occr[char] = 1 print(o...
6cbc40d5852cb72b56df2596752064108690ef8d
serdardoruk/Bloomberg-Common-DS-Algo-Python-Solutions
/arrayValuesOfIndices.py
1,223
3.640625
4
''' Input a = [21,5,6,56,88,52], output = [5,5,5,4,-1,-1] . Output array values is made up of indices of the element with value greater than the current element but with largest index. So 21 < 56 (index 3), 21 < 88 (index 4) but also 21 < 52 (index 5) so we choose index 5 (value 52). Same applies for 5,6 and for 56 i...
fa4024757d899635360db79b14fcb4e3d5e610af
jessy1082/itp_week_1
/day_3/test.py
1,012
3.8125
4
list_4 = ["abc", 34, True, 40, "male"] list_5 = [["John", "Smith"], ["Jane", "Doe"]] print(type(list_5)) # <class 'list'> print(len(list_5)) # 2 fruits = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"] print(fruits[0]) # "apple" print(fruits[-1]) # "mango" print(fruits[-7]) # "apple" print(fruits[2:...
bc9f45158341a38bb908793c649916dd56eb0775
amcgrat/UCD_DATACAMP
/WEEK_4.py
1,118
3.890625
4
import pandas as pd import numpy as np #raad the .csv file netflix_data = pd.read_csv(r"C:\Users\amcgrat\\Desktop\netflix_titles.csv") #Take a first look to understand the data #print(netflix_data.head()) #print(netflix_data.shape) #Count missing values in each column missing_values_count = netflix_data.isnull().sum...
c286fd68f207fee0d0a91dcd511762eeb75fdc78
yoyocheknow/leetcode_python
/3_lengthOfLongestSubstring.py
2,250
3.796875
4
# -*- coding:utf-8 -*- class Solution(object): # 其实这道题我卡了很久,原因是不知道python从i+1的地方遍历,然后就想到用while的方式,每次for循环一次,就把上一次循环过的字符删掉 def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ if not s: return 0 tmp_list=[] max_length=1 ...
e628908685020e60cc86acd6d4c4e14edd6280a2
UMBC-CMSC-Hamilton/cmsc201-spring2021
/files_dir/fileio_slices.py
7,131
4.15625
4
if __name__ == '__main__': """ How do you open a file? There's a built-in-function File name is a string, literal, or a variable. """ if False: x = 3 # pycharm is reading everything as being based in the main directory. # because we're ...
d3ee02507c3e1f4e4e559d2b4bc620f04d542247
Indra-Ratna/LAB9-1114
/lab9_problem4.py
216
3.515625
4
#Indra Ratna #CS-UY 1114 #2 Nov 2018 #Lab 9 #Problem 4 def mycount(lst,n): count=0 for element in lst: if(element == n): count+=1 return count print(mycount([7,2,1,3,7,9],7))
70389e06f7d1863e66a43cac9a85cca1be36f290
upsharma8/Python_Programs
/Python Programs/demo16.py
551
4
4
#File Handling #How to acess a file #Step 1- Create a file to be access #Step 2- Access the file ''' open('E:\\upmanyu\\Python\\myname.txt','r') print(r.read()) r=open('E:/upmanyu/Python/myname.txt','w') r.write('I am a python programmer \n I like to write python code') r.close() print('File written succe...
ff8e7bb527961d2813417f40e5fcc3c03f056b94
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/mknnit002/util.py
2,194
3.796875
4
#mknnit002 #question2 ass 7 def create_grid(grid): """create a 4x4 grid""" for i in range (4): grid.append([0]*4) #append each row of the grid one at a time return grid def print_grid(grid): """print out 4x4 grid in 5-width columns within a box""" print("+-------...
ab38e492222ce3e77a98b3dbf9184f2b6e2dc3c6
anuunnikrishnan/Python
/PYTHON 1/DbconnectPython/Dbconnection2.py
457
3.65625
4
from DbconnectPython.openconnection import * db=getconnection() print(db) # prepare a cursor object using cursor() method cursor=db.cursor() # Drop table if it already exists using execute() method cursor.execute("DROP TABLE IF EXISTS EMPLOYEE") # Create table as per requirement sql="""CREATE TABLE EMPLOYEE( FI...
1645d55d7dfe1291c84e1ae05e4dbf1262fff745
AlgorithmStars/Jeongmin
/leetCode/06longestPalindrome.py
981
3.609375
4
class Solution: def findShortPalindromeIndex(self, s:str) -> tuple[int, int]: if len(s) == 1: return for start in range(len(s) - 2): if s[start] == s[start + 2]: #odd palindrome yield start, start + 2 if s[start] == s[start + 1]: # even palindrome...
4f2158b8fee86e2d4f29765e127f075139e6fbb6
PetrTimof/pyth2
/less3.py
2,841
3.546875
4
# 1 def non_zero_del(var1, var2): try: result = var1 / var2 except ZeroDivisionError: return "Вы разделили на ноль и перешли на следующий уровень бытия! Поздравляю!" else: return result temp = non_zero_del(int(input('Введите делимое:\n')), int(input('Введите делитель:\n'))) print(...
0e05d3777858898a466c080299a6d1b0730b69ae
avanishsingh07/CodeChef_DSA
/»_Factors_Finding.py
189
3.59375
4
n = int(input("Enter the number")) l = [] count = 0 for i in range(1,n+1): if n % i == 0: count = count +1 l.append(i) print(count) for j in l: print(j, end = " ")
6653eab81f09a61c4631f8308b38e89679427652
prithvi020397/awesomeScripts
/yt_clipper/yt_clipper.py
2,891
3.90625
4
#! /usr/bin/env python3 import re import argparse import subprocess def find_url(string): """ Finds an arbitrary number of URLs in a string and returns them in a list. Taken from: https://www.geeksforgeeks.org/python-check-url-string/""" regex = ( r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[...
4ee7d820d8f32386cf5b3c0296f0cef7208252c7
KhanyiMM/Pre-bootcamp-python
/Task 4.py
183
3.984375
4
def three(x,y): total_sum = x + y if '3' in str(total_sum): return True elif x == 3 or y == 3: return True else: return False print(three(7,8))
cd68ed20c520f22a480d640590feb8c388b3a87d
cedro-gasque/cs-module-project-recursive-sorting
/src/sorting/sorting.py
2,665
4
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): arr = [] a = b = 0 while a < len(arrA) and b < len(arrB): l = arrA[a] < arrB[b] n = not l arr.append(arrA[a] * l + arrB[b] * n) a += l b += n arr.extend(arrA[a:]) arr.e...
25ed1ca68b6618791ab658b86940770d02658631
flyfatty/PythonTutorial
/leetcode/tree/106.py
845
3.65625
4
# @Time : 2020/10/14 13:23 # @Author : LiuBin # @File : 106.py # @Description : # @Software: PyCharm """从中序与后序遍历序列构造二叉树 关键字: 后序遍历 思路: 1、利用后序遍历列表定位root 2、利用中序遍历列表定位左右子树,注意是先右再左 3、递归缩减问题规模 """ from utils import TreeNode from typing import List class Solution: def buildTree(self, inorder: List[int], postorder: Lis...
972f8b85276b235ebcfa947435b7de0eb15f65b7
CompPhysics/MachineLearning
/doc/src/week36/programs/test2.py
1,727
4.09375
4
import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression np.random.seed(2021) def fit_beta(X, y): return np.linalg.pinv(X.T @ X) @ X.T @ y true_beta = [2, 0.5, 3.7] x = np.linspace(0, 1, 11) y = np.sum( np.asarray([x ** p * b for p, b in enumerate(true_beta)])...
90889eef40379753e32ac7a61da5b49a921e1dac
andigibson93/snake-game
/pysnake/snake.py
6,055
3.5
4
from pygame.locals import * from random import randint import pygame import time SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 SNAKE_SIZE=25 APPLE_SIZE=20 BANANA_SIZE=20 CHERRY_SIZE=20 GRAPE_SIZE=20 class Fruit: x = 0 y = 0 def __init__(self,x,y): self.x = x * APPLE_SIZE self.y = y * APPLE_SIZE...
527aef6e93a1966a3f349ed5e79e9d5a34612905
sgriffith3/2020-12-07-PyNDE
/funcy.py
405
3.953125
4
""" This is an example of a basic function. """ def add_111(any_number): """ This function adds 111 to any_number """ response = any_number + 111 print(f"Your number is: {response}") return response add_111(55) add_111(5) add_111(89) add_111(3.14) print(add_111(42)) x = add_111(add_111(1)) pr...
ad1ea5d5eaccebf301240d604f66cc34cc9ffa01
mwroffo/FastCardsOnline
/app/Deck.py
3,990
4.125
4
from Card import Card """ Representing a deck of flash`Card`s. There are plenty of prebaked structures for this purpose, but for the sake of data structures practice, I built this from scratch. In data structures terms, this is most like a List. It allows inserts and removals at head, tail, or anywhere in the middl...
f39ded82b49866952dc9e686639312704c85cf8a
suppressf0rce/ProgramTranslators_Homework1
/src/Token.py
1,121
4.1875
4
# Token types # # EOF (end-of-file) token is used to indicate that # there is no more input left for lexical analysis INTEGER, PLUS, MINUS, MUL, DIV, EOF, OPEN_PARENTHESES, CLOSE_PARENTHESES, STRING, ASSIGN, COMMA, EQUALS, LESS, GREATER, LEQUALS, GEQUALS = ( 'INTEGER', 'PLUS', 'MINUS', 'MUL', 'DIV',...
854e433fd05d867c6983a63dcc21f038108158a1
letsgolesco/Project-Euler
/problem_22.py
1,016
3.78125
4
# Names scores # # File given: names.txt, containing over 5000 first names # Begin by sorting the list into alphabetical order # Then work out the alphabetical value for each name # (sum of numbers corresponding to each letter) # Multiply this value by its position in the sorted list # That's the name score! # # What's...
036a4525469b44316dc47bc2caee3e6b03fa8c58
praneethpeddi/Python-Assignments
/Oct20th-Dictionaries/diff_copy_assignment.py
377
4.28125
4
# assigning using assignment operator dict1 = {1: 'one', 2: 'two', 3: 'three', 4: 'four'} dict2 = dict1 dict2.clear() print(dict1) print(type(dict1)) print(dict2) print(type(dict2)) print() # assigning using the copy method dict1 = {1: 'one', 2: 'two', 3: 'three', 4: 'four'} dict2 = dict1.copy() dict2.clear() print(...
71c6c990cb067a053461d52af67c6a7f6bfa3c21
crystalDf/Automate-the-Boring-Stuff-with-Python-Chapter-10-Debugging
/traceback_format.py
262
3.65625
4
import traceback try: raise Exception('This is the error message.') except: error_file = open('errorInfo.txt', 'w') print(error_file.write(traceback.format_exc())) error_file.close() print('The traceback info was written to errorInfo.txt.')
bcf8b2e0750fb6d7d77df4712f801d44404ac7ff
gvolsky/Python-algorithms-practice
/BST.py
6,268
3.625
4
class BSTNode: def __init__(self, key, val, parent): self.NodeKey = key self.NodeValue = val self.Parent = parent self.LeftChild = None self.RightChild = None class BSTFind: def __init__(self): self.Node = None self.NodeHasKey = False ...
2a53bacaa3ebddac6bff10bef303c2cec25a69ac
s0409/DATA-STRUCTURES-AND-ALGORITHMS
/LONGEST CONSECUTIVE SUBSEQUENCE/main.py
457
3.765625
4
def longestsub(arr,n): #create hash s=set() ans=0 #insert all elements to hash for ele in arr: s.add(ele) #look for arr[i]-1 for i in range(n): if arr[i]-1 not in s: j=arr[i] while j in s: j+=1 ans=max(ans...
03f2c7f18b203cf6cac51f264e813730ac196cfa
cy275/Statistics_Calculator
/Stat_Calculator/Median.py
217
3.734375
4
def median(a): a = sorted(a) list_length = len(a) num = list_length//2 if list_length % 2 == 0: median_num = (a[num] + a[num + 1])/2 else: median_num = a[num] return median_num
2424d4fca4b1c3e51647f3101ee983fbe900a627
LocNguyenHuu2k/LocNguyen
/list_practice.py
505
3.6875
4
games = ["CSGO", "PUBG", "Leage of Legend", "Star Craft 2"] print(*games,sep=", ") new_games = input("What games would you like to add?") games.append(new_games) print(*games,sep=", ") remove_game = input("What game would you like to remove?") games.remove(remove_game) print(*games,sep=", ") for game, index in enum...
967374a6092bdadf0f75662a1d85e012d208aa00
kitizl/spongePy
/spongePy.py
1,103
3.78125
4
#! python3 import sys import random def spongify(s): output = "" for i in range(len(s)): if i%2 == 0: output += s[i].upper() else: output += s[i].lower() return output def sponge_real(s): output = "" for i in range(len(s)): if random.randint(0,1): ...
a1838322f123312e2009600c0af5ccac4d968024
pmheintz/PythonTutorials
/methods/methods_demo2.py
508
4.25
4
""" Working with more methods Adding documentation """ def sum_nums(n1, n2): """ Get the sum of 2 numbers :param n1: first number :param n2: second number :return: sum of n1 and n2 """ return n1 + n2 sum1 = sum_nums(1, 2) print(sum1) print(sum_nums(5, 7)) string_add = sum_nums("one", "two...
5e40f7e89c9ea1d4c5e4d7665a8743645b6233db
All3yp/Daily-Coding-Problem-Solutions
/Solutions/179.py
716
4
4
""" Problem: Given the sequence of keys visited by a postorder traversal of a binary search tree, reconstruct the tree. For example, given the sequence 2, 4, 3, 8, 7, 5, you should construct the following tree: 5 / \ 3 7 / \ \ 2 4 8 """ from typing import List from DataStructures.Tree import Bina...
f3f46edd2095db1cab58f27d92b568b96a3e9600
scric/Python3.x-2017
/begginger/2017-03-07/第四章 - 持久存储 - try/missingFile.py
926
3.953125
4
# 尝试打开一个不存在的文件 # try: # data=open('missing.txt') # print(data.readline(),end='') # except IOError: # print('File error') # finally: # data.close() ''' 出现错误 Traceback (most recent call last): File error File "D:/Python/python-git/begginger/2017-03-07/missingFile.py", line 12, in <module> data.cl...
8fc723c6bea4f557dddd68cd1d8fdf78fe61fc27
stefanolocci/English-Italian-Direct-Translator
/En_It_Translator/utils/NumberUtility.py
1,657
3.703125
4
class NumberUtility: def is_ordinal_number(self, word): try: int(word.replace('th', '')) return True except ValueError: return False def is_number(self, word): try: float(word) return True except ValueError: ...
700eb342c6eda26665431b0f2b77b34c0d831248
danrfiuza/learningpython
/datetimeexample.py
507
3.96875
4
import time; import datetime import calendar ticks = time.time() now = datetime.datetime.now() # print("Number of ticks since 12:00am, Jan 1,1970: ",ticks,end="\n") # cal = calendar.month(now.year, now.month) # print ("Here is the calendar:",end="\n") # print (cal) date = input('Wanna see calendar? type a date on thi...
567f1004a4cd606b6458abd21585abc577350ba3
iwwxiong/leetcode.python
/5.longest-palindromic-substring/test_longest_palindromic_substring.py
928
3.6875
4
from longest_palindromic_substring import Solution, is_palindrome def test_is_palindrome(): assert is_palindrome("a") is True assert is_palindrome("aa") is True assert is_palindrome("ab") is False assert is_palindrome("abcb") is False assert is_palindrome("aba") is True def test_longestPalindrom...
c3a2537add062a6b9a66ba203cfd83874c428f9f
lytr777/EvoGuess
/method/solver/models/option.py
691
3.609375
4
class SolverOption: def __init__(self, name, value): self.name = name self.value = value def str(self, form): return form % (self.name, self.value) def __str__(self): return self.str('%s=%s') def __eq__(self, other): if hasattr(other, 'name'): retur...
de93c76ce532000608a092c47b2060192459da58
dikshaa1702/ml
/mini project/challenge1.py
573
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue May 7 19:30:18 2019 @author: DiPu """ import random guess=random.randrange(1,11) print("enter number") no=int(input()) if(guess==no): print("player wins and computer lose") else: print("player lose and computer wins") print("random no: {0}".format(guess,no)) print("...
d38cdb22f512683edc15a7f2d12cda9c6f4b52f0
MacJei/pyspark_py
/pyspark_1.py
47,319
4.1875
4
# What is Spark, anyway? # Spark is a platform for cluster computing. Spark lets you spread data and computations over clusters with multiple nodes (think of each node as a separate computer). Splitting up your data makes it easier to work with very large datasets because each node only works with a small amount of da...
91be2e2437046bd4dba1aeec273c6ebabd7462f5
MamontRussel/2019_PPO_sociology
/Seminar_6_7.py
26,824
4.09375
4
''' Недели 5-7 Сoursera. Чтение файлов, множества, словари, обработка ошибок, дополнительные методы работы со строками. ''' ''' МЕТОДЫ РАБОТЫ СО СПИСКАМИ Списки в Python поддерживают множество методов для взаимодействия с ними. Стоит отметить, что эти методы изменяют исходный список. ''' test_list = list(range(10)) ...
7c2c2b3a2892a75a2d4640626e922e8b2aae8566
pakoy3k/MoreCodes-Python
/Basics9.py
339
3.6875
4
#Basics of Functions def function1(): print "Hello there!" def function2(num): print "That number is ", num def function3(): num_sum = 1 + 1 return num_sum def function4(firstName, lastName): fullName = firstName + " " + lastName; return fullName; function1(); function2(5); print function3(); print function4...
e029d0a0956ad8294d039763f3b14e548494c702
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/topics/Collections/45/fifo.py
442
4.15625
4
from collections import deque def my_queue(n=5): return deque(maxlen=n) if __name__ == '__main__': mq = my_queue() for i in range(10): mq.append(i) print((i, list(mq))) """Queue size does not go beyond n int, this outputs: (0, [0]) (1, [0, 1]) (2, [0, 1, 2]) (3, [0, 1, 2, 3]) (4, [0, 1...
589e1196bcadd87bce66d0755e4694dd91651da3
TobiasYin/LeetCodeKotlin
/src/answer/leetcode/LeetCode1.py
410
3.53125
4
class Solution1: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ nums_set = set(nums) for i in nums_set: if target-i in nums_set: index_1=nums.index(i) nums[index_1]=...
92243ca39cd61c370a56c294c065dc7cd79a964d
alightwing/advent-code-2019
/day_2.py
2,195
3.953125
4
# Advent of Code Day 2 solution - https://adventofcode.com/2019/day/2 # TEST DATA # raw_program = "1,0,0,0,99" # output 2,0,0,0,99 # raw_program = "2,3,0,3,99" # output 2,3,0,6,99 # raw_program = "2,4,4,5,99,0" # 2,4,4,5,99,9801 # raw_program = "1,1,1,4,99,5,6,0,99" # output 30,1,1,4,2,5,6,0,99 # ACTUAL DAT...
95188332c3276d0089f90f34121cd5280bab8892
kexinl/test_github
/test4.py
1,015
4.09375
4
from datetime import datetime def is_leap_year(year): is_leap = False if (year % 400 == 0) or ((year % 100 !=0) and (year % 400 == 0)): is_leap = True return is_leap def main(): input_date_str = input('请输入日期(yyyy/mm/dd/): ') input_date = datetime.strptime(input_date_str, '%Y/%m/%d') prin...
5dd29e321f43b2f9be08fabcd81a27a63d353cdc
laobadao/Deep-Learning
/homework/01_neural_network_deeplearning/week_2/part_1_1.py
3,207
4.96875
5
""" 吴恩达Coursera深度学习课程 DeepLearning.ai 编程作业(1-2) Part 1:Python Basics with Numpy (optional assignment) 1 - Building basic functions with numpy Numpy is the main package for scientific computing in Python. It is maintained by a large community (www.numpy.org). In this exercise you will learn several key num...
a109aabea2626c986f6d6ac3835c7cbfba826d34
anilachacko/python
/CO2/C002.py
157
3.859375
4
n=int(input("enter the limit")) a=0 b=1 print("fibonacci series") print(a) print(b) for i in range(1,n-1): c=a+b print(c) a=b b=c
d504f75cf01c29b1a096215477aae8f7d6f55ec9
kamojiro/atcoderall
/beginner/176/B2.py
44
3.671875
4
print("Yes" if int(input())%9==0 else "No")
92129c31f56378d915ac4d2f576d70cd8fe2bd8d
mwrouse/Python
/Chapter 10/challenge10_1.py
4,563
4.03125
4
""" Program......: challenge10_1.py Author.......: Michael Rouse Date.........: 3/5/14 Description..: Create your own version of the Mad Lib Program """ from tkinter import * class Application(Frame): """ GUI application that creates a story based on user input. """ def __init__(self, master): ...
0c47464c0b7e249f89c517ba2a03c16d25551ebd
nitsuga/mrplan
/src/mrplan_auctioneer/src/mrplan_auctioneer/item.py
1,073
4.03125
4
"""item.py This module defines the Item class used in MRPlan experiments. Eric Schneider <eric.schneider@liverpool.ac.uk> """ from enum import Enum class Material(Enum): """ Materials are composed to make up Items. At first, this class just identifies and distinguishes one material from another via an ...
4a1ea738d3d4eb866346b25aee832f31ae1540f6
porala/python
/practice/88.py
385
3.875
4
#Create a script that uses countries_by_area.txt file as data sourcea and prints out the top 5 most densely populated countries import pandas data = pandas.read_csv("countries_by_area.txt") data["density"] = data["population_2013"] / data["area_sqkm"] data = data.sort_values(by="density", ascending=False) fo...
62c5a065fedcfae0f79abff797ba06b21b46bd9c
cmirza/cs_work
/Unit_2/module_3.py
1,447
3.671875
4
def validBracketSequence(sequence): # define opening and closing chars open_char = ("(", "[", "{") close_char = (")", "]", "}") stack = [] # iterate over chars in sequence for char in sequence: if char in open_char: stack.append(char) elif cha...
b1efd564425abb04f08f754e34ec7bb01dcce28e
CptnSteve/prime_viz
/prime_viz.py
1,254
3.59375
4
import numpy as np import matplotlib.pyplot as plt def move_right(x,y): return x+1, y def move_left(x,y): return x-1, y def move_up(x,y): return x,y+1 def move_down(x,y): return x,y-1 def gen_points(end): from itertools import cycle moves = [move_right, move_down, move_left, move_up] _mov...
074cf3c8a34d270d0e1c06462c2c637d54058e37
ianbooth12/python_crash_course
/chapter_2/2lesson.py
420
3.96875
4
inches_in_foot = 12_000_000 print(inches_in_foot) # Although Python removes underscores in print, makes more readable. x, y, z = 0, 0 ,0 print(x) # You can define multiple variables in one line of code with commas name1, name2, name3 = "mason", "jad", "kadin" print(name2) # Multiple variables can also be defined wit...
1c3fe91750ccb3f3873aba3d36fe7bcb302993ac
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4352/codes/1650_2450.py
127
4.03125
4
a = input("digite um nome:") b = input("digite outro nome:") if (a > b.upper()): print(b) print(a) else: print(a) print(b)
2e8181335d92a1f63aa6e07a865110d74d52a66d
LucasOJacintho/Curso_em_video_python
/Exercícios/ex84.py
913
3.734375
4
pessoas = [] dados = [] maior = menor = 0 while True: dados.append(str(input('Digite o nome: '))) dados.append((float(input('Digite o peso em kg: ')))) ##teste para definir qual é o peso maior e menor if len(pessoas) == 0: maior = menor = dados[1] else: if dados[1] > maior: m...
e148b845fbc45964a0d3de23b60f704e60386933
T-o-s-s-h-y/Learning
/Python/progate/python_study_2/page2/script.py
360
3.640625
4
# 変数fruitsに、複数の文字列を要素に持つリストを代入してください fruits = ['apple', 'banana', 'orange'] # インデックス番号が0の要素を出力してください print(fruits[0]) # インデックス番号が2の要素を文字列と連結して出力してください print("好きな果物は" + fruits[2] + "です")
257ef0e3cc3999e05789c38a8d071e839127fdd7
mattsuri/unit3
/quiz3.py
298
3.609375
4
#Matthew Suriawinata #3/5/18 #quiz3.py num = -15 while num < -8: print(num) num += 1 for i in range(50, 17, -4): print(i) total = 0 for i in range(-100, 1000, 2): total += i print(total) while True: text = input("Enter text: ") if "alpaca" in text: break
e095fcff239d4f6e7781b37f32fc0b828b6b0ed8
santhoshbabu4546/GUVI-9
/set7/prime1.py
197
3.875
4
import math a2=int(input()) x=0 if a2 == 2 and a2 == 3: print("yes") for i in range(2,int(math.sqrt(a2))+1): if a2%i==0: print("no") x=x+1 break if x==0: print("yes")
3437e33328dff4970cd7df338f4ff914ec55fb32
NidhoggZe/LeetCode
/py/1.两数之和2.py
486
3.59375
4
#用hashmap记录是否出现过(字典同时还能将索引存为值)O(n) class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ hashmap = {} for i in range(0, nums.__len__()): if target - nums[i] in hashmap: ret...
8304a0454f11294a1e9a36f410c6806da5260cb8
chetanpv/python-snippets
/LevelTwo/square_odd_numbers.py
558
4.25
4
# Question: # Use a list comprehension to square each odd number in a list. The list is input by a sequence # of comma-separated numbers. # Suppose the following input is supplied to the program: # 1,2,3,4,5,6,7,8,9 # Then, the output should be: # 1,3,5,7,9 print "\nEnter sequence of numbers: " numbers = raw_...
97aa9934fd753069b47ffa1518c5945a031dc0e0
WellingtonTorres/PythonExercicios
/ex009.py
182
3.859375
4
n = int(input('Digite um numero para ver sua tabuada: ')) i = 1 print('-' * 11) while i <= 10: r = n * i print('{} x {:2} = {:3}'.format(n, i, r)) i += 1 print('-' * 11)
8ffe034bda17bdde0d334ead9424d4e2589a8bb4
rkpatra201/python-practice
/python-basics/109_tuples.py
268
4
4
# tuples are same as list but are immutable item = (1, 1, "test", 3.2, {'a': 'b'}) print(item) print(type(item)) print(item[0]) print(item[2:]) print(len(item)) print(item.index(1)) print(item.count(1)) #item[2] = 20 #'tuple' object does not support item assignment
fd4e3cb4a2cd28da6ba2e5a1657df44ed81421a2
nickyfoto/lc
/python/tests/1345_jump_game_iv.py
10,674
3.5
4
# # @lc app=leetcode id=1345 lang=python3 # # [1345] Jump Game IV # # https://leetcode.com/problems/jump-game-iv/description/ # # algorithms # Hard (27.33%) # Likes: 37 # Dislikes: 1 # Total Accepted: 1.4K # Total Submissions: 5.1K # Testcase Example: '[100,-23,-23,404,100,23,23,23,3,404]' # # Given an array of ...
96b3f2f8175545ecf04a3dd05fd61d21a8a15f3b
NathanPaceydev/MadLibs-Oh-The-Places-You-Will-Go
/Rewrite_story_scrape.py
1,974
3.71875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #first time scraping program ## I wanted to do something static to start and just have fun with the outcome # import libraries import requests from bs4 import BeautifulSoup # In[2]: # scraping the staic website URL = "http://denuccio.net/ohplaces.html" page = reque...
e0e5b303749671f617a28d8c84a3bacd00fb24f7
moguzozcan/HackerrankSolutions
/Python/scripts/while_loop.py
300
3.6875
4
c = 5 while c != 0: print(c) c -= 1 c = 5 while c: print(c) c -= 1 #Zen of Python explicit is better than implicit, use the first one #Infinite loops, if divisible by 7, exit the loop while True: response = input() if int(response) % 7 == 0: break
6bbc0fa9537921344976be8d802b5a21e4542f93
5l1v3r1/crypto_utils
/morse/main.py
714
3.6875
4
#!/usr/bin/python "Morse encoder/decoder with option of custom charset, CC-BY: hasherezade" import argparse from morse import * def main(): parser = argparse.ArgumentParser(description="Morse Encoder/Decoder") parser.add_argument('--charset', dest="charset", default='.- ', help="Charset in format: 'DitDashBre...
bb5dd5eee44a3a59bd9371bf65bcfd293df34cec
avenet/hackerrank
/algorithms/implementation/repeated_string.py
268
3.59375
4
s = input().strip() n = int(input().strip()) a_count = s.count('a') whole_str_reps = n // len(s) partial_str_length = n % len(s) partial_str = s[:partial_str_length] partial_str_a_count = partial_str.count('a') print(a_count * whole_str_reps + partial_str_a_count)
a070a1d91a9d2cb4ddaf5fcae2c3ae6dd7251844
chauhanvishu/shiny-dollop
/ab/1.py
247
3.796875
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 12 23:52:15 2018 @author: aksha """ our_list = [] first_num = int(input('Enter first number: ')) second_num = int(input('Enter second number: ')) third_num = int(input('Enter third number: '))
a2978b664b22a741f9200cf18cbf12afa8167e7d
EricMoura/Aprendendo-Python
/Exercícios de Introdução/Ex030.py
152
4
4
num = int(input('Digite um número inteiro qualquer: ')) if num%2 == 0: print('Esse número é par') else: print('Esse número é ímpar')
3d9c924be611582a9b609dff66c250c143326f03
cdiebold/python-class
/longest_word.py
327
4.03125
4
def longest_word(sen): for ch in sen: if not char.isalnum(): sen = sen.replace(char, ' ') return max(sen.split(), key = len) if __name__ == "__main__": sen1 = "fun&!! time" sen2 = "I love dogs" res1 = longest_word(sen1) print(res1) res2 = longest_word(sen2) print...
f4dd5068593579ae03d92f59e53fc6349086e556
choiseoungho/ssafy
/Day2/3장/ex2.py
728
3.578125
4
# 사용자가 시청한 작품의 리스트를 저장합니다. 수정하지 마세요. user_to_titles = { 1: [271, 318, 491], 2: [318, 19, 2980, 475], 3: [475], 4: [271, 318, 491, 2980, 19, 318, 475], 5: [882, 91, 2980, 557, 35], } def get_user_to_num_titles(user_to_titles): ''' 사용자가 시청한 작품의 수를 리턴합니다. >>> get_user_to_n...
b5f1a6dbd33e6dc74106a9b38fee73f9c4058b5e
Prasanna0708/forloop-task
/while.py
119
4.3125
4
print("By using While Loop Printing values reverse from 10 to 1") x = 10 while(x>0): print(x) x = x-1
fdfaac9f6b17907935bdfd2f2d23652b9ea22f4c
A-Chornaya/Python-Programs
/Other tasks/dejkstra.py
3,492
3.75
4
# Algorithm Dejkstry # search for the shortest path from one knot of the graph to all others # Matrix as a list of lists from collections import deque def dejkstra(matrix, start): n = len(matrix) distance = [None] * n path = [0] * n distance[start] = 0 nonvisited = [start] visi...
6652cea1f27b477a57b8732b31db418c88ed5c67
thrama/coding-test
/python/gradingStudents.py
1,384
4.09375
4
import math import os import random import re import sys # # HackerLand University has the following grading policy: # - Every student receives a grades in the inclusive range from 0 to 100. # - Any grade less than 40 is a failing grade. # # Sam is a professor at the university and likes to round each student's grade ...
17a2aa1badf14781162aa8c3bf172de640cbaea8
vimkaf/Learning-Python
/comment_break.py
205
3.796875
4
# This is a single line commment """ This is a multiline comment """ num = 15 for x in range(100): if x is num: print('x is the number') break else: print(x)
bd9572157e1c093764b8b1ebd0c0b9f0119fc871
Daria706/Lab
/Task 2.py
217
3.953125
4
a = float(input("Введите основание a")) h = float(input("Введите высоту h")) S = 0.5 * a * h if S%2 == 0: S=S/2 print("S=",S) else: print("Не могу делить на 2!")
afc23bc1cd715817243dde7acdf39c00570c6472
mepujan/IWAssignment_1_python
/data_types/data_type_21.py
353
4.375
4
# Write a Python program to get a list, sorted in increasing order by the last # element in each tuple from a given list of non-empty tuples. def last(n): return n[-1] def sort_list_last(tuples): return sorted(tuples, key=last) def main(): print(sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])) if __...
cfd730b4343cc845beae838a576d06d08c83f6c9
RhysMurage/alx-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
418
4.375
4
#!/usr/bin/python3 """ Module that has the function print_square """ def print_square(size): """Prints a square using the character '#' Args: size (int): dimensions of the square """ if not isinstance(size, int): raise TypeError('size must be an integer') if size < 0: rai...
e1ddc5442fae207bd82bece5723465c1d6257ced
ArpitSharma2800/Algorithms-and-Basic-Programmes
/Python/Algorithms/LeftSumArray.py
1,048
3.65625
4
# Given, an array of size n. Find an element that divides the array into two sub-arrays with equal sum. def naive_method(arr): # slower method # O(n^2) n = len(arr) counter = 0 for x in range(n): # calculating sum of left and right part and comparing values if sum(arr[:x]) == sum(a...
3c254824529fc639c8a3bd47fc9fe772329f9a5a
perext5528/Python_2019
/repl.it Example/3. If & Else/H. Queen move.py
186
3.75
4
x1 = int(input()) y1 = int(input()) x2 = int(input()) y2 = int(input()) dx = abs(x1 - x2) dy = abs(y1 - y2) if (x1==x2) or (y1==y2) or (dx == dy): print("YES") else: print("NO")
b57ecc5edda54252e5c44e2eda6dea963029124b
seanchen513/leetcode
/bits/0260_single_numer_iii.py
2,381
3.984375
4
""" 260. Single Number III Medium Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. Example: Input: [1,2,1,3,2,5] Output: [3,5] Note: The order of the result is not important. So in the above...
135093a5d17b5e01e05b613e63ed425b17954229
rorochaudhary/sudoku
/sudoku_verifier.py
3,241
4.21875
4
# Name: Rohit Chaudhary # Course: CS 325 - Analysis of Algorithms # HW 8: Portfolio Project # Date: 12/7/20 # Description: For this project I chose to implement a 9x9 Sudoku solution verifier. The verifier takes as input a user-submitted solution.txt and determines whether solution.txt is a valid solution certifiate ac...
ffda8b9cf42dfc4167698f5de1e4bc69c3db92fd
kariesta/Euler
/p30.py
577
3.859375
4
''' Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 14 + 64 + 34 + 44 8208 = 84 + 24 + 04 + 84 9474 = 94 + 44 + 74 + 44 As 1 = 14 is not a sum it is not included. The sum of these numbers is 1634 + 8208 + 9474 = 19316. Find the sum of all the numbers ...