blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
780f99fe6420856ea2b4ba6bfdc42c9d6956f318 | vitorm12/Text-analysis | /pa3_vitor_mouzinho/TextAnalysis/main.py | 9,797 | 3.734375 | 4 | """main.py
Example Text Analysis code after assignment 2.
"""
import os
import math
import nltk
from nltk.corpus import brown
from nltk.corpus import wordnet as wn
from nltk.corpus import PlaintextCorpusReader
from nltk.probability import FreqDist
from nltk.text import Text
# NLTK stoplist with 3136 words (multil... |
c1a1de0eac3472301fb62f5129920f8707c162db | sevenzero/daily-study | /LeetCode/14.py | 3,182 | 3.625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2020/1/17 11:25
@Author : duanpy001
@File : 14.py
@Link : https://leetcode-cn.com/problems/longest-common-prefix/
"""
from typing import List
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
s = ""
... |
d1ce399e8bac7d6056dbbffd590fabdc1d7fa4b1 | ssongman/windmill | /python/ex311_queue.py | 1,273 | 3.65625 | 4 | ###################################################
#
# file name : ex311_queue.py
# executeoin : python3 ex311_queue.py
#
###################################################
import queue
#import PriorityQueue
def q_put():
while True:
item = q.get()
if item is None:
br... |
bef5ce9050391f518382fd2c2c0fb7de74f40ecb | guojch/Python-learning-record | /study/dict.py | 209 | 4 | 4 | # 字典(无序)
d = {'Michael': 95, 'Bob': 75, 'Tracy': 85}
d['Michael']
d['Michael'] = 99
# 判断key存在
print('Thomas' in d)
d.get('Thomas')
d.get('Thomas', -1)
# 删除key
d.pop('Bob')
print(d)
|
d77c958edff114576fd825a12320b7842f240f6c | szymonWojdat/Stanford_Algorithms1 | /week2/quicksort.py | 1,107 | 3.921875 | 4 | data = []
comps = 0
with open('QuickSort.txt') as f:
for line in f:
data.append(int(line.strip()))
def choose_pivot(arr, n):
"""
:param arr: array from which the pivot will be chosen
:param n: length of arr
:return: INDEX of the pivot element
"""
a = arr[0]
b = arr[n-1]
c = arr[(n-1)//2]
m = [a, b, c]
m... |
fe03cc5bdd48c43b3182f94e1195a91dbdfdcee9 | radhadman/flask_app | /project/models.py | 1,372 | 3.921875 | 4 | import sqlite3 as sql
x = """
DROP TABLE IF EXISTS posts;
"""
q = """
CREATE TABLE IF NOT EXISTS posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
comment TEXT NOT NULL
);
"""
y = """
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NUL... |
12a47ecdc7dc26a36913213388ef2cf8a5d9d04d | Yucheng7713/CodingPracticeByYuch | /DataStructure/Graph.py | 1,967 | 3.546875 | 4 | from collections import defaultdict
class Graph:
# Graph Construction
def __init__(self, vertices):
self.graph = defaultdict(list)
self.numOfVertices = vertices
def addEdge(self, u, v):
self.graph[u] += [v]
# DFS Traversal
def depthFirstSearchUtil(self, v, visited, path):... |
67a90b0e93388a3babd05b6923715f764efdce75 | isp5708/Algorithm_python_bj_2cotae | /재귀 함수 이진 탐색/main.py | 542 | 3.8125 | 4 | def binary_search(array,target,start,end):
if start>end:
return None
mid=(start+end)//2
#찾을시
if array[mid]==target:
return mid
#더 작은경우
elif array[mid]>target:
return binary_search(array,target,start,mid-1)
#더큰경우
else:
return binary_search(array,target,mid... |
ebc8eb6a2bd8420fb4b36e9deb8c05a15c636719 | arjun921/Python-TIL | /misc/hackerrank/general/Loops.py | 74 | 3.5625 | 4 | N = int(input())
if 1<=N and N <=20:
for x in range(0,N):
print (x**2)
|
e6cfa4ec648b8fa55cd10cbf578b504ed73df36d | simultechnology/my-python-samples1 | /recipe1/1-9,10,11.py | 211 | 3.578125 | 4 | import numpy as np
Matrix = np.arange(1, 13).reshape(4, 3)
print(Matrix)
print(Matrix.reshape(2, -1))
print(Matrix.T)
a = np.array([np.arange(1,7)])
print(a)
print(a.T)
print(Matrix)
print(Matrix.flatten()) |
709107ef7f1a6a93f8191dcfea6c64697031c9ff | pvanh80/intro-to-programming | /round08/OS_library.py | 1,202 | 3.75 | 4 | # Intro to programming
# Os library
# Phan viet Anh
# 256296
import os
def file_filter(file_list, extension):
# Return a list only contains mp3 file extension
file_list_extension = []
for file in file_list:
dot_position = file.find('.')
if str(file[dot_position:]) == extension :
... |
72f400d999779a9223cbecd271379d68c40b822b | sharuhasan/ee2703-2019-spring | /Answers/assign4.py | 10,468 | 3.78125 | 4 | # Assignment 4 for EE2703
# Done by Om Shri Prasath, EE17B113
# Date : 23/2/2019
# Importing libraries
from pylab import *
from scipy.integrate import quad
# # Question 1
# * Define Python functions for the two functions $e^{x}$ and $\cos(\cos(x))$ which return a vector (or scalar) value.
# * Plot the functions over ... |
2c660db99a44028882d48d6209dc57f38a5f7298 | hushion-r/COMP346 | /getDepartureTime.py | 4,854 | 3.65625 | 4 | import requests
import json
# author: Rae Hushion
# MetroTransit Activity
# Due Fri 7 Sept 2018
class GetInfo:
def __init__(self):
self.all_metro_info = CallMetroAPI()
# establish values
self.route = 000
self.direction_value = 0
self.direction_text = "0"
self.stop... |
d3323e1576df23c9b50d23c482b5f0b9c618b95c | KaueGuimaraes/Python-Begin-Exercises | /ex007.py | 629 | 4 | 4 | print('========= DESAFIO 007 =========\n')
n1 = int(input('Primeira nota:'))
n2 = int(input('Segunda nota: '))
m = n1 + n2
print('\nA média entre essas duas notas é: {}'.format(m / 2))
print('FIM!!')
'''
English Version
print('========= CHALLENGE 007 =========\n')
n1 = int(input('First score: '))
n2 = int(input... |
f47060d399a2d393fa253f07d76074beae18e3b0 | XMK233/Leetcode-Journey | /py/125.py | 1,112 | 4.03125 | 4 | '''
125. Valid Palindrome
Easy
513
1435
Favorite
Share
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Note: For the purpose of this problem, we define empty string as valid palindrome.
Example 1:
Input: "A man, a plan, a canal: Panama"
Output: true
E... |
8ffbf622a52dc63024873901ea255c58abb813a5 | bergamojoao/URI-EXERCICIOS | /1144.py | 394 | 3.71875 | 4 | a=0
N=int(input())
for i in range(1,N+1):
for k in range(1,4):
if(k==3):
print(i**k,end='')
else: print(i**k,end=' ')
print()
for j in range(1,4):
if j==2 or j==3:
a=i**j+1
if(j==3):
print(a, end='')
else: print(a, end=... |
dd02ac94518503c583babd83db0d30cd6c41c731 | kentxun/PythonBase | /ForOffer/57_2_FindContinuousSequence.py | 2,924 | 3.78125 | 4 | '''
输出所有和为 S 的连续正数序列。
例如和为 100 的连续序列有:
[9, 10, 11, 12, 13, 14, 15, 16]
[18, 19, 20, 21, 22]。
双指针思路
//左神的思路,双指针问题
//当总和小于sum,大指针继续+
//否则小指针+
'''
class Solution1:
def FindContinuousSequence(self, tsum):
phigh ,plow =2,1
allres= []
while phigh > plow:
cur = (phigh+plow)*(phigh-p... |
cc741c2c4ea2e7232b4e86cf2c4cd48bc495353e | unbreakble26/python_study | /python_study1.py | 3,057 | 3.578125 | 4 | #1) 이름분석
data = '이의덕,이재명,권종수,이재수,박철호,강동희,이재수,김지석,최승만,이성만,박영희,박수호,전경식,송우환,김재식,이유정'
''',를 기점으로 이름을 통째로 배열 안에 넣어준다.'''
names = data.split(",")
print(names)
print(names[1])
park = 0
kim = 0
for name in names:
print(name)
for name in names:
if name.startswith('박'):
park += 1
elif name.startswith('김'):... |
4a6671d8c8ebcb8a9edf1d229e9de21ec796fd52 | shubhamkumar27/Leetcode_solutions | /30. Substring with Concatenation of All Words.py | 577 | 4.0625 | 4 | '''
You are given a string, s, and a list of words, words, that are all of the same length.
Find all starting indices of substring(s) in s that is a concatenation of each word in
words exactly once and without any intervening characters.
Example 1:
Input:
s = "barfoothefoobarman",
words = ["foo","bar"]
Output: [0,9]... |
83686ab112ea77e96469387a3137105aa6091def | Yessinia-199/Tarea-Python-1 | /Módulo 1/Ejercicios/tarea3ec.py | 422 | 4.125 | 4 | import math
print ("Teniendo la ecuación ax^2 + bx + c")
print("-------")
a = int(input("ingrese el valor de a:"))
b = int(input("ingrese el valor de b:"))
c = int(input("ingrese el valor de c:"))
x= (b*b)- 4*a*c
if x<0:
print ("No existe soluciones reales")
else:
x1 = (-b + (x**(1/2)))
x2 = ... |
248bea61b493a71cef82629853dfb060ac10e1a6 | jhod0/Fractran | /core.py | 2,969 | 3.90625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division, print_function
from parser import process
import numbers
class Program(object):
"""Represents a FRACTRAN program.
Construction:
Takes a list of fractions, and optionally a description.
A fraction can either be a t... |
538c9d9ca99f24b4ff589d5af7f18e882de75010 | gskrscm/PythonPractice | /dictionary.py | 393 | 4.21875 | 4 |
a = (1,2,3) #tuple - It is immutable list
b = {'a' : 5} # Dictionary - key value pair
b ['c'] = 10 # Adding new value to dictionary. It can be added at the end or start or any where
# Changing value
b ['c'] = 20 # Changing value of a dictionary element
b [a] = 35 # Adding tuple 'a' as key.
print(b)
print(b['a']... |
b1a78eccbe3c9cf7091ccee7460677ed1feb8591 | yanpan9/Some-Code | /ListNode/206.py | 417 | 4.03125 | 4 | from data_structure import ListNode
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if not head:
return None
head_1, head_2 = ListNode(0), ListNode(0)
head_1.next = head
while head_1.next:
node = head_1.next
head_1.next = node.n... |
d2c5af1e777c9dbf72188b56ac86a5466f3da264 | AndreaGarofoli/Rosalind-problems | /1.DNA.py | 600 | 4.1875 | 4 | """
Problem:
A string is simply an ordered collection of symbols selected from some alphabet and formed into a word; the length of a string is the number of symbols that it contains.
An example of a length 21 DNA string (whose alphabet contains the symbols 'A', 'C', 'G', and 'T') is "ATGCTTCAGAAAGGTCTTACG."
Given: ... |
a1ea5f1bd2ed309453c67a13f6c40f44df822720 | RamiMhanna/python | /type_conversion/app.py | 209 | 3.875 | 4 | birth_year = input('Birth year: ')
age = 2020 - int(birth_year)
print(age)
print(type(birth_year))
print(type(age))
weight_lbs = input('Weight (lbs): ')
weight_kg = float(weight_lbs) * 0.45
print(weight_kg)
|
6e6e2448053fcffdaac89e590e77b07a36b07ba6 | geniousisme/CodingInterview | /Company Interview/FB/OneEditDistance.py | 818 | 3.6875 | 4 | class Solution(object):
def isOneEditDistance(self, str1, str2):
if not str1 and not str2:
return False
if len(str1) > len(str2):
return self.isOneEditDistance(str2, str1)
len1 = len(str1); len2 = len(str2); i = 0; shifted = len2 - len1
if shifted > 1:
... |
e4f2bcbde8ed9561975a51888c684d72db1a8bd5 | ammydolphin/space_racer | /game_over_effect.py | 2,314 | 3.734375 | 4 | """Module for rendering 'game over' animation effect."""
import pygame
from sliding_label import SlidingLabel, SLIDE_BOTTOM
from blinking_label import BlinkingLabel
FONT_SIZE = 92
COLOR_PRIMARY = (121, 0, 0)
COLOR_SECONDARY = (242, 108, 79)
TEXT_MESSAGE = 'GAME OVER'
SLIDING_SPEED = 4
class GameOverEffec... |
2a3b863f2316ef805340cfe27482a22f309ac267 | infdahai/PE_sol | /Problem_3.py | 652 | 3.59375 | 4 | import math
def find_number(x= 600851475143 ):
max_ = 0
for i in range(2,int(math.sqrt(x))+1):
while x % i ==0:
x = x/i
if i > max_:
max_ = i
print(max_)
find_number()
"""
two optimization consideration : [1.] 2 and fact>3 [2.] fact>3 but fact must less than $sqrt{n}$
n=”the evil big n... |
5c7f4cf22ccbb37e412022fcec5be260ba44199b | lvncnt/Leetcode-OJ | /Linked-List/python/mergeSortedList.py | 469 | 4.0625 | 4 | ## merge two sorted linked lists and return it as a new list
class Node():
def __init__(self, data):
self.data = data
self.next = None
def mergeSortedList(l1, l2):
dummyHead = Node(0)
p = dummyHead
while(l1 != None and l2 != None):
if(l1.data <= l2.data):
p.next = l1
l1 = l1.next
... |
11ba48a1a96150b6b51ab2fd82f9c1153a574890 | bnagarjun902/1 | /conditionals.py | 1,341 | 4.0625 | 4 | #if conditional........
#a = 34
#if a>= 30:
#print(a, "is greater than 30")
#if else conditional .....
#user_name = input(" enter username: ") # input function = string data type.....
#pass_word = int(input(" enter password: "))
#if (user_name == "bujji" and pass_word == 95):
# print("successfully logged i... |
3b2b73b909da21b3aec1a3bb57c0b15edb9617f7 | qmnguyenw/python_py4e | /geeksforgeeks/python/python_all/60_9.py | 1,898 | 4.1875 | 4 | Python – Group Tuples by Kth Index Element
Sometimes, while working with Python records, we can have a problem in which
we need to perform grouping of elements of tuple by similar Kth index element.
This kind of problem can have application in web development domain. Let’s
discuss certain way in which this ta... |
becb599627f3735b67830d4d9bf118a001dd40a0 | santhosh-learn/daily-coding-challenge | /00-10/02/Product Of All Numbers Except One.py | 792 | 4 | 4 | """
Given an array of integers,
return a new array such that each element at index [i] of the new array is the product of all the numbers in the original array except the one at [i].
For example,
if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24].
If our input was [3, 2, 1], the expec... |
273498c855a898902de96eab0f259c217560f469 | Algebra-FUN/My-Data-Structure | /Sort/bubble_sort.py | 359 | 3.875 | 4 | def bubble_sort(a):
n = len(a)
for i in range(n):
exchange = False
for j in range(n-1,i,-1):
if a[j-1] > a[j]:
a[j-1],a[j] = a[j],a[j-1]
exchange = True
if not exchange:
return
if __name__ == "__main__":
a = [8,9,5,6,1... |
f1a8e26712d1e2ff10328688390f5dba9c90ed28 | ggldnl/Robot-Simulator | /geometry/polygon.py | 7,693 | 3.859375 | 4 | from geometry.utils import linalg
from geometry.point import Point
import numpy as np
import math
class Polygon:
def __init__(self, points):
"""
:param points: a list of 2-dimensional vectors.
"""
# Deep copy of the points array. While making the copy we can
# find the ce... |
8b424e90963e6c0d2b755ac4c35b8209446a914d | fancona/Python | /whileLoops.py | 1,404 | 4.34375 | 4 | """
1.While Loop Basics
a.create a while loop that prints out a string 5 times (should not use a break statement)
b.create a while loop that appends 1, 2, and 3 to an empty string and prints that string
c.print the list you created in step 1.b.
"""
counter = 3
empty = []
while counter < 9:
empty.append([1,... |
46ef5e1d01ff69bd5fe10884d8db3752c2b27e15 | Alnipet/search_copy_transfer_files | /search_copy_transfer_files.py | 1,551 | 3.5625 | 4 | #подключаем библиотеки для работы с файлами
import os, shutil
import time
"""генерация имён файлов в дереве каталогов.
Для каждого каталога функция walk возвращает кортеж (путь к каталогу, список каталогов, список файлов)"""
def CopyTransFile(pathFrom, pathIn, exp):
n = 0
for root, dirs, files in os.walk(pathF... |
05c3325ba409df20d6bd72871e10c8746793a301 | SergioRyzhov/python | /lesson3/task_4.py | 316 | 3.640625 | 4 | def power_func2(num_x, num_y):
power_x = num_x
if num_y != 0:
for i in range(1, abs(num_y)):
power_x *= num_x
power_x = 1 / power_x
else:
power_x = 1
return power_x
power_func1 = lambda num_x, num_y: num_x ** num_y
print(power_func1(3, -3), power_func2(3, -3))
|
668802b57ddb9d2d1b1188ff2dbb0c04c702a235 | noobul/PythonTraining | /Ch6/dictionarielooping.py | 1,163 | 4.09375 | 4 | #6-4 Glossary 2
programming_words = {
"variable" : "keyword that can store data",
"string" : "text data type",
"boolean" : "data type that can have the value 'true' and 'false'",
"if-else condition" : "method for checking conditions and executing code based on result",
"integer" : "whole-number data... |
8ac0c7884cb0fb38e3537c7c22530c87e7856325 | RaiLincolnSS/Projetos-pequenos | /Adivinhação.py | 444 | 3.828125 | 4 | from random import randint
NUMBER = randint(0, 10)
ATTEMPTS = 3
C = 0
# repetir enquanto houver tentativas
while C < 3:
KICK = int(input('Em que número de 1 a 10 o computador pensou?'))
C += 1
ATTEMPTS -= 1
if KICK == NUMBER:
print("Parabêns você acertou")
break
elif KICK != NUM... |
b8a57aeef1409c0170efea57b0e71dc964eafed4 | chrissyzic/python-the-hard-way | /ex06.py | 980 | 4.4375 | 4 | #This variable is the joke setup
x = "There are %d types of people." % 10
#This is one half of the answer
binary = "binary"
#This is the other half of the answer
do_not = "don't"
#This the the answer of the joke all put together
y = "Those who know %s and those who %s." % (binary, do_not)
#Print the joke setup and ... |
fa7b97cf090fdab59eadca0d036b1168723cbe11 | Saikilito/TeachingTools | /Python/3- Metodos Numericos/2- Interpolación/pol_newton.py | 3,326 | 3.515625 | 4 | ##*---------------------------------------------------------------*##
## -- Metodo de Interpolación por diferencias divididas y Newton --##
## ------ UCV - Kembert Nieves CIV 21.283.323 -------##
##*---------------------------------------------------------------*##
import numpy as np
from sympy import *
... |
76b67b44548b377ad9668b7a034365e254e1f546 | samarth031/sample-data-structures | /merge_sort.py | 587 | 4.09375 | 4 | def merge_logic(s1, s2, full_arr):
i = j = 0
while i + j < len(full_arr):
if (j == len(s2)) or (i < len(s1) and s1[i] < s2[j]):
full_arr[i+j] = s1[i]
i += 1
else:
full_arr[i+j] = s2[j]
j += 1
... |
f26c4d502a7f1235d2d6f6e53b8a1b3b3dcf1c05 | 4st1nus/Vigenere-Cipher-Key-Finder | /decipher.py | 394 | 4.21875 | 4 | #!/bin/python
print ("Vigenere Decipher\n")
print ("Text must be entered without Symbols or Space\n")
plain = raw_input("Enter Known Text: ")
encrypted = raw_input("Enter the corresponding Encrypted text to the known text: ")
password = ""
for i in range(len(plain)):
x = ((ord(encrypted[i]) - ord(plain[i])) % 26... |
75ca8ee316fa704bc9acc48e6a6c446943ea8e03 | Aleleonel/algoritimos | /venda.py | 2,156 | 3.75 | 4 | produtos = {
'01': 'nootebok',
'02': 'ipad'
}
valor = {
'01': 1500,
'02': 1000
}
compra_realizada = {}
def compra_itens():
codigo_do_item = input('digite o código do item: ')
quantidade = int(input('Digite a quantidade: '))
desconto_fixo = int(input('Digite o valor do desconto fixo'))
... |
0150aec22bb664ae115473e288e244a95e8d4a69 | atanasbakalov/Programming0-1 | /week 2/2-List-Problems/4 sum_numbers.py | 242 | 4.125 | 4 | n = int(input("Enter count of numbers:" + "\n"))
start = 1
sum_numbers = 0
while start <= n:
number = int(input("Enter number:" + "\n"))
sum_numbers += number
start += 1
print("The sum of all numbers is:", sum_numbers)
|
e9fcae4769077c25137133ba9507dd8a9d6e41e4 | BakdauletZhalgasbayev/python | /Python/1.py | 1,166 | 3.890625 | 4 | #python "D:/Python/1.py"
def fac(b):
if b == 1:
return 1
else:
return b*fac(b-1)
print(str(int(fac(9)/(fac(5)*fac(9-5)))))
print("способов покрасить 5 шаров в черный цвет")
#Визуализация:
'''import copy
balls = [0,0,0,0,0,0,0,0,0]
def check(b):
c = 0
for i in range(len(b)):
if b[... |
3a418c0ef2545b128923da97cade5d9f0102f8ea | v1ktos/Python_RTU_08_20 | /Diena_9_sets_tuples/uzd2_g1.py | 500 | 3.53125 | 4 | # def get_common_elements(seq1, seq2, seq3):
# result = set(seq1) & set(seq2) & set(seq3)
# return tuple(result)
# seq1 = (2, 3, 5, 8)
# seq2 = [2, 8, 4]
# seq3 = (7, 9, 2, 8)
# print(get_common_elements(seq1, seq2, seq3))
def get_common_all(*argv):
my_set = set(argv[0])
for seq in argv[1:]:
... |
80f3a9d43f67546daeb98e941a2bdb3b748f73c2 | ENate/nlp-classification-example | /misc_files/misc_py/some_python_feats.py | 1,088 | 3.71875 | 4 | """Main"""
from dataclasses import dataclass
from functools import partial
from timeit import timeit
@dataclass(slots=False)
class TeacherSlots:
"""printing teachers"""
name: str
age: int
address: str
@dataclass(slots=False)
class Teacher:
"""printing teachers"""
name: str
age: int
a... |
664edad9a515e3dd379f72b25f5957c6130f87dd | cyrt63/demos | /Tutorials/Lesson003.py | 756 | 3.609375 | 4 | '''
This lesson demonstrates adding a simple object to a scene.
'''
from browser import WindowAnimationRunner
from geometry import CartesianSpace, SphereBuilder
from workbench import Workbench3D
scene = CartesianSpace()
# The object is created using the builder pattern.
sphere = SphereBuilder().color(0x0000FF).build(... |
a5f700d0a7122c5f8984981104691d02a89b5ab1 | pronob1010/Codeforces_Solve | /cf_61_a.py | 144 | 3.53125 | 4 | s1 = input()
s2 = input()
for i in range(1,len(s1)+1):
if s1[i-1]==s2[i-1]:
print("0", end="")
else:
print("1", end="") |
bbb9ee988d779b33317ae2c63584b44faede3d10 | Ryuana/Contests | /Atcoder/AtcoderC/Switches.py | 95 | 3.8125 | 4 | list=list([5,1,4,2,3])
print(list)
for i in range(3):
print(3-sorted(list).index(list[i]))
|
0e8a0ddbdc06a62d83dd8586025f995e06cc9feb | ericaschwa/code_challenges | /correctHTML.py | 1,571 | 4.03125 | 4 | """
correctHTML
By: Erica Schwartz (ericaschwa)
Solves problem as articulated here:
https://ryanstutorials.net/programming-challenges/
Problem Statement:
Create a program which will read in a file containing HTML and identify
lines with incorrectly nested tags. This is an example of correctly nested
tags:
<H1>This i... |
990766fd778292e972bd9502e019a2f3cc976316 | estraviz/codewars | /6_kyu/Backwards Read Primes/backwards_prime.py | 542 | 4.0625 | 4 | """Backwards Read Primes
"""
def backwards_prime(start, stop):
primes = (i for i in range(start, stop + 1) if is_prime(i))
back_primes = []
for prime in primes:
if is_prime(int(str(prime)[::-1])) and not is_palindrome(prime):
back_primes.append(prime)
return sorted(back_primes)
d... |
3a0a4d35d802639bc2bc7421c905cd4c5d615a43 | tyutltf/Leecode | /701-800/709-转换成小写字母.py | 1,134 | 3.671875 | 4 | # -*- encoding: utf-8 -*-
'''
@File : 709-转换成小写字母.py
@Time : 2021/12/02 19:55:21
@Author : TYUT ltf
@Version : v1.0
@Contact : 18235121656@163.com
@License : (C)Copyright 2020-2030, GNU General Public License
'''
# here put the import lib
'''
给你一个字符串 s ,将该字符串中的大写字母转换成相同的小写字母,返回新的字符串。
示例 1:
输入:s = "... |
27ccd15c7b00d50e793723828aa5782424efe6ef | muyani/trainingPythonBasics | /conditionals.py | 215 | 3.796875 | 4 | # let the user input values
marks = input("Enter your KCPE marks: ")
marks = int(marks)
if marks>=250:
print ("Congratulations and Welcome to Jamea")
else:
print ("Sorry ,you have been rejected")
#
|
badef06c017059e50250d8e8e1425fe79e5bbf86 | Yashita101/PIP_1BM17CS152 | /2b_reverse.py | 329 | 3.890625 | 4 | def reverse1(str1):
l=[]
l = str1.split(' ')
l.reverse()
return ' '.join(l)
def reverse2(str1):
l=[]
l = str1[::-1].split(' ')
l.reverse()
return ' '.join(l)
str1 = input("Enter your sentence:")
x = reverse1(str1)
y = reverse2(str1)
print('OUTPUT 1:',x,'\n')
print('OUTPUT 2:'... |
668a1d716b4d8606f1f088ddee604be0e3f92cc2 | Sakshamgupta20/Python-Programs | /The Full counting sort.py | 1,246 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 17:57:42 2019
@author: Saksham
"""
"""
In this challenge you need to print the string that accompanies each integer in a list sorted by the integers. If two strings are associated with the same integer, they must be printed in their original order so your sorting algo... |
c82ff1082b7a309e0cf65301e89b18d4f3a1c16c | Nihanglama/python-learn | /Numpy.py | 3,650 | 3.8125 | 4 | # import numpy as np
# A = [
# [1, 2, 3],
# [55, 66, 7]
# ]
# B =[
# [5,4,3],
# [6,-8,7],
# [1,-1,10]
# ]
# C =[
# [1, 2, 3, 8],
# [5, 6, 7, 5],
# [6, 7, 12, 12],
# [11, 12, 13, 20]
# ]
# def printMatrix(X):
# for i in range(len(X)):
# for j in range(len(X[0])):
# ... |
4ffb96437c090cca5e8ee3ffc7cece9a52c578e8 | RaspBri/logger-project | /main.py | 1,322 | 3.625 | 4 | # 7/15/21
# Keylogger Project
# Note: Must allow computer Input Access to PyCharm for KeyLogger to run program
# must upgrade pip and python for the import to work properly
import pynput
from pynput.keyboard import Key, Listener
count = 0 # every so many keys the text file will be updated
keys = []
# when a key is ... |
36fd9d354d81fd07cacbf4eb0856cf4162145317 | kyumiouchi/python-basic-to-advanced | /10.68. Reversed.py | 1,036 | 4.6875 | 5 | """
Reversed
OBS: It is different from reverse() from list => the function reverse() just work with
list and reversed() with any iterable.
"""
list_number = [1, 2, 3, 4, 5]
result = reversed(list_number)
print(result) # <list_reverseiterator object at 0x0000029BC4B12FD0>
print(type(result)) # <class 'list_reversei... |
4691aa7dafb49bb1d744ad40d6f66a3e8cc63d20 | justzino/algorithms | /This-is-Coding-Test-Book/Search/7-5.py | 835 | 3.796875 | 4 | n = int(input())
parts = list(map(int, input().split()))
m = int(input())
orders = list(map(int, input().split()))
parts.sort()
def binary_search(array, target, start, end):
# 해당 부품이 없는 경우 False 반환
if start > end:
return False
# 찾은 경우 True 반환
mid = (start + end) // 2
if parts[mid] == tar... |
7eeb1429ffdbff9cf0711d4c0023f65e452c413b | AdalbertoM/Algoritmos-Python_3 | /trab2.py | 1,352 | 4.28125 | 4 | ''' Escrever um programa em linguagem Python que controle as retiradas de dinheiro de um cofre.
Aluno: Adalberto Marques da Costa.
E-mail: adalbertonatal@hotmail.com '''
valor_total = int(input("Digite o valor total de retirada do cofre: R$ "))
saque = 0
valor_res = valor_total
while True:
n100 =n50 = n20 ... |
06b25da0a904fa25f6d589d0b77bc806030b4793 | panda7802/django_test | /demos/src/mid/oop1.py | 1,195 | 4 | 4 | # coding=utf-8
class Person(object):
__name = ""
__score = 0
def __init__(self, name, score):
self.__name = name
self.__score = score
def get_grade(self):
res = ""
if(self.__score >= 90):
res = self.__name + " 优秀"
elif (self.__score... |
600cb4a4a0fb0c02fd641c0744d20d4413860cd0 | erroren/Python_A | /0404/demo03.py | 313 | 3.671875 | 4 | L = [x for x in range(10)]
print(L, type(L), L.__sizeof__())
L1 = (x for x in range(10))
print(L1, type(L1), L1.__sizeof__())
# print(L1.__next__())
def run(L1):
for i in L1:
yield i
r = run(L1)
while True:
try:
print(next(r))
except Exception as e:
print(e)
break
|
6ed745a07ac9ea8783f49ab70bcc13b1d3555fb6 | Dorkond/stepik-python-course | /Module 3/3.2.2.py | 1,252 | 4.0625 | 4 | '''
Напишите функцию update_dictionary(d, key, value), которая принимает на
вход словарь dd и два числа: key и value.
Если ключ key есть в словаре dd, то добавьте значение value в список, который хранится по этому ключу.
Если ключа key нет в словаре, то нужно добавить значение в список по ключу 2 * key.
Если и к... |
3fd4f909db4f3732b4dc55f4833f43bffe5ba1e7 | fortune009/Python-tutorial | /motors.py | 407 | 3.953125 | 4 | motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
popped_motorcycles = motorcycles.pop()
print(motorcycles)
print(popped_motorcycles)
motorcycles.append(popped_motorcycles)
print(motorcycles)
motorcycles.remove('suzuki')
print(motorcycles)
cars = ['bmw', 'audi', 'toyota', 'suberru']
#cars.sort()
print(cars... |
5b866d9d29f5bf51695e02b69e38a4e5a408f7ca | taihaozesong/CS229_2018 | /PS1/src/p01b_logreg.py | 2,330 | 3.796875 | 4 | import numpy as np
import util
from linear_model import LinearModel
def main(train_path, eval_path, pred_path):
"""Problem 1(b): Logistic regression with Newton's Method.
Args:
train_path: Path to CSV file containing dataset for training.
eval_path: Path to CSV file containing dataset for ev... |
5a148326495f52f97b4c281f5df3fc5294de8976 | miikkij/tomerater | /TomeRater.py | 11,154 | 3.796875 | 4 | class User(object):
def __init__(self, name, email):
self.name = name
self.email = email
self.books = {} # Book : Rating
def get_email(self):
return self.email
def change_email(self, address):
old_email = self.email
self.email = address
print("Email... |
e83247f26194157773f3895d526d2b0062d31409 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2382/60622/317080.py | 235 | 3.796875 | 4 | n=int(input())
l=[]
for i in range(n):
s=input()
l.append(s)
print(l)
if l==['5 6', '1 4', '10 10', '6 9', '8 10', '12 13', '16 18']:
print("1 4")
print("5 10")
print("12 13")
print("16 18")
else:
print(l)
|
5d07f19b35eecfff1f09799f0f9be265c3d9ff54 | wasit7/tutorials | /iddcdt_day2/01guess.py | 334 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 14 23:05:26 2015
@author: Wasit
"""
import random
y=-1
x=random.randint(0,32)
while x!=y:
y=int(raw_input("guess a number:"))
if y<x:
print y," is LESS than the corrected number"
if x<y:
print y," is LARGER than the corrected number"
print y,... |
1d0c50b036d2de9b57d56718d49bd660200ff90f | sidv/Assignments | /Greeshma_Prakasan/Aug17/main_file.py | 1,214 | 3.921875 | 4 | import file
while True:
print("Enter 1 for create file")
print("Enter 2 for write data to file")
print("Enter 3 for delete data from file")
print("Enter 4 for read data from file")
print("Enter 5 for copy content of file to another file")
print("Enter 6 for find string inside a file")
print("Enter 7 for compare ... |
9b887dc92a6a39fb978bd76b69e06bc337201202 | NathanMuniz/Exercises-Python | /Desafio/ex100.py | 490 | 3.5625 | 4 | from random import randint
from time import sleep
lista = list()
def sortear():
print("Sorteando 5 Valores da lista: ", end="", flush=True)
for c in range(0, 5):
lista.append(randint(1, 10))
sleep(1)
print(lista[c], end=" ", flush=True)
print("PRONTO!")
def somar():
som = 0
... |
3e4776976e9bbf0f79dadff09708259a1e54a447 | guzel-web/python-draft | /RandomIterator_yield.py | 918 | 4.125 | 4 | from random import random
# class RandomIterator:
# def __iter__(self):
# return self
#
# def __init__(self, k): # конструктор класса
# self.k = k # количество перебираемых чисел
# self.i = 0 # кол-во перечисленных итератором чисел
#
# def __next__(self):
# if self.i < se... |
6d9d84c1c47603b9dd1f71e196ece942c6f655de | Zero2Infinity/Python | /minion_game.py | 1,325 | 3.609375 | 4 | def minion_game_2(string):
vowel = 'AEIOU'
stuart_score = 0
kevin_score = 0
for i in range(1, len(string)+1):
for j in range(0, len(string)):
s = (string[j:i+j])
if len(s) == i:
if s[0] in vowel:
kevin_score += 1
e... |
01f2f94cc1ab3aa30f2c0999d823f2e7837c2e1c | mattoffice/Weatherman | /service1.py | 894 | 3.625 | 4 | import requests
import simplejson as json
def main():
"""
value = input(
"Which planet do you want to know about? Type a number between 1 and 10 - or however many planets there are...!\n")
"""
response = requests.get(
"https://swapi.co/api/planets/")
print(response.status_code)
... |
097ca809a0f49a49bb0779d40585a219b70efbb8 | WindyAmy/WindyAmy.github.io | /_posts/pythonDemo/func_default.py | 254 | 3.640625 | 4 | #coding=utf-8
#函数的默认值
'''
默认参数使用的是=给参数赋值
注:只能在参数末尾使用默认参数
def func(a,b=5) 有效
def func(a=5,b) 无效
'''
def say(message,times=1):
print message*times
say('Hello')
say('World',5)
|
d5d343573a7c2b9db80b0b3525fa8b33a512d65e | Dearyyyyy/TCG | /data/3922/AC_py/516540.py | 197 | 3.5 | 4 | # coding=utf-8
while True:
a, b = map(int, input().split())
try:
result = a / b
if (result - int(a / b) >= 0.5):
result += 0.5
print(int(result))
except Exception as e:
print("error") |
2a22817d12db3c6910ae4efce8b4cb5e1642f404 | preddy5/dltemplate | /src/homemade/classes.py | 5,756 | 4.03125 | 4 | import numpy as np
class Layer(object):
"""
A building block. Each layer is capable of performing two things:
- Process input to get output: output = layer.forward(input)
- Propagate gradients through itself: grad_input = layer.backward(input, grad_output)
Some layers also have learnable ... |
1969a1efbccf224dc18aa710705bf3c182f09a5d | tainenko/Leetcode2019 | /leetcode/editor/en/[1837]Sum of Digits in Base K.py | 914 | 3.78125 | 4 | # Given an integer n (in base 10) and a base k, return the sum of the digits of
# n after converting n from base 10 to base k.
#
# After converting, each digit should be interpreted as a base 10 number, and
# the sum should be returned in base 10.
#
#
# Example 1:
#
#
# Input: n = 34, k = 6
# Output: 9
# ... |
23d68864d5993eb702aa0c22eec95b74772e9bf9 | alexYooDev/pythonSyntax | /algorithms/gcd_recursive.py | 90 | 3.703125 | 4 | def gcd(a,b):
if a%b==0:
return b
else: return gcd(b, a%b)
print(gcd(192,162)) |
5f6ed138b3cc2bd4fb4580b79526cc9f3d1f3a81 | kudinov-prog/Arena_game | /game_arena.py | 5,398 | 3.6875 | 4 | from random import randint
def main():
NAMES = ["Джон Сноу", "Дейнерис Таргариен", "Тирион Ланнистер", "Лорд Бейлиш", "Арья Старк",
"Бриенна Тарт", "Григор Клиган", "Вонючка", "Санса Старк", "Джейме Ланнистер",
"Король Ночи", "Бран Старк", "Ходор", "Красная женщина", "Серсея Ланнистер",
... |
8057ff8f4d502aa86d3fe75592c9e7a8aef8bd63 | mihirkelkar/languageprojects | /StInt/Digits_Multiply_toN/digits_multiply_to_n.py | 417 | 3.84375 | 4 | def digits_multiply_to_n(number):
result = list()
if number < 10:
return number + 10
elif number >= 10:
for ii in range(9, 1, -1):
while number % ii == 0:
number = number / ii
result.append(ii)
if number > 10:
print "Not possible"
else:
return "".join(map(str, res... |
81ff9346f9ae0197379cf96f24d13622b7eedbb3 | TripleChoco/ubb | /sem1/fop/Practic/UI/ui.py | 4,386 | 3.671875 | 4 | from Question.question import question
import os
class ui:
def __init__(self, controller, quiz_controller):
self.__controller = controller
self.__quiz_controller = quiz_controller
def getUserInput(self, default_text):
'''
This method returns and user inserted text
'... |
cf719635ed043b39b0cdf028cf4b6773d58faf1a | Hallyson34/uPython2 | /preenchervet.py | 156 | 3.5 | 4 | def main():
n = int(input())
vet = []
for i in range(0,10):
vet.append(n)
print(f"N[{i}] = {vet[i]}")
n = n + n
main()
|
297e496a1ee599244a28e03bed1307b80f499cc4 | dalalsunil1986/Interview-Prep | /Easy/monotonicarray.py | 741 | 4.0625 | 4 | """
1. Figure out if array should be MI or MD, or flat (if flat it won't be MI and shouldn't have any increases)
2. Iterate through array and check for violation based on MI or MD.
"""
def isMonotonic(array):
n = len(array)
# trivially monotonic if array has 1 or no elements
if n < 2: return True
# ch... |
f184e3b1dc62767a9b8106466382e3cd713efa91 | skeitcd/DevOpsTest | /date_validator.py | 456 | 4.0625 | 4 | #!/usr/bin/env python
from datetime import datetime
x=0
def validate(date_text):
try:
datetime.strptime(date_text, "%a %b %d %H:%M:%S")
return True
except ValueError:
return False
while (x<1):
date = raw_input("Please enter a valid date:")
print "You entered:", date
if va... |
33a61d9ff472855c7507e9d9bd92d5ba46c59772 | dipayandutta/python-datastructure | /new/list/Remove_Duplicate.py | 1,047 | 4.09375 | 4 | def check_duplicate(List):
dup_list = []
for i in List:
if i not in dup_list:
dup_list.append(i)
else:
return True
return False
def duplicate_position(dup_list):
dup_items = []
dup_list.sort()
print ("Given List after Sorting {0}".format(dup_list))
fo... |
38324d6c3961048884c13a173581cb32f44ad93d | paniash/progs | /project_euler/p2.py | 190 | 3.875 | 4 | # to sum of even terms of Fibonacci sequence
a = 1
b = 2
sum = 0
for i in range(5):
a, b = b, a+b
while a<4000000:
if a%2==0:
sum+=a
print("The sum is ", sum)
|
7959edcf3422f510647472f9f024d82e7237126c | romanfffg/vsu_programming | /dz2/4.py | 921 | 3.921875 | 4 | def bracket(f):
open_b = 0
end_b = 0
open_b = f.count("(")
end_b = f.count(")")
k = str(end_b - open_b)
m = str(open_b - end_b)
if end_b > open_b:
if k == 1:
return ("You miss the opening 1 bracket")
else:
... |
b69d9770717c178f085bf4035f5022d11e61ec35 | juliocsg/python-cesar | /Operators/isnot.py | 356 | 4.21875 | 4 | x = ["apple", "banana"]
y = ["apple", "banana"]
z = x
print(x is not z)
# returns False because z is the same object as x
print(x is not y)
#returns True because x is not the same object as y, even if
#they have the same content
print(x <> y)
#to demostrate the difference between "is not" and
#"<>" this comparison ret... |
2378c682da0f30c9d796b0b449b80c87ea333902 | yaolizheng/leetcode | /142/linked_list_cycle.py | 580 | 4.03125 | 4 | from linked_list import LinkedList
def has_cycle(head):
slow = head
fast = head
while fast.next and fast.next.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
while head != fast:
head = head.next
fast = fast.next
... |
aeda421e00703272027eeb22bf3f7378156af262 | TedYav/CodingChallenges | /HackerRank/Challenges/Week Of Code 28/tests/generate_digits.py | 110 | 3.671875 | 4 | import random
num = 2 * (10**5)
print(num)
s = ''
for i in range(num):
s += str(random.randint(0,9))
print(s) |
94785447016e245530591f757a26811d1b974018 | samiran163/Helloworld | /break.py | 157 | 3.765625 | 4 | '''count = 0
while True:
print(count)
count+=1
if (count>10):
break
'''
#CONTINUE
for x in range(20):
if(x%2)==0:
#continue
print(x)
|
261e0f89183019ef7e171c55a339aa7b36333c96 | HuynhThiMyDuyen/CS112.L21-Group5 | /Homework/Group-09/ConvexHull.py | 2,077 | 3.5 | 4 | from sys import stdin, stdout
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def Left_index(points):
minn = 0
for i in range(1,len(points)):
if points[i].y < points[minn].y:
minn = i
elif points[i].y == points[minn].y:
if points[i].x ... |
21cb5da0e2a3d319259e4bebb3c68500b8edbc5d | theGreenJedi/Path | /Python Books/Athena/training/exercises/exercises/scipy/integrate_function/integrate_function_solution.py | 1,532 | 3.765625 | 4 | """
Integrate sin using scipy.integrate.quad.
Topics: SciPy's integration library, vectorization.
1. Use scipy.integrate.quad to integrate sin from 0 to pi/4.
Print out the result. Hint::
from scipy import integrate
>>> integrate.quad?
2. Integrate sin from 0 to x where x is a range of va... |
03af7f4914b4b4e41ef3c520c92383404012faf7 | mohamedehab69/task-4 | /Untitled1.py | 2,062 | 4.0625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
def check (x,y) :
if(x%2==0+y%2==0):
if(x<y):
return x
else:
return y
else:
if (x < y):
return y
else:
return x
num_1=int(input("Please Enter number 1 : "))
num_2=int(input("Please ... |
fb3f995e123548da42297628929f3381f471eb83 | japesinator/Project-Euler | /PE_21.py | 461 | 3.65625 | 4 | #!/usr/bin/env python
import math
def amicable_test(n):
def factor_sum(m):
divisors = []
for i in range(2, int(math.floor(math.sqrt(m)) + 1)):
if m % i == 0:
divisors.append(i)
divisors.append(m/i)
return sum(divisors) + 1
if factor_sum(factor_sum(n)) == n and factor_sum(n) != n:
... |
9771d6dde2981c565b17143c3faf5d7bafa626c5 | vdhopte99/8BoardSolver | /BoardSolver.py | 12,166 | 3.71875 | 4 | import heapq
import sys
class Board(object):
# create a board from an n-by-n array of tiles,
# where tiles[row][col] = tile at (row, col)
def __init__(self, tiles):
self.n = len(tiles)
rows, cols = (self.n, self.n)
self.tilescopy = [[0 for i in range(cols)] for j in range(rows)]
... |
d7b4636a13df4d2566e97a4e32757a7733ff320b | shafaypro/shafayworkspace | /Revision udemy/1.py | 728 | 4.0625 | 4 | print ("Hello World")
name, first_name, last_name = 'Muhammad shafay Amjad', 'Shafay', 'Amjad'
number, name, char = 10, 'shafay', 'b'
print (name, first_name, last_name)
var1 = var2 = var3 = 'Shafay'
print(var1, var2, var3)
number = 10
number2 = 20.12312
number3 = 2 / 10
sum = number + number2+ number3 # type has been... |
8049e65b34cc4c1526586caeab906b17d33c4b00 | praveenhp07/begin-python | /even-or-odd.py | 206 | 3.78125 | 4 | def main():
a=input()
try:
x=int(a)%2
if(int(x)==0):
print("even")
else:
print("odd")
except:
print("invalid entry")
if __name__ == '__main__':
main()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.