blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
d37607056b272255785db7fb8b2da652115d588e | kriti-ixix/ml1030 | /python/functions.py | 574 | 3.859375 | 4 | #User defined functions
'''
Four types of functions:
Parameters:
- Default function
- Parameterised function
Return types:
- No return type
- Return type
'''
def addNumbers():
print("Addition:")
x = int(input())
y = int(input())
print(x + y)
def subNumbers():
print("Subtraction:")
x = ... |
d9cb0f66d845de5e767b89dda28377b6f5fa8eb4 | aleksaa01/algorithms-and-data-structures | /data-structures/Python/Deque/array_deque.py | 5,766 | 4 | 4 | """
Deque's front is at the beginning of the list and back at the end of the list.
Unlike Queue, his front and back are swapped.
"""
class ArrayDeque(object):
DEFAULT_SIZE = 10
def __init__(self, list_object=None):
if list_object:
self.data = list_object
self.front = ... |
3bc3c69d54f7e96078aacb5cfbe610b6f55f85b1 | RonDingDing/Algorithm4th | /leetcode/数据结构/链表/23.合并 K 个升序链表.py | 3,803 | 3.734375 | 4 | # 给你一个链表数组,每个链表都已经按升序排列。
# 请你将所有链表合并到一个升序链表中,返回合并后的链表。
#
# 示例 1:
# 输入:lists = [[1,4,5],[1,3,4],[2,6]]
# 输出:[1,1,2,3,4,4,5,6]
# 解释:链表数组如下:
# [
# 1->4->5,
# 1->3->4,
# 2->6
# ]
# 将它们合并到一个有序链表中得到。
# 1->1->2->3->4->4->5->6
# 示例 2:
# 输入:lists = []
# 输出:[]
# 示例 3:
# 输入:lists = [[]]
# 输出:[]
#
# 提示:
# k == lists.... |
40c2fccd97d059897e5f445a84577bb254f3710e | niemitee/mooc-ohjelmointi-21 | /osa06-06_kurssin_tulokset_osa3/src/kurssin_tulokset_osa3.py | 1,496 | 3.515625 | 4 | # tee ratkaisu tänne
opiskelijatiedot = input("Opiskelijatiedot: ")
tehtavatiedot = input("Tehtävätiedot: ")
koetiedot = input("Koepisteet: ")
def arvosana(pisteet):
a = 0
pisterajat = [15, 18, 21, 24, 28]
while a < 5 and pisteet >= pisterajat[a]:
a += 1
return a
def pisteiksi(lkm):
ret... |
a30b2288356e6512103855125acd8dd5eed06700 | ZoeCD/Mision-03 | /pagoTrabajador.py | 1,421 | 3.953125 | 4 | # Autor: Zoe Caballero Dominguez Matrícula: A01747247
"""Descripción: El programa pide las horas normales y extras trabajadas, junto el pago por hora.
Calcula el pago por las horas y el pago total."""
# Programa
"""Función calcularPagoNormal hace la operación correspondiente para sacar el pago
de las horas normales ... |
638ef91795f12bf383ceeb5cbf1cde83a516af84 | daminL/Hangman-game-PA6 | /pa06_hangman/hangman_webapp.py | 2,490 | 3.828125 | 4 | """
website_demo shows how to use templates to generate HTML
from data selected/generated from user-supplied information
"""
from flask import Flask, render_template, request
import hangman_app
app = Flask(__name__)
global state
state = {'guesses': [],
'word': "",
'done': False,
'lette... |
50c70fc13941d9fdce1076793fa72006ec14025f | TehraniZadehAli/Python | /successLoop.py | 130 | 3.984375 | 4 | num = int(input("Enter"))
for i in range(num):
print(i)
else:
print("Done!")
# if i == num-1:
# print("Done!") |
a1fe312558329397aab57b862c1d57690262cf76 | ywyz/IntroducingToProgrammingUsingPython | /Exercise08/8-4.py | 441 | 3.84375 | 4 | '''
@Date: 2019-12-08 19:58:01
@Author: ywyz
@LastModifiedBy: ywyz
@Github: https://github.com/ywyz
@LastEditors: ywyz
@LastEditTime: 2019-12-08 20:01:19
'''
def count(s, ch):
num = 0
for char in s:
if char == ch:
num += 1
return num
def main():
strings = input("Input a string: ... |
2985ef1b7b23cbad0940a78017a96c1d01261c57 | Jmap96/Python | /Python Basico/C6 conversor monedas.py | 1,422 | 3.984375 | 4 | """Mejorando Conversor de Monedas"""
menu = ''' Bienvenido al conversor de monedas 🪙💰
--- Seleciona algun numero para hacer la operacion ---
1 - Pesos Colombianos
2 - pesos Chilenos
3 - Pesos Mexicanos
4 - Pesos Argentinos
--- Elige alguna de las cuatro opciones ---
Gracias
'''
dolar_cop = 3875
... |
23c36036e017b927fde0ecfd18b7ff7c24d39715 | coco-in-bluemoon/cs-basics | /Algorithm/code/sorting_merge.py | 1,204 | 3.765625 | 4 | import random
import time
def _merge_sort(start, end, arr):
if end - start == 1:
return (start, end)
middle = (start + end) // 2
ldx, ldx_end = _merge_sort(start, middle, arr)
rdx, rdx_end = _merge_sort(middle, end, arr)
temp = [0] * (end - start)
index = 0
while ldx < ldx_end an... |
f0422b5caa8d8621edf0d9da86767f756f6cf9aa | JonDGS/Intro-y-Taller | /Recursion de cola/potencias.py | 246 | 3.8125 | 4 | def potencia(num):
if isinstance(num, int) and (num > 0):
return algo(num)
else:
print("El valor no es valido")
def algo(num):
if num == 0:
return 1
else:
print(2 ** num)
return algo(num-1)
|
a4ba0fd935d55aa533393474fbead711d1a18d3e | Himanshu-8830/My-Captain-Tasks | /my captain Task 2.py | 182 | 3.90625 | 4 | def fibo(n):
if(n<=1):
return n
else:
return(fibo(n-1)+fibo(n-2))
n=int(input("Enter the limit:"))
print("Fibonacci series")
for i in range(n):
print(fibo(i))
|
efb3c19fdf1800415632d5c815c30d8fcea9cfef | JuliaGofman/find_path_to_the_site | /lib_requests.py | 729 | 3.640625 | 4 | # Вашей программе на вход подаются две строки, содержащие url двух документов A и B.
# Выведите Yes, если из A в B можно перейти за два перехода, иначе выведите No.
import requests, re
# one, two = input(), input()
one, two = 'https://stepic.org/media/attachments/lesson/24472/sample1.html', 'https://stepic.org/media/a... |
0d247b9f0983362fe0388de4a84031025ace730f | joda2802/pymath | /symbolic_derivative.py | 185 | 3.90625 | 4 | from sympy import *
def derivative(f,n):
return diff(eval(f),x,n)
x=Symbol('x')
f=input('input function in x:\n')
n=input('input number of derivations:\n')
print(derivative(f,n)) |
2cdb238b66147a3262584650dfd637a61ef1972b | mzmudziak/Programowanie-wysokiego-poziomu | /zajecia_7/zadanie_4.py | 1,590 | 3.65625 | 4 | def comparator(x, y):
if type(x) is type(y):
if x > y:
return 1
elif x == y:
return 0
else:
return -1
if type(x) > type(y):
return -1
elif type(x) == type(y):
return 0
else:
return 1
class List(object):
def __init_... |
4a78f7151eea88eb83953f39b08e579a80cdd4f9 | MrzAtn/Prog_Python | /Apprentissage/boucleFor.py | 780 | 4.0625 | 4 | """Fichier d'explications + exemple pour ce qui est des générateurs et iterateur, création d'une boucle for"""
# Iterateur
def myFor(mylist):
# La fonction iter permet d'appeler la méthode spéciale "__iter__" de
# l'objet passé. Celle ci renvoie un itérateur.
ite = iter(mylist)
error = False
whil... |
3d95696775893b1c3d4077f71f21cd03b1234e75 | girishkumaramanchi/pythonassignment | /basic programs in python/twosum.py | 714 | 3.5 | 4 | """class Solution:
def twoSum(self, nums, target):
for i in range(len(nums)):
complement = target - nums[i]
for j in range(i+1, len(nums)):
if nums[j] == complement:
return [i, j]
"""
class Solution:
def twoSum(self, nums, target):
# ... |
4e36f46c1d38374ccb64e1eb3d01ed3d99e6efaa | a8578062/store | /day05/bank.py | 8,398 | 3.75 | 4 | # author:yjl
import random
# 银行库
bank = {}
# 银行名称
bank_name = "中国工商银行昌平支行"
# 欢迎模板
welcome = '''
*****************************************
* 中国工商银行账户管理系统 *
*****************************************
* 1.开户 *
* 2.存钱 *
* 3.取钱 ... |
4dec0963be8ee98565b95dc214e9087667d56fef | marymarine/sem5 | /hometask1/task1.py | 3,232 | 4.3125 | 4 | """Task 1, Program 1"""
class Node(object):
"""Describes node of list: data and link to next node"""
def __init__(self, data=None, next_node=None):
self.data = data
self.next_node = next_node
def get_data(self):
"""Get data value of node"""
return self.data
def get_next... |
fbb0686fcead16ca395050a684ec8aaeefe9367c | trungtinhpltn/LuyenTap | /CoBan/Bai5.py | 287 | 3.6875 | 4 | a= int(input("Nhap vao he so a: "))
b = int(input("Nhap vao he so b: "))
if a == 0 and b == 0:
print("PT {0}x+{1}=0 co vo so nghiem".format(a,b))
elif a == 0 and b != 0:
print("PT {0}x+{1}=0 vo nghiem".format(a,b))
else:
print("PT {0}x+{1}=0 co nghiem x= ".format(a,b), -b/a) |
543072628c32170dfdcb945cc14bcfb959911d68 | casheljp/pythonlabs | /examples/7/handler.py | 239 | 4.125 | 4 | #!/usr/bin/env python3
total = 0
while True:
value = input("Please enter a number: ")
if value == "end":
break
try:
total += int(value)
except ValueError:
print("Invalid number - try again")
print("Total is", total)
|
72ce7f9ad006a0960487230f4d55e3bb80692957 | AGagliano/HW04 | /HW04_ex08_12.py | 1,427 | 4.65625 | 5 | # Structure this script entirely on your own.
# See Chapter 8: Strings Exercise 12 for guidance
# Please do provide function calls that test/demonstrate your function
#Inputs
def rotate_word(s, int):
"""Returns and encrypted string by rotating the letters of the original string (s) by a set integer (int).
Rotatin... |
e4acb495a5f4a4cefc198d4af15b8772537c5b1c | lim1202/LeetCode | /Algorithm/sort.py | 3,182 | 4.0625 | 4 | """Sort"""
import random
import time
def bubble_sort(nums):
"""Bubble Sort"""
if not nums:
return None
for i in range(len(nums)):
flag = False
for j in range(len(nums) - i - 1):
if nums[j] > nums[j+1]:
nums[j], nums[j+1] = nums[j+1], nums[j]
... |
184c3cdc6a1fc83c5da45d6ff7e2f01f5b7b47a1 | challeger/leetCode | /中级算法/leetCode_65_子集.py | 1,834 | 3.859375 | 4 | """
day: 2020-08-19
url: https://leetcode-cn.com/leetbook/read/top-interview-questions-medium/xv67o6/
题目名: 子集
题目描述: 给定一组不含重复元素的整数数组nums,返回该数组所有可能的子集
示例:
输入: [1, 2, 3]
输出:
[
[3],
[1],
[2],
[1,2,3],
[1,3],
[2,3],
[1,2],
[]
]
思路:
1. 回溯
与全排列思路大... |
c858e21e9686fcb157f3159c46d3ab091948b034 | foureyes/csci-ua.0003-fall2020-001 | /notes/filesdemo.py | 1,969 | 4.1875 | 4 | """
open
1. str: name of file you're opening
* actual file name
* can be absolute or relative path
* /Users/jversoza/Desktop/foo.txt
* foo.txt
* this will be relative to pycharm project folder
2. str: a mode (single characters)
* 'r'ead: file should exist
* 'w'rite: will overwrite ex... |
bd317125b445f1eaf70558f9c1280a8f5ee451a5 | learncodesdaily/PP-String | /CountForVowels.py | 289 | 3.953125 | 4 | def counVowels(str):
vowels = 0
for i in str.lower():
if (i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u'):
vowels = vowels + 1
print("The Vowels in the String <",str,"> are : ",vowels)
str = input("Enter an String : ")
counVowels(str) |
569eb5a4e3fd74d44c9bd28b34e09ee9368c8a5f | Cr1s1/bfsutechlab-1week-python | /学习笔记/代码笔记/Day1/2.3_type_conversion.py | 1,261 | 4.375 | 4 | # 2.3 变量类型转换 & 获取变量类型
# 2.3.1 变量类型转换的用法(以字符串转换为整数为例)
birth_year = input('Birth year: ')
age = 2021 - int(birth_year)
print(age)
'''
运行结果:
--------------------
Birth year: 1982
39
--------------------
'''
# 2.3.2 常见的三种变量类型转换
age = '39'
int(age) # 1)字符串转换为整数
rating = '4.9'
float(rating) ... |
a7ab46863598ff378102c753db15d4b3a6f79cd7 | ykcai/Python_ML | /lectures/lecture2.py | 630 | 4.03125 | 4 | # while Loops
i = 1
while i<5:
print("i is: {}".format(i))
i = i+1
# range()
print(range(5))
for number in range(5):
print(number)
# list comprehension
x = [1, 2, 3, 4]
output=[]
for item in x:
output.append(item**2)
print(output)
print([item**2 for item in x])
# functions
def my_func(param1="no... |
7419b41f17a4d503202b87d2aea5ab96e34ab784 | SerhiiKhyzhko/SoftServe | /functions/ET9_palindrome.py | 1,613 | 3.890625 | 4 | from decorators_and_additional_vars.decorators import is_valid_string
from custom_exceptions.exceptions import InvalidInteger
@is_valid_string
def find_palindromes(numbers:str) -> str or 0:
'''
looking for palindrom in numbers string
:param numbers:
:return list with palindrom or 0 if it is not includ... |
edf72c46e096bcf286ebece5c3f2f7136b830264 | capside/principios-arquitectura-azure | /14-bigdata-machine-learning/reducer.py | 1,150 | 3.640625 | 4 | #!/usr/bin/env python
from itertools import groupby
from operator import itemgetter
import sys
# 'file' we use STDIN
def read_mapper_output(file, separator='\t'):
# Go through each line
for line in file:
# Strip out the separator character
yield line.rstrip().split(separator, 1)
def main(sepa... |
e8c1ae95e3b848592d0cf82e471554dbe7116fc4 | NicRichardson/PizzaCalc | /pizzacalc.py | 1,183 | 3.59375 | 4 | from Person import Person
def TryExcept(varType, message, output, returnVal):
while True:
try:
returnVal = varType(input(message))
break
except ValueError:
print(output)
return returnVal
def calcTotalCost(people, tax):
totalCost = 0
tip = 0
while... |
85313633c7cc002f5434264eb592e0401657405c | harrika/python-data | /part01-e14_find_matching/src/find_matching.py | 269 | 3.8125 | 4 | #!/usr/bin/env python3
def find_matching(L, pattern):
lst = []
for i, k in enumerate(L):
if pattern in k:
lst.append(i)
return lst
def main():
aa = ['mwana', 'mukagwa', 'anan']
oo = find_matching(aa,'an')
print(oo)
if __name__ == "__main__":
main()
|
75f757ade32346eae449df9a8287094cf9d74520 | abbhowmik/PYTHON-Course | /Chapter 11.py/Other Dunder Method.py | 552 | 4.09375 | 4 | class Number:
def __init__(self, num): # the method are called as a dunder method
self.num = num
def __add__(self, num2):
print('Lets add')
return self.num + num2.num
def __mul__(self, num2):
print('Lets Multiply')
return self.num * num2.num
def __str__(self):... |
46f9ffd1f5e2afb36601ad7ea3339680318b065b | IvanWoo/coding-interview-questions | /puzzles/earliest_possible_day_of_full_bloom.py | 2,706 | 4.03125 | 4 | # https://leetcode.com/problems/earliest-possible-day-of-full-bloom/
"""
You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:
p... |
95581a6f478e088ad87766d8945ab55fb202dd3d | zhanzecheng/leetcode | /456.132模式.py | 574 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
# @Time : 2018/6/14 上午10:14
# @Author : zhanzecheng
# @File : 456.132模式.py
# @Software: PyCharm
"""
class Solution:
def find132pattern(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
s3 = -123123
st = []
for i in r... |
018c2ffa0bce0b4f07a72707ca92031ea41923fb | mzarecky/advent-of-code | /2020/02/day2.py | 767 | 3.84375 | 4 |
import re
# 3-7 x: xjxbgpxxgtx
def parse_data(x):
temp = re.split("[- :]", x)
return int(temp[0]), int(temp[1]), temp[2], temp[-1]
def is_valid(len1, len2, char, password):
num_char = sum(map(lambda x: x == char, password))
return len1 <= num_char <= len2
def is_valid2(len1, len2, char, password)... |
1846f71726ab68b9661a6043b3d9e0c85a9bf8d2 | ssalinasr/Programacion | /Python/Pyhton Funciones/FunEj13.py | 514 | 3.703125 | 4 | #-------------------------------------------------------------------------------
# Name: módulo1
# Purpose:
#
# Author: FliaSalinasRodriguez
#
# Created: 17/04/2018
# Copyright: (c) FliaSalinasRodriguez 2018
# Licence: <your licence>
#---------------------------------------------------------------... |
7db60a0ebbbf1b8be39b02df4184511bb3f0960c | hlgao666/python_learning_code | /python_learning_code/day_03/delete_duplicates.py | 144 | 3.796875 | 4 | numbers = [10, 20, 30, 20, 10, 40]
unique = []
for num in numbers:
if num not in unique:
unique.append(num)
else:
print(unique)
|
ecbbe819c04e1c58515373d9f3b7521989c6c7eb | jedpalmer/PythonStuff | /python_stuff/ex18.py | 343 | 3.515625 | 4 | def print_two(*args):
arg1, arg2 = args
print "arg1: %r, arg2: %r" %(arg1, arg2)
def print_two_again(arg1, arg2):
print "arg1: %r, arg2: %r" %(arg1, arg2)
def print_one(arg2):
print "arg2: %r" % arg2
def print_none():
print "I got nothin'."
print_two('Jed','Palmer')
print_two_again("Jed","Palmer")
print_one... |
d91d4c2cd14ad948d250c8397aeded6e5d99ca87 | tpraks/python-2.7 | /reverse.py | 130 | 3.90625 | 4 | a = "abcdefgh"
a = raw_input()
print a[::1]
print a[::-1]
if a[::1] == a[::-1]:
print "palindrome"
else:
print "not palindrome"
|
76c2b1fc7141ff1071f32492b049400e307aa71b | Suryaphalle/python_practice | /python/divisable_by_4.py | 217 | 3.578125 | 4 | divby4 = []
nondivby4 = []
for x in range(1,100):
if x % 4 == 0:
divby4.append(x)
else:
nondivby4.append(x)
print("NO divisiable by 4: " + str(divby4))
print("NO not divisiable by 4 :" + str(nondivby4)) |
b9f153f53b28904417983d961ec178f3b258e0d0 | mike03052000/python | /Training/HackRank/Level-1/iterator-3.py | 538 | 3.6875 | 4 | from itertools import *
s1=[1,2,3]
s2=[4,5,6]
s3=['a','b','c']
'''
Also note that ifilter became filter in Python-3
(hence removed from itertools).
'''
print(list(filter(lambda x: x%2, range(10))))
func=chain
print(func ,list(func(s1,s2)))
func=product
print(func ,list(func(s1,s2)))
print(func ,list(func(s1,s2,s3)))... |
3c796dce6752ce744955aef4bcf8c7fc3b06627a | DenisLyakhov/Python_SortingAlgorithms | /SelectionSort.py | 438 | 3.671875 | 4 | def swap(tabl, i, j):
tabl[i], tabl[j] = tabl[j], tabl[i]
def selectionSort(tabl):
temp = tabl
maxIndex = 0
for i in range(0, len(temp)):
maxIndex = i
for j in range(i, len(temp)):
if(temp[j] > temp[maxIndex]):
maxIndex = j
swap(t... |
5f31793e0382a61c9a961e632a46728eeda037d6 | Ved005/project-euler-solutions | /code/consecutive_prime_sum/sol_50.py | 758 | 3.65625 | 4 |
# -*- coding: utf-8 -*-
'''
File name: code\consecutive_prime_sum\sol_50.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #50 :: Consecutive prime sum
#
# For more information see:
# https://projecteuler.net/problem=50
# Problem Statement... |
ad7e342adf2cd0a3ac92d3f70d083dfecc7363b1 | SaidRem/just_for_fun | /groupby.py | 1,265 | 3.96875 | 4 | # Given a string. Suppose a character occures consecutively x times
# in the string. Output these consecutive occurences of the character
# (x, c), where x is the number of times occured the 'c' character in
# the string.
# Input format:
# A single line of output consisting of the string.
# Output format:
# ... |
c0895c4f004796f82260868e49ad70420abb55a3 | ronzohan/bank_app | /bankapp/account.py | 475 | 4.15625 | 4 | """
Model for Account object
"""
class Account(object):
"""
Account object used by the Bank
"""
def __init__(self, account_number, balance):
self.account_number = account_number
if type(balance) == int:
self.balance = balance
else:
try:
se... |
95129d5f96010051bd27f1a59ec4aa7e0b6024d6 | eldar-nurtdinov/Python_tutorial | /task 3.py | 353 | 4 | 4 | def fibonacci(a):
z = 1
if a > 2:
z = fibonacci(a-1) + fibonacci(a-2)
return z
a = int(input('введите номер числа из последовательности Фибонначи'))
c = [1]
i = 1
x = 1
while i < a:
c.insert(i, x)
x = c[i] + c[i-1]
i = i+1
print(c)
print(fibonacci(a))
print(c[a-1]) |
4d6c5340153a5fa0ffa2d229aa47a388332543c6 | arigo7/reference-sheets | /scratchpad.py | 1,710 | 3.8125 | 4 | # class Adult:
# def make_phone_call(self):
# print("I'm picking up the phone and dialing a number and using my voice!")
# class Texter(Adult):
# def make_phone_call(self):
# print("I'm waiting four days")
# print("Now I'll forget to call them back")
# print("Now I'm just textin... |
6720931cb44267bdae349f90e88c6866e96f5935 | SWEETCANDY1008/algorithm_python | /ch01/binarysearch.py | 602 | 3.71875 | 4 | # n : 배열의 크기
# S : 배열
# x : 찾고자 하는 수
# location : 찾고자 하는 수의 위치
def binsearch(n, S, x):
low = 0
high = n
location = 0
while low <= high and location == 0:
mid = (low + high) // 2 # / 대신 //을 사용하는 이유는 소수점을 자동으로 버려주기 때문
if (x == S[mid]):
location = mid
elif ... |
ef402aa527850974f5a97e5d6227a387c9cee95a | briggirl2/piro12 | /2주차금요일과제/stack.py | 549 | 3.640625 | 4 | class stack:
def __init__(self):
self.__arr = []
self.__top = 0
def push(self, item):
self.__arr.append(item)
self.__top += 1
def isEmpty(self):
return self.__arr == []
def pop(self):
if self.isEmpty():
return False
self.__top -= 1
... |
8f2d5b7940da31d204ff9fe12ce306282f758170 | drahmoune/TP4_RO | /tp_4/exo1.py | 2,450 | 3.765625 | 4 | import random as ra
def throw_dice():
return ra.randint(1, 6)
def throw_dice_times(n):
throws = []
for time in range(n):
throw = throw_dice()
throws.append(throw)
return throws
def count_six(throws):
return throws.count(6)
def throw_coin():
retur... |
a41c5a9aad4624a2332c2f2ba090f0a82b760b3f | josulaguna/Python | /ejercicio-pares.py | 155 | 4.09375 | 4 | #Josué Laguna Alonso
#08/02/2018
numero = input ("Escribe un numero: ")
if numero % 2 == 0 :
print "Que bonito numero par"
else :
print "Que numero mas vulgar"
|
9c5c8df757b866004dba45ddaa64f453592cc062 | giovanni-mastrovito/tesi | /script/Mapping SentiCR.py | 1,086 | 3.53125 | 4 | import csv
import re
import sys
in_name = sys.argv[1]
out_name = sys.argv[2]
comments = []
labels = []
in_file = in_name
out_file = out_name
print(in_file)
print(out_file)
#read a csv file
with open(in_file, 'rb') as csvfile:
data = csv.reader(csvfile, delimiter=',')
#print(sum(1 for row in ... |
e221bb3d67cda262c23b17862330e3cd133bd42b | YacineGACI/subjective_attributes | /filter.py | 4,950 | 3.515625 | 4 | import pickle
from similarity.compute_similarity import similarity
def filter_entities(user_tags, sim_threshold=0.3, to_index_later="data/index/to_index.txt"):
"""
@user_tags: list of tags the user is interested in
@index: pre-built index of tags
@sim_threshold: a similarity threshold used... |
2c3f9ec9f5345b113fa148d0d263520137f7cf0b | JinleeJeong/Algorithm | /20년 2월/1411.py | 193 | 3.6875 | 4 | n = int(input())
nArray = []
resultArray = []
for i in range(0, n-1):
card = int(input())
nArray.append(card)
for i in range(1, n+1):
if i not in nArray:
print(i)
|
7ed3f4896557a830333cb308ccb91a973114dc19 | geronimo-iia/c4-model | /c4_model/util.py | 449 | 3.78125 | 4 | import re
__all__ = ["camel_to_snake"]
# __camel_to_snake optimisation pattern
_pattern_1 = re.compile("(.)([A-Z][a-z]+)")
_pattern_2 = re.compile("([a-z0-9])([A-Z])")
def camel_to_snake(name: str) -> str:
"""Convert camel case string to snake case.
Arguments:
name (str): a name
Returns:
... |
ff2c56b8063173571b671fdba70a778356dbed58 | h3x4n1um/CTU-Machine_Learning | /Lab 4/Lab4_example_1.py | 1,822 | 3.546875 | 4 | import numpy as np
import matplotlib.pyplot as plt
def LR1(X, Y, eta, loop_cnt, theta0, theta1):
m = len(X)
for k in range(loop_cnt):
print("Lan lap:\t{}".format(k))
for i in range(m):
h_i = theta0 + theta1*X[i]
theta0 = theta0 + eta*(Y[i]-h_i)*1
theta1 = th... |
d07c2a385e2cef8877e84c07049aa40e6e71849c | FirstSingleheart/homework---classes | /homework for lecture 6(classes).py | 7,161 | 3.609375 | 4 | students_list = []
lecturers_list = []
class Student:
def __init__(self, name, surname, gender):
self.name = name
self.surname = surname
self.gender = gender
self.finished_courses = []
self.courses_in_progress = []
self.grades = {}
students_list.append(self)
... |
927000de15de97588c91bbb6327fa0a462e74c4e | MurtazaMoiyadi/MovieDatabase-Queries | /get_best_pics.py | 665 | 3.8125 | 4 | import sqlite3
db = sqlite3.connect('movie.sqlite')
cursor = db.cursor()
start = int(input('Enter the start year: '))
end = int(input('Enter the end year: '))
command = '''SELECT O.year, M.name, M.runtime
FROM Movie M, Oscar O
WHERE M.id = O.movie_id
AND O.type = 'BEST-PICTURE... |
7b5e70ffc6b2420288a4a690eb94a2b674387ef1 | rashiraffi/Tutorials | /PYTHON/OS/Regular Expression/char_classes.py | 774 | 4.28125 | 4 | import re
print(re.search(r"[pP]ython","Python"))
print(re.search(r"[a-z]way","the end of the highway"))
print(re.search(r"[a-z]way","What a way to go"))
print(re.search(r".way","What a way to go"))
# match any character that aren;t in a group we use "^" this
# Any character that is not a letter
print(re.search(r"[^a... |
fa3daf050182c893ae6d07578e3758e3da80e2d6 | MohamadShafeah/python | /Day7/O22OOPS/O10Privatemember.py | 649 | 3.671875 | 4 | class Student:
def __init__(self, id, name, age):
self.id = id
self.name = name
self.age = age
def get_age(self):
return self.age
def get_id(self):
return self.id
def get_name(self):
return self.name
@classmethod
def StudentFact... |
c97296099523487e93c146ff6ba004970e469aef | smart9545/Python-assignments | /Q1.py | 3,171 | 4.375 | 4 | #############################################
# COMPSCI 105 SS C, 2018 #
# Assignment 2 #
# #
# @author FanYu and fyu914 #
# @version 10/2/2018 #
#############################################
"""
Description:
Task1:
W... |
8ac6c11d02490c36047812e8dc9a4451e04a8f79 | gwaxG/pypatterns | /behavioral/iterator/iterator.py | 1,370 | 3.71875 | 4 | #!/usr/bin/env python3
# coding: utf-8
from abc import ABC, abstractmethod, ABCMeta
class RadioStation:
def __init__(self, freq):
self.freq = freq
def get_freq(self):
return self.freq
class StationList:
def __init__(self):
self.stations = []
self.counter = 0
def ad... |
f1aa349de90ef7267fde44001a51d880e92c9dac | Ashish9426/Python-Tutorials | /18. numPy)/page3.py | 1,163 | 3.546875 | 4 | import numpy as np
def function1():
# list
l1 = [1, 2, 3, 4, 5]
print([num + 10 for num in l1])
# print(l1 + 10)
# function1()
def function2():
a1 = np.array([1, 2, 3, 4, 5])
# broadcast mathematical operators
print(a1 + 10)
print(a1 - 10)
print(a1 * 10)
print(a1 / 10)
... |
06ced6d37d0f427f8eea2033c5bd7b63bf944188 | aimdarx/data-structures-and-algorithms | /solutions/Linked Lists/merge_two_sorted_lists.py | 1,538 | 4.03125 | 4 | """
Merge Two Sorted Lists/Merge Linked Lists:
Merge two sorted linked lists and return it as a sorted list.
The list should be made by splicing together the nodes of the first two lists.
https://www.algoexpert.io/questions/Merge%20Linked%20Lists
https://leetcode.com/problems/merge-two-sorted-lists/
"""
# Definiti... |
f2abcf558f960bfea8fe29e039c793b03d994865 | Aluriak/linear_choosens | /application.py | 2,360 | 3.609375 | 4 | """Application of the linear choosens algorithm:
Bollobas et al., Directed scale-free graphs.
Objectif:
Idea is to generate a random graph knowing the number of nodes, using the following constraint:
- the number of edges is roughtly equal to (3/2) * nb_node ** (3/2)
Implementations:
The basic implementation is, ... |
c4ce7aba5b374a659fbf01ef898e2bf902246c6a | binhnhu1409/Nhu_python_journey | /translate_dna.py | 1,195 | 4.25 | 4 | """
File: translate_dna.py
----------------
This program translates a strand of DNA to create its matching base pair.
A becomes T, T becomes A, G becomes C, and C becomes G.
"""
# The line below imports TextGrid for use here
from TextGrid import TextGrid
def translate_DNA(filename):
"""
This function takes a DNA Te... |
61c08e2df06bd90c1c092969fb7fd9c437bcd8c7 | Vamsi-2203/python | /switch-case.py | 250 | 3.859375 | 4 | ## switch-case in python##
def numbers_to_strings(argument):
switcher = {
0: "v",
1: "c",
2: "b",
3: "d",
4: "a"
}
return switcher.get(argument, "nothing")
print(numbers_to_strings(6)) |
6f96401055430bcbd9f614a5f9e842f3ec3e155a | pratik-iiitkalyani/Python | /list/exercise1.py | 204 | 3.96875 | 4 | numbers = [1,2,5,4,8,6,7,4]
def square_list(l):
square = []
for i in l:
square.append(i**2)
return square
print(square_list(numbers))
num = list(range(1,11))
print(square_list(num)) |
f5c1a6411b67fea0b488c9390cc46db8e6bc8f51 | chjberlioz/project_euler | /Largest palindrome product.py | 701 | 3.765625 | 4 | # coding = utf-8
def reverse_num(n):
reverse_n = 0
while n > 0:
last_digit = n % 10
reverse_n = reverse_n * 10 + last_digit
n = (n - last_digit) / 10
reverse_n += n
return reverse_n
def is_palindrome(n):
if n == reverse_num(n):
return True
else:
retur... |
97e2d7e3edc3fc0db4079fad79de8f973f1671b6 | LaszloWa/Learning-Python | /Lesson 04 - Journal app/My own attempt/User_operations.py | 2,465 | 4.34375 | 4 | # This imports the os module, with which we can find and specify file paths. It is used here to specify where we
# want to save the list that stores the user input, and also where the app can find our previously stored list when
# loading it again
import os
# This function saves the list. It specifies the filename us... |
b7725bbb103fcad96ee9cf27c03ef070bda0762e | roperch/codewars-python-algorithms | /tip-calculator.py | 703 | 3.671875 | 4 | # test cases:
# calculate_tip(30, "poor") --> 2
# calculate_tip(20, "Excellent") --> 4
# calculate_tip(20, "hi") --> 'Rating not recognised'
# calculate_tip(107.65, "GReat") --> 17
# calculate_tip(20, "great!") --> 'Rating not recognised'
import math
def calculate_tip(amount, rating):
rating = rating.lower()
... |
37779262f1a15a7d8990dc1abb30b90c18f8b87b | Boyzmsc/sw-proj-2-team5 | /20171617-노지민-assignment2.py | 169 | 4 | 4 | y = 1
x = int(input("Enter a number = "))
while x != -1:
for i in range(1,x+1):
y *= i
print (x,"! = ", y)
y = 1
x = int(input("Enter a number = "))
|
ac52ceef4450774bb6567f805eef2a7f764ce541 | knparikh/IK | /Sorting/merge_sort.py | 1,284 | 4.0625 | 4 | # Divide into 2 halves using mid, then start merging them
def merge_sort(inp, start, end):
if (start >= end):
return
mid = start + (end - start)/2
merge_sort(inp, start, mid)
merge_sort(inp, mid+1, end)
inp = merge(inp, start, mid, end)
def merge(inp, start, mid, end):
merged = ... |
b394f42018933d4b058309f8eaee1045d331a23e | AkhileshManda/learngit | /vitrno.py | 144 | 3.546875 | 4 | import sys
import re
n=input()
if(re.match('[0-9]{2}[A-Za-z]{3}[0-9]{4}',n)):
print("valid")
else:
print("invalid")
|
e382ca06e11c7115e849163817e57d01c49401ea | Ahmedjam24/Coding | /num_palindrome.py | 140 | 3.84375 | 4 | usr=int(raw_input())
check=usr
num=0
while(usr>0):
rem=usr%10
num=(num*10)+rem
usr=usr/10
if (check==num):
print "yes"
else:
print'no'
|
f439e2c4e084317dc18423a81eea37cf8c00639c | nsf-comp/python-2019-20 | /homework/2_operations-if-else/vowel-soln.py | 1,013 | 4.34375 | 4 | """
NSF CODE
WEEK 2 HW SUGGESTED ANSWERS
WRITTEN 27 OCT 2018
NOTE: This is a suggested answers. These are not definitive solutions.
"""
# take the user input
user_input = raw_input("What letter?")
# if the input is a capital vowel:
if (user_input == 'A') or (user_input == 'E') or \
(user_input == 'I') or (us... |
eb2e18124f6831b45d8b8d755dccc64e290cff18 | sudo-nan0-RaySK/SkillRack | /ArrangementOfPlants.py | 401 | 3.640625 | 4 | class structure:
def __init__(self,height,ID):
self.height=height
self.ID=ID
def main():
n=int(input())
listOfPlants=[]
ht=0
val=0
for i in range(0,n):
val=(input())
ht=int(input())
obj=structure(ht,val)
listOfPlants.append(obj)
listOfPlants.so... |
aad59c9f4527c9d3ef2e196bff12e99eb40e0ace | amrsekilly/py-learn | /common_word.py | 1,245 | 3.875 | 4 |
############################################ Get the highest message sender ############################################
# read input text file
# pick lines starting with 'From '
# second word in that line is the sender email address
# create a dict with key: sender & value: count of messages
# Loop through the dict a... |
3bc8e772a4f6edf80a45fb02ad3bf8e620ee8aa3 | fatmasherif98/Parallel-HTTP-Proxy | /proxy.py | 12,194 | 3.765625 | 4 | # Don't forget to change this file's name before submission.
import sys
import os
import enum
import threading
import socket
from urllib.parse import urlparse
class HttpRequestInfo(object):
"""
Represents a HTTP request information
Since you'll need to standardize all requests you get
as specified by... |
6a94adcf6d9c121c157d63e2866dc984f1435a05 | finefin/pibakeoff | /code/backup/proxy.py | 2,084 | 3.765625 | 4 | # A simple proxy (c) 2013 @whaleygeek
#
# Starts a server on a nominated local port
# when an incoming connection arrives, it is accepted
# then an outgoing client connection is made to the remote host/port
# all data is forwarded in both directions
import network
import sys
import time
def trace(msg):
print("prox... |
d4baba470755959d33f728a11730ce54bd2f9bc0 | K1A2/bakjun | /1002_터렛.py | 533 | 3.53125 | 4 | import math
for _ in range(int(input())):
x1, y1, r1, x2, y2, r2 = map(int, input().split())
if x1 == x2 and y1 == y2:
if r1 != r2:
print(0)
else:
print(-1)
else:
line = math.fabs((2 * (x1 - x2)) * x1 + (2 * (y1 - y2)) * y1 + - 1 * (r2 ** 2 - r1 ** 2 + x1 ** 2... |
b3f590999f55bc1dedf525b66389e0f6d9e19fa9 | wenjunz/leetcode | /intersection_of_two_linked_lists.py | 694 | 3.671875 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def getIntersectionNode(self, headA, headB):
"""
:type head1, head1: ListNode
:rtype: ListNode
"""
l1,l2 = Tr... |
891708f1668d4b00bcadcb153e516771aed66e60 | xlyang0211/learngit | /largest_number.py | 1,779 | 3.90625 | 4 | __author__ = 'seany'
# Note: The most important part is to devise the compare function, and pay special notice to it!
class Solution(object):
def largestNumber(self, nums):
"""
:type nums: List[int]
:rtype: str
"""
self.quick_sort(nums)
return "".join([str(i) for i ... |
0e198b27e1adf33d5c0e4681a922b222d06d5f13 | HawChang/LeetCode | /34.在排序数组中查找元素的第一个和最后一个位置.py | 2,615 | 3.59375 | 4 | #
# @lc app=leetcode.cn id=34 lang=python3
#
# [34] 在排序数组中查找元素的第一个和最后一个位置
#
# @lc code=start
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
#return self.searchRange1(nums, target)
return self.searchRange2(nums, target)
def searchRange2(self, nums: List[int], ... |
e348ca85c6ad00caba14bc1baa1044fa79646646 | afergus89/Engineering_4_Notebook | /Python/quadsolver.py | 466 | 3.8125 | 4 | # Quadratic solver
# Molly and Alex
print ("Quadratic solver")
print ("Enter the coefficients for ax^2 + bx + c = 0")
a = int(input("Enter a:"))
b = int(input("Enter b:"))
c = int(input("Enter c:"))
def doQuad(a,b,c):
d = (b*b - 4*a*c)
if d < 0:
return ("No real roots")
else:
myArray = [st... |
955c36516b576acf0bcaeff4c7544dea12df87dd | abhinav80066/python-projects | /jumbleword.py | 1,422 | 3.734375 | 4 | import tkinter
from tkinter import *
from tkinter import messagebox
import random
from random import shuffle
answers = ["America", "India", "Australia", "Russia", "England"]
questions = []
for i in answers:
words = list(i)
shuffle(words)
questions.append(words)
num = random.randint(0, len(questions)-1)... |
3a0f9b94fedfcd7357e1f8d5b3edde6bda15ff29 | anupammishra08/taskA | /Alphabet learn.py | 556 | 4.21875 | 4 | # Given Word
word = "Mississippi"
# Take an empty dictionary
dic = {}
# loop through every letters of word
for alpha in word:
# check for letter is already
# present in a dic or not
# if present then increment count by 1
if alpha in dic:
dic[alpha] += 1
... |
9055df53b0eadbe2db70c946610fb773d44ce1b2 | rechardchen123/Algorithm-Space | /Multiple_merge/multiple_merge.py | 1,641 | 4.21875 | 4 | '''
实现多路归并排序:
将k(k>1)个已经拍好序的数组归并成一个大的排序结果数组
'''
def two_way_merging_algo(first_list,second_list):
'''
:param first_list:
:param second_list:
:return: sorted list
'''
'''
If the two lists are empty, then return an empty list.
or if one of the list is empty, then return the other.
'''... |
5eb2a6329ae2c2e395eccd93ef860201f4d266ec | paalso/learning_with_python | /ADDENDUM. Think Python/10 Lists/10-7.py | 2,177 | 4 | 4 | '''
Exercise 10.7. Write a function called has_duplicates that takes a list and
returns True if there is any element that appears more than once. It should
not modify the original list.
'''
def has_duplicates(L):
"""Returns True if any element appears more than once in a sequence.
t: list
returns:... |
33202e77164b82a34c8369148ba30f2ca8e5d93b | herereadthis/timballisto | /tutorials/abstract/abstract_06.py | 1,442 | 4.5625 | 5 | """Use abc as a skeleton for subclasses."""
"""https://www.smartfile.com/blog/abstract-classes-in-python/"""
from abc import ABC, abstractmethod
class AbstractOperation(ABC):
def __init__(self, operand_a, operand_b):
"""Initialize by storing 2 args."""
self.operand_a = operand_a
self.ope... |
127fa72fe8a7aa8c5672f7c5758b6db066b5b9f9 | minjoon-park/practice | /coding practice/10_N-th largest in BST.py | 985 | 3.890625 | 4 | class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def insert_left(self, value):
self.left = Node(value)
return self.left
def insert_right(self, value):
self.right = Node(value)
return self.right
root = No... |
6346d2e996a7672ad1a135ceb55f28abf34c30f4 | Charllys-Brauwol/BD-Aulas | /Aula 03/pratica01app.py | 1,428 | 3.890625 | 4 | #Prática01 - Reescreva o código da criação do banco Agenda,
#de forma que os comandos SQL fiquem guardados em constantes
#e essas constantes sejam invocadas por funções. As funções
#devem ficar em um arquivo e os comandos que chamam
#essas funções devem ficar em outro.
#importa o arquivo
import pratica01data
MENU_PROM... |
b359db409b31747ba4206da1d0a81a17c7cd87ec | josdeivi90/Python_exercise | /actividad_matrices.py | 1,055 | 3.6875 | 4 | #A = [[1, 4, 5],
# [-5, 8, 9],
# [ 5, 7, 2]]
#for i in range(len(A)):
# for j in range(len(A[:])):
# print(A[i][j])
#a partir de la matriz, generar dos listas una para los números pares otra para los impares e imprimir cada una de las listas por aparte
'''
A=[[87,-5,654],
[0 , 5, 1]... |
d2ab2eb68154637250fe0df9b17a66442aa0ebba | HarikrishnaRayam/Data-Structure-and-algorithm-python | /Linked List -1/Lectures/Delete Node.py | 1,534 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 11 14:06:27 2020
@author: cheerag.verma
"""
class Node:
def __init__(self,data):
self.data = data
self.next = None
def createLinkedList(arr):
head = Node(arr[0])
tail = head
for data in arr[1:]:
... |
dc9f09e46d31bbaefe3c1a9e4cb460fa804da962 | raghuprasadks/pythontutoriallatest | /23-osmodule.py | 621 | 4.1875 | 4 | '''
It is possible to automatically perform many operating system tasks. The OS module in Python provides functions
for creating and removing a directory (folder), fetching its contents, changing and identifying the current directory, etc.
'''
'''
We can create a new directory using the mkdir() function from the OS mo... |
5f687c5e8c97a0a10d17af9047c025d2c57683b9 | dangtien99/BaiTap | /lab1/bt5.py | 323 | 3.84375 | 4 | def fibonacci(n):
f0 = 0;
f1 = 1;
fn = 1;
if( n < 0):
return -1;
elif(n == 0 or n == 1):
return n;
else:
for i in range(2, n):
f0 = f1;
f1 = fn;
fn = f0 + f1;
return fn;
print ("10 so dau tien cua day fibonacci la:");
sb = "";
for i in range(0, 10):
sb = sb + str(fibonacci(i)) + ",";
print (sb)
... |
0f6b9a5e7f3bc5bda2cde91aa7f32ca160516c79 | tule2236/Movie_Recommendation_SageMaker | /generate_users.py | 411 | 3.578125 | 4 | '''generate fake user data'''
import random
import names as gen_name
import vars
def generate_users(count=vars.NUM_USERS):
""" Create random users with gender and name """
for _ in range(count):
gender = random.choice(['female', 'male'])
name = gen_name.get_full_name(gender=gender)
use... |
ee222712dd72cea70a74b08a6ffc4acfe3fac1e8 | wude935/CS-313E | /Assignment 4/WordSearch.py | 10,051 | 3.75 | 4 | # File: WordSearch.py
# Description: This program reads in a k by k square of characters and finds pre-set words inside that square
# Student Name: Derek Wu
# Student UT EID: dw29924
# Partner Name: Victor Li
# Partner UT EID: vql83
# Course Name: CS 313E
# Unique Number: 50205
# Date Created: Septembe... |
d428999956d8f8e155d803d6adc3ce82eeca4427 | sandeep2000/sandeep | /rps.py | 376 | 3.90625 | 4 | #dictionary
import random
a={1:'r',2:'p',3:'s'}
while(True):
c=a[random.randint(1,3)]
user_input=input("enter rock paper or scissor")
print("computer puts",c)
#conditions
if(user_input=='r'and c=='s' or user_input=='p'and c =='r' or user_input=='s'and c =='r'):
print("you wins")
else:
print("you lose!!!!... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.