blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
8d3812dcbdb71742b5bb8876f277d3fd3609e6f7 | christiancas999/CESAR_questions | /question_7.py | 2,777 | 3.9375 | 4 | # If two requests on the queue have linked lists that intersect (like the example below),
# previous service could be improved to process only the difference between them.
# Write a method that receives two singly linked lists and return the intersecting node
# of the two lists (if exists). Note that the intersectio... |
77ad1958758f8a399d137006b7eab0b92f900673 | davidcolton/bitesofpy | /304/max_letter.py | 1,258 | 4.15625 | 4 | from typing import Tuple
from collections import Counter
import re
def max_letter_word(text) -> Tuple[str, str, int]:
"""
Find the word in text with the most repeated letters. If more than one word
has the highest number of repeated letters choose the first one. Return a
tuple of the word, th... |
f571d255e6413443d9f1f649bd4841ebeeb87d09 | Belmar04/EspPhis | /EspPhsih.py | 555 | 3.78125 | 4 | #!/usr/bin/python3.9
linkP = input("Introduce URL del Phising aquí (sin http o https), ej(64738n34b4.ngrok.io): ")
str(linkP)
linkW = input("Introduce el dominio para ocultar el Phishing URL (con http o https), (ej: https://google.com): ")
str(linkW)
print("Escribe palabras para engañar a la víctima, (ej: ga... |
dbc5a1bcc44f35029a1921b037ec2db6ea4a571f | ochsnerd/numpde | /series1_handout/linear-transp-2d/sol_movie.py | 1,321 | 3.75 | 4 | # See http://matplotlib.org/1.4.3/examples/animation/moviewriter.html
# and https://stackoverflow.com/questions/16915966/using-matplotlib-animate-to-animate-a-contour-plot-in-python
from numpy import *
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import sys
import matplotlib.animation as man... |
c9c527fd66f10b6416490c1422b54719f40e3792 | kanishkd4/Python_Learning_code | /Datacamp - Intro to python/Basics.py | 1,660 | 4.40625 | 4 | print(5 / 8)
print(7 + 10)
# print works differently from python 2 as it is a function in python 3
# ** gives exponential; % gives remainder
# Addition and subtraction
print(5 + 5)
print(5 - 5)
# Multiplication and division
print(3 * 5)
print(10 / 2)
# Exponentiation
print(4 ** 2)
# Modulo
print(18 % 7)
# How mu... |
8bf1ea37694933ef56721b83ae86a3536a758712 | HamburgerPlsdotexe/PyEx | /Exercises/10.1.py | 433 | 4.0625 | 4 | list1 = []
list2 = list()
print("List 1: {}".format(list1))
print("List 2: {}".format(list2))
if list1 == list2:
print("The lists are the same")
even = [2, 4, 6, 8]
another_even = even
print(another_even is even)
another_even.sort(reverse=True)
print(even)
odd = [1, 3, 5, 9]
oddAndEven = [even, odd]
fo... |
b6653ff6ac1c6dd5522fbbcc553db6d28ec0c00f | darsovit/AdventOfCode2017 | /Day24/Day24.py | 2,219 | 3.765625 | 4 | #!python
def read_input():
input=[]
with open('input.txt') as file:
for line in file:
input.append(line.strip())
return input
def read_sample():
input=[]
input.append('0/2')
input.append('2/2')
input.append('2/3')
input.append('3/4')
input.append('3/5')
inpu... |
7de4e0db9696917074e2cac47616c5de30351365 | jlevy44/LearningScripts | /Quiz:Program1/quiz.py | 365 | 3.78125 | 4 | def is_true(i):
if i==2:
return True
else:
return False
print(is_true(2))
def lalala(i):
return lambda y: i**2
print(lalala(5))
print('alpha' > 'beta')
d='hello'
for p in d: print(p)
print(d[-2:2])
def add(x,y):
print x+y
add(2,6)
def make_scalar(c):
return lambda n: c*(n)
... |
1d71936b63362d6971638af7400f8cf66979d707 | thetronjohnson/SS-Lab | /bankers/bankers.py | 1,921 | 3.625 | 4 |
def needmatrix(need,maximum,allocated):
for i in range(len(processes)):
for j in range(R):
need[i][j] = maximum[i][j] - allocated[i][j]
def safestate(processes,available,maximum,allocated):
need = [[0 for j in range(R)] for i in range(len(processes))]
needmatrix(need,maximum,allocated)
finish = [0 for i in ... |
0011bed278bcf2f887fc2f9b29eca6d340d494ad | redlifejacket/iot | /web_server.py | 1,780 | 3.734375 | 4 | #!/usr/bin/python3
# Shyam Govardhan
# 25 December 2018
# Coursera: Interfacing with the Raspberry Pi
# Week 2 Assignment
import socket
import sys
import os
SERVER_HOST = "192.168.0.29" # RaspberryPi's IP address; for accessing over the network
SERVER_PORT = 80 # Web server port
REQUEST_BACKLOG = 5
HTTP_A... |
b523f0b6eec21b0daff88ff057ca96ccd825dd5e | Aldirhezaldi/Teknologi_data | /PencatatApp/keuangan.py | 1,070 | 3.5625 | 4 | # from kegiatan import Kegiatan
#
#
# class Keuangan(Kegiatan):
# def __init__(self):
# super().__init__()
# self.jenis = 'kredit'
# self.nominal = 0
#
# def tampilkan_form(self):
# super().tampilkan_form()
# str_jenis = input('Masukkan Jenis: ')
# str_nominal = i... |
5d4a85e3d91d1bd1e23620bb86ba725e96bf0521 | M0nica/advent_of_code | /advent_of_code/2016/day21/aoc_day_21.py | 4,522 | 3.5625 | 4 | #!/bin/python3
import re
SCRAMBLE = 'abcdefgh'
SCRAMBLE2 = 'fbgdceah'
# SCRAMBLE2 = 'gbhafcde'
# SCRAMBLE = 'abcde'
# SCRAMBLE2 = 'decab'
S_LEN = len(SCRAMBLE)
# S_LEN = 8
def swappos(s, x, y):
x, y = map(int, (x, y))
s[x], s[y] = s[y], s[x]
return s
def swapltr(s, a, b):
for i in range(S_LEN):
... |
7659a0c1079d39996278a1115381e2c7f154aeb1 | Parkhyunseo/PS | /baekjoon/algo_10809.py | 216 | 3.703125 | 4 | text = list(raw_input())
alpha = [ -1 for _ in range(26) ]
for i in range(len(text)):
if alpha[ord(text[i]) - ord('a')] == -1:
alpha[ord(text[i]) - ord('a')] = i
print(' '.join( str(x) for x in alpha))
|
1ad294f6a4ae3a42d48bfd032af11747cec50910 | yyyuaaaan/python7th | /crk/2.6.py | 598 | 4.09375 | 4 | """
__author__ = 'anyu'
Given a circular linked list, implement an algorithm which returns node at the beginning of the loop.
EXAMPLE
Input: A -> B -> C -> D -> E -> C [thesameCasearlier] Output: C
map addr to hash table
python do not support address or linkedlist use hash()
"""
class Node(object):
def __init__(se... |
27409eee0121a45906958193dfab44bbd02f8c16 | abhi651/PYTHONLAB-II-B28-template---4 | /linear_search.py | 855 | 3.78125 | 4 |
""" write a program for Linear Search"""
# It returns index of x in given array arr if present,
# else returns -1
import unittest
# Implement the below function and run this file
# Return the output, No need read input or print the ouput
def linear_search(lst,key):
pass
class TestLinearSearch(unittest.T... |
abcf5683aae1bd5a41bb936f42f598517807bdf3 | anjalee15/Top-100-codes-in-Python- | /Leap_year_6.py | 233 | 4.28125 | 4 | # Leap Year
a=int(input("Enter a year : "))
if a%4==0:
if a%100==0 :
if a%400==0:
print(f"{a} is a leap year")
else:
print(f"{a} is a leap year")
else:
print(f"{a} is not a leap year") |
c1673a08886f9b91abdf18426cb463174dae8864 | sfdye/leetcode | /binary-tree-right-side-view.py | 491 | 3.609375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def rightSideView(self, root: TreeNode) -> List[int]:
if not root:
return []
ans = []
level = [root]... |
ec1832a7a1399065083cfbd4b96d58b49b73e4fd | iamprayush/ud120-complete | /__outliers/outlier_cleaner.py | 1,010 | 3.734375 | 4 | #!/usr/bin/python
def outlierCleaner(predictions, ages, net_worths):
"""
Clean away the 10% of points that have the largest
residual errors (difference between the prediction
and the actual net worth).
Return a list of tuples named cleaned_data where
each tuple is of the form (age, net_worth... |
2fe87ab574b9884edbeadf317b318fc84ae17c39 | S010-0N3/-PROJET-EXPLORER-LES-NAISSANCES-AUX-US-DEPUIS-2000 | /main.py | 1,280 | 3.59375 | 4 | birth_doc = open("US_births_2000-2014.csv","r",encoding= "utf-8")
f = birth_doc.read()
birth_split = f.split("\n")
def read_csv(file):
f = open(file,"r")
string_list = f.read()
string_list = string_list.split("\n")
string_list = string_list[1:]
final_list = []
for rows in string_list :
int_fields... |
56a577bf9b5ebeb9216782c39966c90c59307334 | gourav47/Let-us-learn-python | /Assignment 8 q5.py | 135 | 4.25 | 4 | '''count elements in the tuple'''
t=eval(input("Enter the values of tuple: "))
print("Number of elements in the tuple is: ",len(t))
|
4be8f4b3afe769909e45b781dd88eeb39533065c | Esul/projects | /dungeonTXT/main.py | 1,448 | 3.78125 | 4 | from functions import *
from dungeon import dungeon_main, secret_sentence, clear
clear()
print("""\t\t\tHello and welcome!\n
You are now in the HUB!\n
Your objective is to get all 3 words from this dungeon
and make a sentence. Return to the HUB and check if the
sentence is right
type help, for help :D
""... |
0bf767bbbdb6cd661558d9d6345ff2fa289b8b15 | heye/ebay-kleinanzeigen-notifyer | /utils/print_list.py | 130 | 3.65625 | 4 | from typing import Dict, Tuple, List
def print_list(item_list: List[any]):
for one_item in item_list:
print(one_item) |
c28aee36c8db920d53c00f23aa1cd083a628e276 | jay6413682/Leetcode | /FindMinSteps_DP_1.py | 1,339 | 3.75 | 4 | '''
Created on Jul 20, 2015
@author: ljiang
https://www.codechef.com/wiki/tutorial-dynamic-programming
q1:
Problem Statement: On a positive integer, you can perform any one of the following 3 steps. 1.) Subtract 1 from it. ( n = n - 1 ) , 2.) If its divisible by 2, divide by 2. ( if n % 2 == 0 , then n = n / 2 ) ,... |
8913010c544189c7f9ca1d57b6ca36f38ad8883f | Leputa/Leetcode | /python/367.Valid Perfect Square.py | 550 | 3.703125 | 4 | class Solution(object):
def isPerfectSquare(self, num):
"""
:type num: int
:rtype: bool
"""
if num<=0:
return False;
low=0
high=num
ans=(high+low)//2
while(low<high):
while ans**2!=num and low<high:
#print(str(low)+"... |
36d19ec959ce756a698fad98759e90bf41874af8 | matiek8/Python | /IsAscending.py | 878 | 3.921875 | 4 | """
Дан список. Определите, является ли он монотонно возрастающим(то есть верно ли, что каждый элемент этого списка больше предыдущего).Выведите YES, если массив монотонно возрастает и NO в противном случае.Решение оформите в виде функции IsAscending(A).В данной функции должен быть один цикл while, не содержащий вложен... |
9df0b1e751848fc1b2bce8dd1ac237b284fa34df | grance1/hello-world | /fu.py | 254 | 3.59375 | 4 | #!/usr/bin/python2.7
>>> str(123)
'123'
>>> str(1.23)
'1.23'
print int('123')
print int(12.34)
print str(123)
print str(1.23)
print str('1.23')
from math import fsum
L = []
# print L
L=list(map(lambda x: x*x,range(1,101)))
print sum(L)
L = range(1,101)
|
bf5d28adfd37184c699220f1a46affc2c28a6d83 | GuilhermeLaraRusso/aula_python | /aula5_5.py | 563 | 3.96875 | 4 | # tupla é imutável, enquanto a lista é mutável.
# tupla é definido por ()
lista = [1, 10, 7, 5]
lista_animal = ['cachorro', 'gato', 'elefante', 'lobo', 'arara']
lista_animal[0] = 'macaco'
print(lista_animal)
tupla = (1, 10, 12, 14)
print(tupla)
# tupla[0] = 12 não funciona pois a tupla não pode ser alter... |
4053a48af57246b1aca1d4bf8a3d433061408917 | bmihovski/PythonFundamentials | /serialize_string.py | 980 | 3.984375 | 4 | from collections import defaultdict
"""
You have been tasked to serialize a string. The serialization is done in a special way,
in which a character from that string is saved with the indexes at which it is found.
The input will consist of a single input line, containing a single string, which may consist of ANY ASCII... |
c50b2a9d359c47970ad9e0f37f3f3a597b823727 | Apra001/games | /main.py | 2,199 | 3.5625 | 4 | import pygame
import pygame.locals
import tile_set
import tile_map
import os
TILE_WIDTH = 32 # Width of each tile in pixels
TILE_HEIGHT = 32 # Height of each tile in pixels
TEXT_HEIGHT = 64 # Height of the text area at the bottom in pixels
if __name__ == '__main__':
# Load level 1 (the only level so far)
... |
3b4abcf62461a102af31da977be6385f62649ce0 | Bucky5683/SSF | /Database.py | 3,674 | 3.65625 | 4 | import sqlite3
import pandas as pd
from pandas import Series, DataFrame
conn = sqlite3.connect("database.db")
cursor = conn.cursor()
def checkdatabase():
# all_data 테이블이없으면 all_data 테이블 생성
cursor.execute("PRAGMA foreing_keys = 1;")
sql = 'CREATE TABLE IF NOT EXISTS all_data(all_idx INTEGER NOT... |
482fc7eb7a80658293d9bd4421a910b189996595 | apetrosian/algo | /01_algorithms/01_introduction/fibonacci_sum_last_digit/fibonacci_sum_last_digit.py | 383 | 3.984375 | 4 | # Uses python3
def fibonacci_sum(n):
if (n <= 1):
return n
# pisano period for mod 10
PISANO_PERIOD = 60
result = 0
previous = 0
current = 1
n = n % PISANO_PERIOD
for x in range(1, n+1):
result += current
previous, current = current, previous + current
... |
fa48e456d12b43782cfe958e1acd47b9f4385734 | diegofregolente/Curso-em-Video-Python | /Mundo 3/89-BoletimEscolar.py | 817 | 3.765625 | 4 | aluno = []
escola = []
media = 0
a = 0
while True:
aluno.append(str(input('Nome do aluno: ')))
aluno.append(float(input('Nota 1: ')))
aluno.append(float(input('Nota 2: ')))
media = (aluno[1] + aluno[2]) / 2
aluno.append(media)
escola.append(aluno[:])
aluno.clear()
r = str(input('Quer con... |
6e50a390a629b6d603d7ee2e73a5ccbe8c35c836 | ytgeng99/algorithms | /Pythonfundamentals/MultiplesSumAverage.py | 512 | 4.53125 | 5 | # Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do this exercise.
for i in range(1, 1001, 2):
print i
# Create another program that prints all the multiples of 5 from 5 to 1,000,000.'''
for i in range(5, 1000001, 5):
print i
# Create a program that print... |
1e38ec380df1fbc96ea039fa001bbf8dc69b18c8 | quartie-gif/Python_Language | /Labs/lab_05.py | 2,225 | 3.578125 | 4 | # Zad 1
# Proszę napisać funkcję przyjmującą jako parametr string (przy wywołaniu będziemy przekazać argument wiersza poleceń). Zakładamy, że string ten zawiera poprawną definicję wyrażenia/funkcji matematycznej z jedną zmienną x, czyli np. 'a*x+b', 'a*x**2+b*x+c'. W miejscu wszystkich stałych proszę wstawić losowe li... |
870ca2809b5f5259a9acf7c4c3e383314ad551d7 | zhushun0008/IntroductionToCSandProgrammingUsingPython_MIT | /exercises/lec05/exercise05.py | 6,783 | 4.5 | 4 | # -*- coding: utf-8 -*-
def iterPower(base, exp):
'''
returns: int or float, base^exp
Write an iterative function iterPower(base, exp) that calculates the
exponential base^exp by simply using successive multiplication.
For example, iterPower(base, exp) should compute base^exp by multiplying base
... |
1dd8c30bbfd350346f0267687b98337542417f0b | zengcong1314/python1205 | /web/lesson10_basepage/tests/test_add_class.py | 2,626 | 3.515625 | 4 | """python自动化"""
import time
import random
from selenium.webdriver.common.by import By
from web.lesson10_basepage.pages.home import HomePage
from web.lesson10_basepage.pages.login import LoginPage
def gen_class_name():
"""随机生成课程名称,字母,生成10位长度的字母。
aacdeyualp"""
name = ''
for i in range(10):
lett... |
a9fd06b332f81a17eea4ff1bd0f195957da3ed31 | swethai/Python_practice_files | /lists/lists_functions.py | 400 | 3.765625 | 4 | #!/usr/bin/python
aList = ['swetha', 123]
bList = ['swetha1', 123]
#camparing the lists
print "comparision of lists", cmp(aList, bList)
print "comparision of lists", cmp(bList, aList)
#no. of elements count in the lists
print "length of lists", len(aList)
print "length of lists", len(bList)
#max list
print "max e... |
1daf1501c46182b2256a5abf410919546b36cd88 | Santosh-J/Python-Lab | /Lab3/Source/Tictactoegame.py | 1,933 | 3.890625 | 4 | c = 0 # initialization
r = 0 # initialization
print("The size of the board is 3")
n = 3 # size of the board
aList = [' ', ' ', ' ']
bList = [' ', ' ', ' ']
cList = [' ', ' ', ' ']
w = ""
def get(): # define the function
c = int(input("Enter column:")) # enter the column number
c ... |
500837b9795519fb88732fd83ea4a92cfee8f144 | breynaUC/py-clase04 | /ejercicios03.py | 111 | 3.5625 | 4 | diccionario={"juan":"Lima","Ana":"Ica"}
for nombre, lugar in diccionario.items():
print (nombre, ":", lugar) |
b37b1e4557c2064f4358c986da1c853a02365fd1 | MichaelOdinProject/pub100daysofcode | /secret_auction.py | 978 | 4 | 4 |
def find_highest_bidder(bids):
highest_bid = 0
winner = ""
# This iterates through the KEYS
for bidder in bids:
# find the value by passing the key
bid_price = bids[bi dder]
if bid_price > highest_bid:
highest_bid = bid_price
winner = bidder
print(f"T... |
27a5227ad1084a4e9a297c24078f8335b5eb12ca | calvincruzader/PythonDeepDiveFredBaptiste | /classesFirstLook.py | 957 | 4.03125 | 4 | class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
@property
def width(self):
return self._width
@width.setter
def width(self, width):
if width < 0:
raise ValueError("Width must be positive.")
else:
self.width = width
@property
... |
4c8f56cc3afe627fc11535aac4bd05ffe289744f | wtrnash/LeetCode | /python/239滑动窗口最大值/239滑动窗口最大值.py | 1,093 | 3.90625 | 4 | """
给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口 k 内的数字。滑动窗口每次只向右移动一位。
返回滑动窗口最大值。
示例:
输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3
输出: [3,3,5,5,6,7]
解释:
滑动窗口的位置 最大值
--------------- -----
[1 3 -1] -3 5 3 6 7 3
1 [3 -1 -3] 5 3 6 7 3
1 3 [-1 -3 5] 3 6 ... |
334ea497013acc8a395232786d9bd0a93b65368b | metanitesh/Data-Structure-Algorithm-Python | /projects/DA-project-3/problem-1.py | 858 | 4.15625 | 4 | def findRoot(starting, end, number):
mid = (end+ starting) //2;
if mid*mid == number:
return mid;
if (mid*mid < number) and (mid+1)*(mid+1)>number:
return mid;
if(mid*mid > number):
return findRoot(0, mid, number)
else:
return findRoot(mid, end, number)
def sqrt(number):
if(number ... |
105fd59fb672b80d01142b0b117ed7ec3dc8048f | lanpartis/jianzhiOffer_practice | /41_sumS.py | 779 | 3.734375 | 4 | # -*- coding:utf-8 -*-
'''
输出所有和为S的连续正数序列。序列内按照从小至大的顺序,序列间按照开始数字从小到大的顺序
'''
class Solution:
def FindContinuousSequence(self, tsum):
# write code here
S = tsum
if S%2 ==0:
end = S/2
else:
end = int(S/2) +1
phead=1
ptail=1
result = []
... |
aa4829a15b12ec974a31f959ba0c27a3414717f9 | HenraL/NSI_1ereG6_Programme_Python | /files/ex 90/sqrt.py | 816 | 3.625 | 4 | from math import sqrt
from time import sleep
def stats(tableau):
n=len(tableau) #on mesure la taille du tableau
m=sum(tableau)/n # on calcule la moyenne
tableau2=[(x-m)**2 for x in tableau] #on crée le tableau des carrés des écarts à la moyenne
variance=sum(tableau2)/n #calcule de la variance
s=sqrt... |
22b04a7c0a00d4bec46c8d455847b520641fa865 | coultat/yieldlove | /picanha/dictionary.py | 531 | 3.65625 | 4 | import random
from random import randint
class darcarta():
def __init__(self):
self.cartas = {'corazones':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K'], 'diamantes':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K'], 'picas':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K'], 'treboles':[1, 2, 3, 4, 5, 6, 7,... |
7c32829e51cb2500d4ba313765ec285960f5c665 | AnoushAtayan/PythonPractice | /PythonBasic/32.py | 209 | 3.765625 | 4 | def lcm(x, y):
list = []
if x>y:
lcm = x
else:
lcm = y
while(True):
if lcm%x==0 and lcm%y==0:
return lcm
break
lcm+=1
print lcm(5, 125) |
35b09b182267559228cf4828042d033639c17da1 | ddediu/bezier-hard-palate | /bezier-model.py | 22,117 | 3.5625 | 4 | """
Supplementary material S7 for Modelling Human Hard Palate Variation with Bezier Curves
Rick Janssen, Scott R. Moisik, Dan Dediu
File name: BezierSupp.py
Author: Rick Janssen
E-mail: rick.janssen@mpi.nl
Date last modified: 12-01-2016
Python Version: 2.7.5
Licence: GPL
This code contains two classes: Bez... |
4a171e15bb6f2f3edf088401afa8a0a3464f4fa4 | MinCheng123/Python | /leetcode/28 Implement strStr().py | 1,225 | 3.515625 | 4 | class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
ans=0
flag=0
complete=0
if len(haystack)==0 and len(needle)==0:
return 0
if len(haystack)==0 or len(needle... |
446cee765617f701c2ef70194f6b927729b1645a | EduardoIxen/201800524_TareasLFP | /Tarea 1/Contador.py | 132 | 3.5625 | 4 | size = 10
for i in range(size):
line = 0
while line <= i:
print("*",end = '')
line = line + 1
print('')
|
ea06a1f10a4c05743adf052a8f1d39bb336ec56b | marklb7/SMU_Homework | /03-Python/Submission/PyBank/main.py | 1,959 | 3.96875 | 4 | #Imports csv dependencies
import csv
#csv file path
csvpath = r"Submission/PyBank/Resources/budget_data.csv"
#Set total initial months and profit count to zero
total_months = 0
total_profit = 0
first_row = True
last_profit = 0
monthly_change = {}
#Creates initial empty dictionary
candidate_dictionary = {}
with open... |
2e08f4fd97a4c03c91564f4bbfcdd6460e5349ea | mzohaib/TrustYouTest | /NER.py | 4,200 | 4.09375 | 4 | """
Programming task
================
The following is an implementation of a simple Named Entity Recognition (NER).
NER is concerned with identifying place names, people names or other special
identifiers in text.
Here we make a very simple definition of a named entity: A sequence of
at least two consecutive capital... |
64edc0f83509b65276f2ef27020e8687ce4e2ceb | JamesPC44/USC_LowerDivision_Spring2019 | /bitblaster/gen/gen.py | 1,002 | 3.59375 | 4 | #!/usr/bin/python3
# Generates Testcases for the NimSolver, where the game value is not 0
import sys
import random as r
def nimsum(arr):
ret = arr[0]
for i in range(1, len(arr)):
ret ^= arr[i]
return ret
def main():
if len(sys.argv) != 5:
print("Usage: ./gen.py min_indicies max_indicies min_number m... |
3a3a50eed2ab5e6c8a183e51ceba98f6ea2ca80b | ay701/Coding_Challenges | /number/setMatrixZeros.py | 2,251 | 4.4375 | 4 | # Python3 Code For A Boolean Matrix Question
# A Boolean Matrix Question
# Given a boolean matrix mat[M][N] of size M X N, modify it such that if a matrix cell mat[i][j] is 1 (or true) then make all the cells of ith row and jth column as 1.
# Example 1
# The matrix
# 1 0
# 0 0
# should be changed to following
# 1 1
# ... |
089affaac72edb537237a30561547f747b2fecaf | jxseff/python-exercise | /chapter 4/my_pizzas_your_pizzas.py | 451 | 4.0625 | 4 | pizzaPie = ['hawaiian', 'overload', 'pepperoni']
for pizza in pizzaPie:
print(f"I like {pizza.title()}")
print('I really love pizza')
friend_pizzas = pizzaPie[:]
pizzaPie.append('cheesy')
friend_pizzas.append('macaroni')
print(f"My favorite pizzas are: {pizzaPie[0]}, \
{pizzaPie[1]}, {pizzaPie[2]} and {pizzaPie[3]... |
da7f67ce9118797da91653069f8b0995725841b9 | brianreinke95/Calculadora | /Calculadora.py | 800 | 3.53125 | 4 | """Calculadora 2.0 """
"""Conceptos Aprendidos en esta version 1.0.0:
-Mucho manejo de strings
+isdigit
-Try/Except, usado para salvar errores
-Manejo de Listas
-Loops: While y for
-Recursividad
-sys: para matar al programa cuando se encuentra algún error del ... |
e91d4552d025a9cfc5823d8572cb6bf7a0cdb64e | lalitdale/Python | /13_01_2019/assign1.py | 174 | 4.1875 | 4 |
#accept string from user and check if it starts with capital 'T'
str1 = str (input ("Enter String to check: "))
print ("Output is :" + str (str1.startswith('T')))
|
5e4494dc35c6387e11fb3c0cf640fd6c49dba866 | cgc186/work | /caiguicheng/week03/day12/课程代码及作业/py1.py | 1,347 | 4.1875 | 4 | # 类的说明<1.类的名称;2.使用:结合缩进来定义类的内容;3.self代表类的实例,而非类>
# class myUser:
# i = 343
#
# def myprint(self):
# return "hello zlz"
#
#
# my = myUser()
#
# print("打印类中的属性", my.i)
# print("对类当中的方法进行调用", my.myprint())
#
#
# class myAdd:
# def __init__(self, num1, num2):
# self.r = num1
# self.x = n... |
7823d45c55eedbfeda27499fb09e0a528313165b | raghuprasadks/sindhi-python-aug-2021 | /day4/1-listdemo.py | 615 | 4.0625 | 4 | """
List -
Dynamic array
It allows duplicate values
It maintains the order of insertion
Elements can be accessed using index
"""
runs =[10,40,50,60]
print('runs -list ',runs)
print('runs -list - data type ',type(runs))
#<class 'list'>
print("list length ",len(runs))
'''
Adding an element
'''
runs.append(35)
print("aft... |
9892d3ded3294e080d3b5f802aa08d76cd128da5 | dianaharm/task_assigment | /source/logs/logs.py | 1,410 | 3.53125 | 4 | # Internal imports
from util import util
class Log:
"""
Class that will handled the log management with some basic functions as write and read
"""
# Object of util class that will handled format information
utility = util.Util()
# path will keep the value of the file for current log
path ... |
0c23f8729c614bd01a6cf0f85ad0fa616534f621 | pzmrzy/LeetCode | /python/design_phone_dictionary.py | 1,431 | 3.875 | 4 | class PhoneDirectory(object):
def __init__(self, maxNumbers):
"""
Initialize your data structure here
@param maxNumbers - The maximum numbers that can be stored in the phone directory.
:type maxNumbers: int
"""
self.avai = {}
for i in range(maxNumbers):
... |
0e92cdca6e086345f4b5244aeb1b07196bfda24f | Mobinul341/Journey-To-Pythonist | /conditionCheck.py | 442 | 4.09375 | 4 | #car = input("Enter a Car name: ")
'''
#if-else statement check
if car == "BMW":
print("I wish to Buy a Black BMW")
else:
print("Go buy a Nano")
'''
'''
#if-elif-else statement check
if car == "Toyota":
print("I can buy this car")
elif car == "Nano":
print("Thios is a cheap indi... |
0b14649f36d9ce3d62959c3991e7d00453a21069 | elenaborisova/Python-OOP | /13. SOLID - Lab/04_entertainment_systems.py | 2,143 | 3.515625 | 4 | from abc import ABC, abstractmethod
class Connector(ABC):
@abstractmethod
def connect(self, device):
pass
class PowerConnector(Connector):
def connect(self, device):
self.connect_device_to_power_outlet(device)
def connect_device_to_power_outlet(self, device): pass
class HDMIConnec... |
a4910f1ed20b9c54efc3e32098f0751d0ee70160 | ACMatNYU/acm-talks | /2014-15/python_101/setting_up.py | 1,991 | 3.75 | 4 | ############
# SETTING UP #
############
# import this
def print_download_links():
"""Open links to download pip, and then to download IPython"""
download_pip_link = 'http://pip.readthedocs.org/en/latest/installing.html'
print "pip ({0}) is the package manager for Python packages".format(download_pip_link)
... |
dc453ad61953a48eb3aa7621c30eb87736e27d8b | sridhar355/prmg | /listcomp.py | 418 | 4.125 | 4 | #list comprehension
#example1
# square of numbers
b=[i*i for i in range(1,11)]
print(b)
#ex2
#print words greater than given length
word=['apple','orange','mango','papaya','grapes']
res=[a for a in word if len(a)>5]
print(res)
#ex3
#using if-else condition
res=[a if a!='papaya' else 'berry' for a in word]
print(res)
... |
3cd6085ba53d58ca5a690a40c2c1ccbcb1865984 | NikethaDinesh/python_internship | /Day15-PongGame/startgame.py | 2,527 | 3.71875 | 4 | import turtle
screen=turtle.Screen()
screen.title("Pong game")
screen.bgcolor("white")
screen.setup(width=800 , height=600)
screen.tracer(0)
paddle_left=turtle.Turtle()
paddle_left.speed(0)
paddle_left.shape("square")
paddle_left.color("black")
paddle_left.penup()
paddle_left.goto(-350,0)
paddle_left.sh... |
0380843d76d8f19aaf5a6357328e9fc0221e561b | Segelzwerg/Advent-of-Code | /Year2019/tag4.py | 1,418 | 3.828125 | 4 | def has_double_digits(password):
password = str(password)
for i in range(len(password)-1):
if password[i] == password[i+1]:
if i+2 < len(password):
if password[i+1] == password[i+2]:
if i+3 < len(password):
shortend_password = pass... |
c9e857ee5c77a7ac8d66c67cbd252bbf70d48e98 | nurulrita/pythoncoba | /Meet 1/tugas_1.py | 421 | 3.515625 | 4 | nilai = input("Masukkan nilai anda:")
if nilai>=80 and nilai<=100:
print "Nilai Anda: A"
elif nilai<=79 and nilai>=60:
print "Nilai Anda: B"
elif nilai<=59 and nilai>=40:
print "Nilai Anda: C"
elif nilai<=39 and nilai>=20:
print "Nilai Anda: D"
elif nilai<=19 and nilai>=0:
print "Nilai Anda: E"
eli... |
dc1a28e1a4e3f966ef030fdde62c05d5bee2503a | ManaswitaDatta/Advanced-Algorithm-Lab-Assignment | /EditDistOptimalAlign.py | 2,022 | 3.546875 | 4 | def printChanges(s1, s2, dp):
i = len(s1)
j = len(s2)
list = []
# Check till the end
while (i > 0 and j > 0):
# If characters are same
if s1[i - 1] == s2[j - 1]:
list.append(s1[i - 1] + " " + s2[j - 1] + " " + str(0))
i -= 1
j -= 1
... |
254b20f47311f5d16d1fcebd7d61cf6a516eb09b | vaish28/Python-Programming | /JOC-Python/estimate_Ploting.py | 1,661 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 17 06:56:09 2018
@author: Supriya
feedback: asked to guess a number about a jar containing colored stones
actual number of stones is 50
"""
import matplotlib.pyplot as grph
from statistics import mean, median
from scipy import stats
feedback = [10,15,25,18,... |
3f843b1fa4d807c055bb78051a6968652ad84621 | caoxudong/code_practice | /leetcode/54_spiral_matrix.py | 2,267 | 4.1875 | 4 | #!/usr/bin/env python
#coding: utf-8
"""
https://leetcode.com/problems/spiral-matrix/
Given a matrix of m * n elements (m rows, n columns), return all elements of the matrix in spiral order.
For example,
Given the following matrix:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
You should return [... |
46fd6508edb30bc2e2d7818c8b73f9e087720d88 | mizanurrahman13/PythonAbc | /FreeCodeCamp.org/TakingInputFromUser.py | 475 | 4.09375 | 4 | name = input("Enter your name: ")
age = input("Enter your age: ")
print("Hello " + name + " ! Your are " + age + " Years old now.")
num1 = input("Enter a number: ")
num2 = input("Enter another number: ")
result = num1 + num2
print(result)
# We need int casting number num1 and num2
result = int(num1) + int(num2)
print(... |
90f62a291557150f14f9e1666fa59bac71c5858a | kihwan-lee/epi | /primitive_types.py | 1,628 | 4.21875 | 4 | import math
"""
Things to Review
Operators: Arithmetic, Comparison, Logical, Bitwise, and Assignment
Caching: Putting something into a temporary storage area that stores the used items for easy access
Math & Random libraries
"""
def reverse(x):
result, x_remaining = 0, abs(x)
while x_remaining: #while x_re... |
3db0cdc0ad22316776394e752924c49c8bfa8dcd | ih-suarez/afs-215 | /week1/FizzBuzz/Fizzbuzzunittest.py | 197 | 3.78125 | 4 | num = int(input(f'Enter a number.. 1 - 2: '))
def fizz_buzz(num):
if num == 1:
return f'Get: {num}'
if num == 2:
return f'Get: {num}'
return num
print(fizz_buzz(num))
|
b12dc7d01e8e8ed889ccf2f8bc271ff2cd56d700 | aljawetz/neural-network-from-scratch | /fc_layer.py | 1,550 | 3.609375 | 4 | from activations import *
class FCLayer:
def __init__(self, input_size, output_size, activation=none):
self.input_size = input_size
self.output_size = output_size
self.activation = activation
self.weights = np.random.randn(
input_size, output_size) / np.sqrt(... |
d8d94a9c127ad1053475ef09e15be89fd8c0a14f | seyi/programming_python_codes | /system/filetools/commands.py | 638 | 3.625 | 4 | #!/usr/bin/env python
from sys import argv
from scanfile import scanner
class UnknownCommand(Exception): pass
commands = {'*':'Mrs','+':'Mr'} # Data is easier to expand than code
""" def processLine(line):
if line[0] == '*':
print 'Hello Mrs ', line[1:-1]
elif line[0] == '+' :
print 'Hello Mr ... |
061a33fa98b62951fb2e8852de9ba5732fe63315 | tzabcd/py-study | /python-new-journey/py_2.py | 185 | 3.59375 | 4 | from random import randint
# 筛出字典中值高于90的项
d = {x: randint(60, 100) for x in range(1, 21)}
print(d)
result = {k: v for k, v in d.items() if v > 90 }
print(result) |
9f7a6ae318b9a771a498a4a27fbbd5722bc2bb27 | lacanlale/practice | /ctci/snq/stackofplates.py | 2,171 | 4.09375 | 4 | # Prompt Imagine a (literal) stack of plates. If the stack gets too high, it might topple.
# Therefore, in real life, we wopuld likely start a new stack when the previous stack exceeds some threshold.
# Implement a data structure SetOfStacks that mimics this. SetOfStacks should be composed of several
# stacks and shoul... |
c6ee782c25a981c26c9125928645a07314a03416 | simonvbrae/advent-of-code-2020 | /day3/day3.py | 365 | 3.828125 | 4 | def slope(c, r):
f=open("input", "r")
lines=f.readlines()
trees_encountered, row, col = 0, 0, 0
while row < len(lines):
trees_encountered+=int(lines[row][col%(len(lines[0])-1)] == "#")
row+=r
col+=c
return trees_encountered
print(slope(3,1))
m=1
for i in [(1,1),(3,1),(... |
5491efb3841bc753f8de6fff6b0f5233c132a805 | saubhagyav/100_Days_Code_Challenge | /DAYS/Day22/Remove_Duplicates_in_Dictionary.py | 364 | 4.21875 | 4 | def Remove_Duplicates(Test_string):
Test_list = []
for elements in Test_string.split(" "):
if ((Test_string.count(elements) > 1 or Test_string.count(elements) == 1) and elements not in Test_list):
Test_list.append(elements)
return Test_list
Test_string = input("Enter a String: ... |
68e983463090000c40d6af19574724ce303d3ef8 | artimishra/Enron_dataset | /explore_enron_data.py | 4,180 | 3.671875 | 4 | #!/usr/bin/python
"""
Starter code for exploring the Enron dataset (emails + finances);
loads up the dataset (pickled dict of dicts).
The dataset has the form:
enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict }
{features_dict} is a dictionary of features associated with that pers... |
ad5353882df1ca29472b9e708587364636d5a659 | HassanSherwani/Data_Science_Projects | /Web_scraping/scrapping_newegg.py | 2,383 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Web Scrapping project from newegg website
"""
# Importing key libraries
import requests
import bs4
from urllib.request import urlopen as ureq
from bs4 import BeautifulSoup as soup
# Reading the web page into Python
my_url= 'https://www.newegg.com/Video-Cards-Video-Devices/... |
fcf4b7b855db9aacfda855a613d97568c753af4d | emersonsemidio/python | /Desafio48.py | 249 | 3.8125 | 4 | cont = 0
soma = 0
for c in range(1,501,2):
if c % 3 == 0:
print(c,end=' ')
cont = cont +1
soma = soma +c
print('\nA soma de todos {} os números múltiplos de 3 nesse intervalo é {}'.format(cont,soma))
print('\nFIM')
|
9dd60a480559e5e689f9bd34b5dc2fde9eb63ac9 | mahabharathi/myproject | /python-projects/range.py | 264 | 4.53125 | 5 | print(range(100))
for x in range(2):
print(x)
print(" ")
for _ in range(5):
print(_)
print(" ")
for _ in range(5,0,-1): #reverse or step back
print(_)
#range - used in loops
#used in list
print(" ")
print(list(range(10))) |
902224e47d6caf47c68547cc61ad6afbed960d2d | RubenMaier/practicas-varias-python | /lampara.py | 1,666 | 3.71875 | 4 | # -*- coding: utf-8 -*-
class LamparaDeEscritorio:
# variable de clase
# en python todo en mayúsculas significa que la variable es una constante
_LAMPARAS = ['''
.
. | ,
\ ' /
` ,-. '
--- ( ) ---
\ /
_|=|_
|_____|
''',
... |
3bd2d14d37c207a5ab90346dfe49b99c362acc6c | shailajayadav/Data-Structure-and-Algo-in-Python | /Areaoftriangle.py | 126 | 3.515625 | 4 | #area of triangle
def areatriangle(l,h):
area=0.5*l*h
print('area',area)
areatriangle(3,5)
areatriangle(2,20)
|
0653d41c021f7b89f0de2e70e56313238dbb4572 | freshkimdh/Python_Basic | /Python_Grammer/Python_level_1/function.py | 531 | 3.84375 | 4 | # 함수 만들기
def print_root(a, b, c):
r1 = a * b * c
r2 = a + b + c
print('곱셉은 {}, 덧셈은 {}'.format(r1,r2))
x = 5
y = 1
z = 3
print_root(x,y,z)
# 함수 리턴
def print_add(value) :
result = value + 5
return result
n = print_add(5)
print('리턴함수{} '.format(n))
# 초기값 True, False
def say(name, age, man=True):
... |
45bbb57f555076a2cfcef65120c2c860ae47f83e | pokhym/guidb | /sqlite3DB.py | 13,849 | 3.703125 | 4 | import sqlite3
import os
DEFAULT_NAME_COLUMN_TYPE = [("staffnumber", "INTEGER PRIMARY KEY", "integer"),\
("fname", "VARCHAR(20)", "text"),\
("lname", "VARCHAR(30)", "text"),\
("gender", "CHAR(1)", "text"),\
("joining", "DATE", "text")
]
class sqlite3DB:
# TODO: The input of columnListType ... |
6952731b19b7c921e7aa52d297111b0c798b156d | anarayanan123/DS-ALGO-COURSEWORK | /Algorithmic Toolbox/W2/fibonacci_last_digit.py | 406 | 3.765625 | 4 | # Uses python3
#import sys
def get_fibonacci_last_digit_naive(n):
ar = []
ar.append(1)
ar.append(1)
# print(ar[0])
# print(ar[1])
for i in range (2,n+1):
x = (ar[i-1] +ar[i-2]) % 10
ar.append(x)
# print(i)
# print(ar[i])
if (n <= 1):
return n
else:
return ar[n-1]
#if __name__ == '__main__':
... |
9ad34d9ab6113207454790d6370f23427fd28112 | rcaracheo/codemotion_scraping_the_web | /BeautifulSoup/google_translate.py | 1,098 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
import sys
#Example input to enter : en (= english)
convert_from = raw_input("Language to Convert from : ")
#Example input to enter : hi (= hindi), fr (= french), de (= German)
convert_to = raw_input("Language to Convert to :... |
39b55fc53086a6081671ecee3f69b7b483396706 | gixlg/Advent-of-Code-2019 | /Day1/Day1.1.py | 296 | 3.765625 | 4 | import math
f = open("inputDay1.txt", "r")
masses = list(f)
total_required_fuel = 0
for mass in masses:
required_fuel = math.floor(int(mass) / 3) - 2
print("required fuel:", required_fuel)
total_required_fuel += required_fuel
print("total required fuel: " + str(total_required_fuel)) |
2536a8dfae5f12f62aaf0df45f9913958b843fcb | Charlie-Toro/Python-Projects | /pizzas.py | 552 | 4.59375 | 5 | #Pizzas
#Caleb Bell
#Stores name of favorite pizzas and demonstrates lists and loops
pizzas = ['cheese','hawaiian','pepperoni']
for pizza in pizzas:
print(pizza.title() + " is a pizza that I like!")
print("Pizza is my favorite dish!")
#4-11 appending to pizza program
pizzas.append("mushroom")
friend_pizzas... |
29df65a8a4cb2f9ae07ac512014074d5d901537f | zhrmrz/is_valid_perfect_square | /is_valid_perfect_square.py | 431 | 3.625 | 4 | from math import *
class Sol:
def is_valid_perfect_square(self,num):
left=0
right=num
for i in range(int(log2(num)+2)):
n=int((right+left)/2)
if n*n==num:
return True
elif n*n>num:
right=n
else:
l... |
aff4c010dc079579f62085c154f6153bad5d6401 | jaewook5267/LikeLionBank | /BankAccount/bank.py | 2,353 | 3.984375 | 4 | class Account:
def __init__(self,user_id,user_name,user_balance):
self.__user_id = user_id
self.__user_name = user_name
self.__user_balance = user_balance
def get_UserId(self):
return self.__user_id
def get_UserName(self):
... |
33a02d12dba64e03e603ed3098deaf3ce14830c6 | AyubQuadri/Python---Sessions | /Assignment/Dilipkumar katturipalli/Day 2/BitwiseOperations.py | 133 | 3.890625 | 4 | #input and output program
print ("Enter value of a")
a=input()
print ("Enter value of a")
b=input()
c=a+b
print("value of c is",c)
|
f49222777153bfded6943921d49fe1466f76bb75 | Git-Math/linear_regression | /precision.py | 435 | 3.65625 | 4 | import sys
def calc_mean_price(data):
mean = 0
for km, price in data:
mean += price
mean /= len(data)
return mean
def r_squared(data, theta0, theta1):
sum0 = 0
sum1 = 0
mean_price = calc_mean_price(data)
for km, price in data:
predicted_price = theta0 + (theta1 * km)
... |
435e4840fc369e1829496d56809c423226362120 | mattjp/leetcode | /practice/medium/0662-Maximum_Width_of_Binary_Tree.py | 1,152 | 3.5625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def widthOfBinaryTree(self, root: TreeNode) -> int:
deque = collections.deque([root])
max_width = 1 if root else 0... |
414953528e89aa5a240588f3afab3708b7fc57a6 | adityajaroli/python-training | /basic/FileHandling.py | 1,121 | 3.6875 | 4 | import json
def add_attendees(attendees):
try:
with open("attendees.txt", "w") as att_file:
json.dump(attendees, att_file)
except Exception:
print("error while writing to file")
def get_attendees():
try:
with open("attendees.txt", "r") as att_file:
if( l... |
672aac2712ebb7d78ce7a20b6989f145c38eac92 | savadev/LeetCodeProblemSet | /recoverbinarysearchtree.py | 1,148 | 4.15625 | 4 | #!/usr/bin/env python3
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def recoverTree(self, root):
"""
:type root: TreeNode
:rtype: None Do not return a... |
81753086f6bbb91fae69c0331f1ed2b87a5e099a | wreyesus/Learning-to-Code | /python/python_crash_course/chapter_10/10-9.silent_cats_and_dogs.py | 382 | 3.890625 | 4 | """ Modify your except block in Exercise 10-8 to fail
silently if either file is missing """
def read_files(filename):
try:
with open(filename) as f:
content = f.read()
print(content)
except FileNotFoundError:
pass
filenames = ['cat.txt', 'dogs.txt'] #the correct name i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.