blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b0cfbd9528be8a03f9e7f7c8139b6804eebb5cd1 | pepesan/machine-learning-python | /02_01_01_pandas_columns.py | 1,522 | 4.28125 | 4 | # -*- coding: utf-8 -*-
#importacion de pandas
import pandas as pd
import sys
print('Python version ' + sys.version)
print('Pandas version: ' + pd.__version__)
# Our small data set
d = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# Create dataframe
df = pd.DataFrame(d)
print(df)
# Lets change the name of the column
df.columns... |
c739b4e91f0cbd5553f6bc3dcf42ae52b8d86555 | RespectKnowledge/Imageprocessing_ML_DL_Labs | /Morphologylab.py | 8,740 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 24 14:13:18 2020
@author: Abdul Qayyum
"""
#%%
# source https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_morphological_ops/py_morphological_ops.html
#Morphological Transformations
#Goal
#In this Lesson
#We will learn different ... |
4ed37047b495f7a99cc64d69e35ead3f38f26042 | saruns/updates | /oct13-14/chapter11/exrsce.11.4.py | 373 | 3.53125 | 4 | import sys
def revlook(x):
d = dict()
for f in x:
if f not in d:
d[f] = 1
else:
d[f] = d[f] + 1
print "your dictionary is",d
b = int(input("Enter your key-vlue: "))
m = []
n = []
for i in d:
if d[i] == b:
m.append(i)
if len(m) == 0:
print n
else:
print m
a = raw_input("Enter your string: ")
... |
2d930f23261eb0006c5450cfd24a7374cdb69470 | saruns/updates | /oct28-29/exc14.1.py | 233 | 3.734375 | 4 | import sys
import os
def walk(x):
b = os.listdir(x)
for f in b:
c = os.path.join(x,f)
if os.path.isfile(c):
print c
else:
walk(c)
a = raw_input("Enter your directory name: ")
walk(a)
if __name__ == "__walk__":
walk(a)
|
e2504e2954cbe80f1826e09b27e5d8b676e6b78b | wryoung412/cs224n_nlp | /assignment1/q2_neural.py | 5,910 | 3.65625 | 4 | #!/usr/bin/env python
import numpy as np
import random
from q1_softmax import softmax, softmax_grad
from q2_sigmoid import sigmoid, sigmoid_grad
from q2_gradcheck import gradcheck_naive
def forward_backward_prop(X, labels, params, dimensions, debug=False):
"""
Forward and backward propagation for a two-laye... |
0bfae3dac43bd698cf3420da51539b6eff6ce712 | KrisOP/python | /for.py | 510 | 3.984375 | 4 | for i in ["Primavera","verano","otonio","invierno"]:
print ("Hola ", end=" ")#no haga un salto de linea en la siguiente interaccion
email=False
contador=0
miEmail=input("ingrese su correo ")
for i in miEmail: #recorre caracter a caracter
if (i=="@" or i=="."):
contador=contador+1
"""if email:#es ... |
91b09c48f6785ea509ea2a196c4d96123e82dcc0 | KrisOP/python | /poo.py | 2,094 | 3.765625 | 4 | class Coche():
def __init__(self):#constructor de la clase (estado inicial de la clase)
self.__largoChasis=250
self.__anchoChasis=120
self.__ruedas=4 #encapsulando la variable rueda//NO PUEDE SER ACCESIBLE DESDE FUERA DE LA CLASE(MODIFICAR)
self.__enmarcha=False
#declaracio... |
3d40a173912c636f6f0db4ce1af6f1b3a64ad51c | NightDriveraa/Python-100-Days | /Days06/判断回文素数.py | 179 | 3.953125 | 4 | from 判断素数 import is_prime
from 判断回文数 import is_palindrom
num = int(input('num: '))
if is_prime(num) and is_palindrom(num):
print('Yes')
else:
print('NO') |
b012db073f4008b892e85ebf43a3139013f961c6 | NightDriveraa/Python-100-Days | /Days08/Restaurant.py | 1,002 | 3.75 | 4 | class Restaurant():
def __init__(self,restaurant_name,cuisine_type):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
print(str(self.restaurant_name))
print(str(self.cuisine_type))
def open... |
7f302386f2db6aad50c97c9e4338affb99e43fe1 | Pontem-Lab/Python | /clock.py | 2,036 | 3.609375 | 4 | #----------------------------------------
#---------- Scedule ---------------------
# This program about the week planning
# exams, but it is can use for another
# purpose.
# import library about date and browser,
# becouse me take week day give x variable
# and then compare with all week days
# Open browser and open ... |
b3eaff36ef9ec1be987dd304541536b77301aa71 | ddbs/tpy | /notes/01_data_types.py | 2,135 | 4.5 | 4 |
##############################################################################
# STRINGS
##############################################################################
print("{0} don't think it {1} like it is, but it {2}".format("They", "be", "do"))
print("Yar matey!"[0])
########################################... |
5ad3e6a33cf9c73b2f47b098d9888c934986d753 | ed18s007/Leetcode_Problems | /287.py | 248 | 3.75 | 4 | # Find the duplicate num
def find_duplicate(inp_list):
n = len(inp_list)
sum_total = (n-1)*(n)/2
sum_list = 0
for i in inp_list:
sum_list += i
return sum_list - sum_total
print(find_duplicate([1,3,4,2,2]))
print(find_duplicate([3,1,3,4,2])) |
af044b723e36388e50f4aeb11d53add9752f8b0f | krissik/learning-asyncio | /src/asyncio_wait.py | 835 | 3.765625 | 4 | # https://pymotw.com/3/asyncio/control.html
"""
wait() can be used to pause one coroutine until th other background
operations complete - if order of execution doesn't matter.
"""
import asyncio
async def phase(i):
print('in phase {}'.format(i))
await asyncio.sleep(0.1 * i)
print('done with phase {}'.fo... |
086dd628a9135cf6074a092937535f959e674cfe | Runib/PythonSimpleExercises | /Lab1Code/Exercise7.py | 252 | 4.125 | 4 | def CheckIsVowel(letter):
vowelTurle = {'a','e','i','o','u','A','E','I','O','U','y','Y'}
if letter in vowelTurle:
print("This letter is vowel")
return True
else:
print("This letter is not vowel")
return False |
4280147b5c6b37281abd46b7a50a36fa99be1f9d | Runib/PythonSimpleExercises | /Lab1Code/Exercise11.py | 150 | 3.546875 | 4 | def InsertStringInMiddle(insertString, basicString):
return basicString[:(len(basicString)/2)] + insertString + basicString[(len(basicString)/2):] |
d2261e4e80e9d25f52fbdee9510271cced248d63 | StetHD/bolt | /bolt/tasks/bolt_mkdir.py | 743 | 3.90625 | 4 | """
mkdir
-----
Creates the directory specified, including intermediate directories, if they
do not exist::
config = {
'mkdir': {
'directory': 'several/intermediate/directories'
}
}
"""
import logging
import os
class ExecuteMKDir(object):
def __call__(self, **kwargs):
... |
522179ce52f9df2372134eb33f5500623ea91c7d | awenhaowenchao/data-structure | /src/chaptor_04/bitree_after_search.py | 372 | 3.984375 | 4 | #后序遍历
from src.chaptor_04.binary_tree import BinaryTree, Node
def after_search(node: Node):
if node.left != None:
after_search(node.left)
if node.right != None:
after_search(node.right)
if node != None:
print(node.value)
root=Node('D',Node('B',Node('A'),Node('C')),Node('E',rig... |
784d41577a9dcb986640e854c1248fc5042a1805 | wenyuan-wu/xuelun_hs_2020 | /mock_exam/tempeture_test.py | 996 | 3.5625 | 4 | import random
from typing import List
class Temperature:
def __init__(self, degree: float):
self.__degree = degree
def get_celsius(self):
return self.__degree
def get_fahrenheit(self):
return round((self.__degree * (9/5) + 32), 2)
class Series:
def __init__(self, temp_list:... |
c4ddbf34792bd19a690eb71a5b8c70243f878011 | oulily/Adobe-SIP-2016 | /Week_3/Flower.py | 404 | 3.6875 | 4 | # attr: color, size, height, x-position, y-position, speed of growth
# methods: draw, grow, fall
import pygame
import random
class Flower():
def __init__(self, color, size, height, x, y, speed):
self.color = color
self.size = size
self.height = height
self.x = x
self.y = y
self.speed = speed
#methods
... |
f821cd87d5a6437907b5d8fd4844666a2c2cf8de | oulily/Adobe-SIP-2016 | /Week_1_2/Hangman.py | 203 | 3.640625 | 4 | import random
word = ["protagonist", "periodic", "fertilizer", "badmouth", "artificial", "hairstyle"]
random_word = random.randint(0, len(word))
print(word[random_word])
print("Guess a letter:")
|
b06b5ca67cfb73cd310fe54d6e2df9441ab42610 | jusdesoja/sushi_preference | /sushiCode/simlify_labels.py | 592 | 3.71875 | 4 | #!/usr/bin/env python
# encoding: utf-8
import numpy as np
def simplify_labels(labels):
n = len(labels)
sorted_ind = np.argsort(labels)
label_sorted = np.sort(labels)
simple_labels = np.zeros((n), dtype = int)
simple_labels[sorted_ind[0]] = 0
for i in range(1, n):
if label_sorted[i] == ... |
d068badfd2ac81f9a0f0f2001f4a640acdd51378 | Ranjith-kumar27/Youtube | /main.py | 1,221 | 3.515625 | 4 | # pip install pafy
#pip install youtube_dl
import pafy
from tkinter import *
def getMetaData(video):
print("Video Details are ---")
print("video title : ",video.title) #print title
# print view count
# print(f"Total views : {video.viewcount}| video lenght : {video.lengh} secounds")
print("channel... |
2fd623d0ce8c225a105c3ce8c100fa506816e31f | victornuness/Data-Science-Using-Python | /Exercico_calculadora.py | 646 | 4 | 4 | def calculadora(n1,n2,operador):
if operador == '+':
resultado=n1 + n2
print(resultado)
if operador == '-':
resultado=n1 + n2
print(resultado)
if operador == '*' or operador == 'x':
resultado=n1 * n2
print(resultado)
if operador == '/' :
... |
5b8772b734a8fdce92ba2b07a0069602774e0a34 | daniu101/PythonBasics | /Structure/For.py | 236 | 3.640625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8
string = 'abc'
for letter in string:
print ('letter:', letter)
language_list = ["python", 'java', 'matlab']
for language in language_list:
print ('language:', language)
|
e1f10594a8e3f9ae865774d7e57c68955ba2c481 | thesadru/pyaww | /pyaww/console.py | 1,635 | 3.59375 | 4 | from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .user import User
class Console:
"""All methods of a console."""
id: int
user: 'User'
executable: str
arguments: str
working_directory: str
name: str
console_url: str
console_frame_url: str
def __init__(self, resp: d... |
48ea55d5651c682c148850f7ac2a580b1c4c128a | hussein-kaplan/python-examples | /odd-even.py | 460 | 3.953125 | 4 | # Hussein kaplan - حسين قبلان
# برنامج بايثون للتحقق مما إذا كان الرقم فرديًا أم زوجيًا
# يكون الرقم عدد زوجي إذا كانت تقبل القسمة على 2 و الباقي 0.
# إذا كان الباقي 1 ، فهو رقم فردي.
num = int(input("اكتب الرقم: "))
if (num % 2) == 0:
print("{0} هو زوجي".format(num))
else:
print("{0} هو فردي".format... |
4b672fe0f3937ec063167b94919d269a4989a7ae | hussein-kaplan/python-examples | /prime-number2.py | 844 | 3.96875 | 4 | # Hussein kaplan - حسين قبلان
# معرفة برمجيا بلغة البايثون اذا كان الرقم عدد اولي ام لا
# الطريقة الثانية
num = 79
# اذا كنت تريد اخد الرقم من المستخدم تستخدم هذا السطر
#num = int(input("ادخل الرقم: "))
# الاعداد الاولية تكون اكبر من واحد
if num > 1:
# التحقق من العوامل
for i in range(2, num)... |
ea3c246942445c67e00ddf0099015dbcd7f05007 | hussein-kaplan/python-examples | /shuffle-card.py | 682 | 3.609375 | 4 | # --- Hussein kaplan - حسين قبلان
# --- برنامج بايثون لخلط أوراق اللعب عشوائيًا
# --- (random)في هذا البرنامج ، ستتعلم خلط مجموعة أوراق اللعب باستخدام وحدة عشوائية.
# --- استدعاء المكتبات المطلوبة
import itertools, random
# --- صنع مجموعة من البطاقات
deck = list(itertools.product(range(1,14),['سيناك',... |
ee5a0641dacba75f65337df4247eb10d38161784 | AprilCCC/PK-Group5 | /pkmodel/protocol.py | 3,112 | 4.1875 | 4 | class Protocol:
"""The Protocol class holds the pharmacokinetic parameters related to
the dose and time span of the dose. It contains a method to return a
dose function for the chosen parameters.
"""
def __init__(self, initial_dose: float = 1.0, time_span: float = 1.0):
"""Initialises a prot... |
60d81070e257c5d35ebde1deb7d8c3e5cef10f02 | souvikb07/Data-Structures-and-Algorithms | /Course_1_Algorithmic Toolbox/Week - 5/primitive_calculator/primitive_calculator.py | 638 | 3.59375 | 4 | # Uses python3
import sys
def optimal_sequence(n):
pathes = [None] * (n+1)
pathes[1] = [1]
for i in range(1,n):
if pathes[i] is None: continue
if i+1<=n and (pathes[i+1] is None or len(pathes[i+1])>len(pathes[i])+1):
pathes[i+1] = pathes[i]+[i+1]
if 2*i<=n and (pathes[2*i] is None or len(pathes[2*i])>len(... |
351e22c236952fe879479b8e4516bb3f1c17c4a0 | pshingavi/Python-Essential-Training | /Quick Start/mvc_oop.py | 1,859 | 4.03125 | 4 | #!python3
__author__ = 'Preetam'
'''This is a demo to show MVC pattern in python'''
# -- VIEW -- Seen from the AnimalActions class
class AnimalActions:
# Quack
def quack(self):
return self._do_action("quack")
# Bark
def bark(self):
return self._do_action("bark")
# Feather
de... |
4e0361647b11f36b9dbb45c5cc23833b064273ce | pshingavi/Python-Essential-Training | /Quick Start/function.py | 484 | 4.28125 | 4 | #!python3
__author__ = 'Preetam'
'''This is a demo for a reusable function
Write a function to print prime numbers'''
def is_prime(n):
if n == 1:
print("1 is special")
return False
for x in range(2,n):
if (n % x) == 0:
# not prime
print("{} is {} x {}".format(n... |
487699fdc410b2bcad83ddc0df79ddf7c8ceee74 | pshingavi/Python-Essential-Training | /Quick Start/inherit_polymorph.py | 1,789 | 4.5625 | 5 | #!python3
__author__ = 'Preetam'
'''This is a demo to show inheritance and data abstraction in python'''
# Class definition for AnimalActions
class AnimalActions:
def quack(self):
return self.strings["quack"]
def feathers(self):
return self.strings["feathers"]
def bark(self):
r... |
0d554af5be386e49b48f1ee104e46ef4aeef4d1f | Fred-Oco/Project | /blackjack.py | 3,342 | 3.765625 | 4 | import random
class gamble:
def __init__(self, money, chip):
self.chip = int(chip)
self.money = int(money)
self.player_total = 0
self.admin_total = 0
self.player_card = []
self.admin_card = []
def start(self):
check = False
while check is False:... |
f78c988fc9e7327a7669f5c4c8512e006a54b8c5 | Ibzan/Progra | /operaciones 2 NO BORRAR.py | 315 | 4.03125 | 4 | #entradas: tres números
#salidas: producto y resultado
#restricciones: solo números enteros
def operaciones(a,b,c):
resul_1 =a+b+c/3
resul_2 =a*b*c
if(a+b>c):
print("El promedio es: ",resul_1,"y el producto es: ",resul_2)
else:
print("La operacíon no es posible")
|
d4cbe872419436831d2bc125901a39d9ce226bc9 | itshimanirajput/MSCW_Python_ML_DS_ | /CollectionDemo.py | 1,016 | 4.25 | 4 | #WAP to implement Collection
BookList = ["Wings of Fire","The monk who sold his Ferari","Hamlet"]
print(BookList)
def Display():
for book in BookList:
print(book)
#Displaying elements of list
for book in BookList:
print(book)
#Adding more books
BookList.append("You can Win")
BookLis... |
44aef9d5faa5d1ccf8bf5b4d8f1604d6b451c3e2 | Abitgor/rand_proc | /task7.py | 1,370 | 3.53125 | 4 | from libs import *
class Circle:
def __init__(self, radius, x, y, z):
self.radius = radius
self.x = x
self.y = y
self.z = z
def exist_in_circle(self, x1, y1, z1):
if (self.x - x1) * (self.x - x1) + (self.y - y1) * (self.y - y1) + (self.z - z1) * (
self.... |
5ab98f68dd816c811291e0602631e32ceae442f3 | pmnyc/Data_Engineering_Collections | /systematicinvestor_quantandfinancial/quant/interpolation.py | 505 | 3.53125 | 4 | # Copyright (c) 2012 Quantitative & Financial, All rights reserved
# www.quantandfinancial.com
def interpolate(xy, x):
def find_left(xy, x):
for xy in reversed(xy):
if xy[0] <= x:
return xy
def find_right(xy, x):
for xy in xy:
if xy[0] >= x:
return xy
if x <= xy[0][0]: # x is lower t... |
9c5a019865b8b01ac3f1cf55c71406174126bf35 | nateroling/thunderbird-contacts-to-outlook | /convert.py | 3,766 | 3.8125 | 4 | import sys
import csv
# Columns that will be written to the output csv.
OUTLOOK_COLUMNS = [ 'First Name', 'Last Name', 'Name',
'E-mail Address', 'E-mail 2 Address',
'Business Phone', 'Home Phone', 'Business Fax',
'Pager', 'Mobile Phone',
'Home Street 1', 'Home Street 2', 'Home City',
... |
cfa1199bd9d5feabc3ae92d1fb789ff36a1e2a69 | minchen8683090/pythonDemo | /mergeArrays.py | 590 | 3.921875 | 4 | """
合并两个排序的整数数组A和B变成一个新的数组
"""
def merge_arrays(a, b):
if a is None:
return b
if b is None:
return a
if len(a) > len(b):
big, small = a, b
else:
big, small = b, a
i = 0
while len(small) > 0:
value = small[0]
j = len(big)
... |
8bf14aeb495d0a15242de6b724ef05f9da14bb72 | lihsur22/Pro105 | /st_dev.py | 590 | 3.828125 | 4 | import csv
import math
with open('data.csv',newline="") as f:
reader = csv.reader(f)
file_data = list(reader)
file_data.pop(0)
def mean(data):
n=len(data)
total= 0
for x in data :
total += int(x[1])
mean = total / n
return mean
squared_list = []
for number... |
665a65c3757fef90acdb3f1c12489e8a5327241a | osuzdalev/Innopolis | /Information Theory/Project 2/sfe.py | 3,270 | 3.59375 | 4 | from math import log2
import random as r
class SFE:
def __init__(self):
self.byte_size = 8
# converts float to binary
def float2bin(self, x, bit='0.'):
LIM = 16
if len(bit) == LIM:
return float(bit)
if 2 * x > 1:
bit += '1'
return self.f... |
fb835abf30bbbc98c9f1d44d1586402a959fdfca | AaronTengDeChuan/leetcode | /leetcode/109.ConvertSortedListToBinarySearchTree.py | 962 | 3.984375 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def bottom_to_up_... |
e56c17468b2282bc3036b566c8ff9763617f7edd | AaronTengDeChuan/leetcode | /leetcode/41.FindMissingPosition.py | 747 | 3.59375 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Solution(object):
def firstMissingPositive(self, nums):
"""
:type num: List[int]
:rtype: int
"""
size = len(nums)
if size == 0:
return 1
for i in range(size):
while nums[i] != i... |
55c2dd011dd5f0a43ec735e361fb730dda3de884 | AaronTengDeChuan/leetcode | /leetcode/33.SearchInRotatedSortedArray.py | 1,118 | 4.0625 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Solution(object):
def search(self,nums,target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
left = 0
right = len(nums) - 1
while left <= right:
mid = (left + right)/... |
13ca90d73c1f60d1703231a3d5957ecbd172fd4f | AaronTengDeChuan/leetcode | /leetcode/36.ValidSudoku.py | 1,549 | 3.5625 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Solution(object):
def isValidSudoku(self, board):
"""
:type board: List[List[str]]
:rtype: bool
"""
for i in range(9):
tmp = []
for j in range(9):
if board[i][j] != '.' and boar... |
1b5332d72a55af8ce246201e6aac61a62d2e4a92 | AaronTengDeChuan/leetcode | /leetcode/63.UniquePathsII.py | 1,094 | 3.65625 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Solution(object):
def uniquePathsWithObstacles(self, obstacleGird):
"""
:type obstacleGird: List[List[int]]
:rtype: int
"""
if len(obstacleGird) == 0:
return 0
for i in range(len(obstacleGird)):
... |
73dd1d66674590e41ffa2b19c96c1840cd27e987 | AaronTengDeChuan/leetcode | /leetcode/57.InsertInterval.py~ | 710 | 3.953125 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Interval(object):
def __init__(self, s = 0, e = 0):
self.start = s
self.end = e
class Solution(object):
def insert(self, intervals, newInterval):
"""
:type intervals: List[Interval]
:type newInterval: Interval
... |
97cc985083c8ea990b54bea3f0b8a51ed0819006 | AaronTengDeChuan/leetcode | /leetcode/37.SudokuSolver.py | 2,092 | 3.671875 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Solution(object):
def searchValidNumber(self, board,position):
tmp = ['1','2','3','4','5','6','7','8','9']
for i in range(9):
if board[position[0]][i] != '.':
tmp.remove(board[position[0]][i])
for i in ran... |
279d89e054105304eb9a6f5cfd6f7bb1d9cca5c1 | AaronTengDeChuan/leetcode | /leetcode/50.Pow_x^n.py~ | 625 | 3.640625 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Solution(object):
def myPow(self, x, n):
"""
:type x: float
:type n: int
:rtype: float
"""
flag = False
if n < 0:
flag = True
n = -n
result = 1.0
curPow = x
... |
b57ef1936c05c263030644d26b6ae2d03309acb3 | AaronTengDeChuan/leetcode | /leetcode/88.MergeSortedArray.py | 696 | 4.1875 | 4 | #!usr/bin/env python
#-*-coding:utf-8-*-
import sys
class Solution(object):
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: void Do not return anything, modify nums1 in-place instead.
""... |
b4adec001cf04cc1b8ac22faa559608c9df7e1c7 | zoobot/datastructures | /tree2.py | 2,546 | 3.90625 | 4 | class BinaryTree(object):
def __init__(self,rootObj):
self.key = rootObj
self.leftChild = None
self.rightChild = None
def insertLeft(self, newNode):
if self.leftChild == None:
self.leftChild = BinaryTree(newNode)
else:
t = BinaryTree(newNode)
t.leftChild = self.leftChild
... |
3f3f6ca314655c2df4197332b26f51381e818a2f | ElizabethHerrera/ProgramacionAvanzada | /Actividad1.py | 3,855 | 3.828125 | 4 | import re
import unicodedata
# Elaborar un programa que pregunte tres datos: matricula, nombre y correo
# [X] la matricula es un numero de 7 posiciones,
# [X] el nombre es un texto que contiene letras mayusculas y espacios, sin acentos no menor 10 a mayor a 40
# [X] el correo es un correo con formato valido
#Funcion ... |
6e948e5e7b44351eb75450f52bd8b2e2853485ce | kbtania/Labs | /lab6/Програми/lab6_task2.py | 459 | 3.75 | 4 | from math import cos
i = int(input('i = '))
list_element = []
numerator = 1
denominator = 0
sum_positive = 0
sum_negative = 0
for x in range(1, i + 1):
product = (2 * x - 1) * (cos(x))
denominator += x ** 2
numerator *= product
element = numerator / denominator
if element > 0:
sum_positive ... |
90d8782a997720fc29d491bfbfe31898011b5397 | kbtania/Labs | /lab7/tasks/lab7_3.py | 933 | 3.859375 | 4 | # Дано матриці А і В. Знайти С = АхВ
i1 = int(input('Rows 1: ')) # count of rows in 1 matrix
j1 = int(input('Columns 1: ')) # count of columns in 1 matrix
i2 = int(input('Rows 2: ')) # count of rows in 2 matrix
j2 = int(input('Columns2: ')) # count of columns in 2 matrix
if j1 == i2:
A = [[int(input('El [{0}]... |
4ed1b3c266e0623404192e6a80cffeef5ba114f9 | kbtania/Labs | /lab11/tasks/lab11.py | 1,362 | 4.21875 | 4 | from math import sqrt
class Triangle:
def __init__(self, a, b, c):
if a < 0 or b < 0 or c < 0:
raise Exception('Side cannot be negative')
self.a = a
self.b = b
self.c = c
def set_side(self):
self.a = int(input('Side a = '))
self.b = int(input('Side b... |
9f8fa0665af51df181c8fa55d03245e915612ab6 | kbtania/Labs | /lab_map_filter_reduce/Tasks/map1.py | 375 | 4 | 4 | # Дано два вектори (списки з координатами – дійсними числами).
# Знайти суму векторів.
vector1 = [float(input('Coordinate of vector1: ')) for x in range(3)]
vector2 = [float(input('Coordinate of vector2: ')) for x in range(3)]
sum_vector = map(lambda x, y : x + y, vector1, vector2)
print(list(sum_vector)) |
f8c362eea8f1bc4d02720f6caded0871d5a06eda | kbtania/Labs | /lab5/Програми/5_task2.py | 283 | 3.78125 | 4 | '''Визначення найменшої цифри в числі'''
number = int(input('Введіть число: '))
minim = 10
while number>0:
if number%10 < minim:
minim = number%10
number = number//10
print('Найменша цифра = {0}'.format(minim))
|
befc7375a114754437b70adf118a443eae813450 | AshwathSalimath/Pramp-Python-Solutions | /Array Index - Element Equality/binary-search-based-solution.py | 353 | 3.875 | 4 | def index_equals_value_search(arr):
st = 0
ed = len(arr)
while st<=ed:
mid = (st+ed)/2
if(arr[mid] == mid):
if(arr[mid-1] == (mid -1)):
ed = mid - 1
else:
return mid
elif (mid > arr[mid]):
st = mid + 1 ## Going right
else:
ed = mid - 1 ## G... |
47769f75315e6198799ed2db5d2e0c9f752272fa | mrbenji/cid | /bdt_utils.py | 2,563 | 3.6875 | 4 | def pretty_money(amount):
"""
Return integer or float as US-currency-formatted string.
Ex. 1289 -> "$1,289.00" and 75.98 -> "$75.98"
:param amount: integer or float to format
:returns: formatted string
"""
return "${:,.2f}".format(amount)
def pretty_table(data, padding=2):
"""
"Pre... |
277e25b2e64378f23f994919e3ec0fafde25a9e7 | MasterKali06/Hackerrank | /Problems/easy/Implementation/hurdle_race.py | 669 | 4 | 4 | '''
A video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights,
and the characters have a maximum height they can jump. There is a magic potion they can take that will
increase their maximum jump height by 1 unit for each dose.
How many doses of the poti... |
2a58fa6f8ee1fb13b284ef7b0f29c24b94574630 | MasterKali06/Hackerrank | /Problems/easy/Implementation/grading_students.py | 768 | 3.921875 | 4 | '''
HL University has the following grading policy: Every student receives a grade in the inclusive range of 0 - 100
Any grade less than 40 is a failing grade.
Sam is a professor at the university and likes to round each student's grade according to these rules:
If the difference between the grade and t... |
38541b1b19bb12fdf1206ad41a36e0e3f8e4ebb6 | MasterKali06/Hackerrank | /Problems/easy/Strings/tow_characters.py | 1,263 | 3.84375 | 4 | """
https://www.hackerrank.com/challenges/two-characters/problem
"""
from itertools import combinations
def alternate(s):
# first we make a list of uniq characters
uniq = []
for i in s:
if i not in uniq:
uniq.append(i)
valid_cases = [] # a list for adding the valid cases
... |
7751ac7e9a70510aa45b4b3d0b76ca81abe5c54c | MasterKali06/Hackerrank | /Problems/easy/Warmup/diagonal_diffrence.py | 334 | 4.03125 | 4 | '''
Given a square matrix, calculate the absolute difference between the sums of its diagonals.
'''
# example
vari = [[11, 2, 4,],[4, 5, 6],[10, 8, -12]]
def dD(arr):
a = 0
b = 0
length = len(arr[0])
for i in range(length):
a += arr[i][i]
b += arr[i][(length-i-1)]
print(abs(a-b... |
a08af4e982f22cd6a2778f06f6897103f26bb4c4 | MasterKali06/Hackerrank | /Problems/easy/Implementation/jumping_on_the_clouds2.py | 448 | 3.859375 | 4 | '''
https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem
'''
c = [0, 0, 0, 0, 1, 0]
c1 = [0, 0, 0, 1, 0, 0]
def jumpingOnClouds(c):
count = 0
j = 0
i = 0
while j < len(c) - 3:
if c[i + 2] == 0:
count += 1
j += 2
i += 2
else:
... |
d6a66cdd5dc3380267ba5fc2aa08c76cab55f257 | MasterKali06/Hackerrank | /Problems/medium/Implementation/non_divisible_subset.py | 1,449 | 3.859375 | 4 | '''
Given a set of distinct integers, print the size of a maximal subset of S where the sum of any 2 numbers
in S' is not evenly divisible by k.
S: an array of integers
k: an integer
'''
def nonDivisibleSubset(k, s):
sums = []
while len(s)>1:
first = s[0]
s.remove(first)
... |
b5b007847dbfb06870b4f65e4d12f09a598a79c2 | MasterKali06/Hackerrank | /Problems/easy/Implementation/chocolate_feast.py | 550 | 3.78125 | 4 | """
https://www.hackerrank.com/challenges/chocolate-feast/problem
int n: Bobby's initial amount of money
int c: the cost of a chocolate bar
int m: the number of wrappers he can turn in for a free bar
"""
def chocolateFeast(n, c, m):
count = 0
f_wrapper = n // c
count += f_wrapper
# e... |
781ad413bbffc4a8a5be82b3ae16113c57831643 | MasterKali06/Hackerrank | /Problems/easy/Implementation/halloween_sale.py | 478 | 3.78125 | 4 | """
https://www.hackerrank.com/challenges/halloween-sale/problem
int p: the price of the first game
int d: the discount from the previous game price
int m: the minimum cost of a game
int s: the starting budget
"""
def howManyGames(p, d, m, s):
count = 0
while s >= m and s >= p:
... |
5379e2bea9edc2603b0760d72dc08bd88ddfde1f | suri040/study | /search.py | 229 | 4.21875 | 4 | #!/bin/python3
string = 'Hi My name is surender'
a= input("Kindly pur your string for your validation")
print(a)
if (string.find(a)):
print ( "My name is ***'surender'*** ")
else:
print ( " Name is not found in string")
|
8a8da2df282637cd894d198ef7622f0258a6bb92 | aditya1rawat/projecteuler | /p4.py | 262 | 3.59375 | 4 | # # # Problem 004: Largest Palindrome Product # # #
num = 0
for x in range(1000, 100, -1):
for y in range(x, 100, -1):
prod = x * y
if prod > num:
s = str(x * y)
if s == s[::-1]:
num = x * y
print(num) |
1200024c995c5b90918312459318795643bb16c5 | yash2029/cses-solutions | /BASIC/bubblesort.py | 285 | 3.875 | 4 | def swap(arr,i,j):
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
def bubbleSort(arr,n):
for i in range(0,n-1):
for j in range(0,n-i-1):
if arr[j] > arr[j+1]:
swap(arr,j,j+1)
return arr
arr = list(map(lambda x: int(x), input().split(' ')))
print(bubbleSort(arr,len(arr)))
|
e788adb264d6b223497375cb70c50425efcb5e71 | OsmanC4hit/PythonNotlarm | /18-hangman.py | 1,966 | 3.5625 | 4 | import random
import secrets
print("""
/\ /\__ _ _ __ __ _ _ __ ___ __ _ _ __
/ /_/ / _` | '_ \ / _` | '_ ` _ \ / _` | '_ \
/ __ / (_| | | | | (_| | | | | | | (_| | | | |
\/ /_/ \__,_|_| |_|\__, |_| |_| |_|\__,_|_| |_|
|___/
""")
name = input("Adınızı giri... |
f85f3ee33927e75bfc60619ed0d27098edb1f8e4 | khezam/Learning_process | /recursion/recur-selection-sort/recu_selection.py | 338 | 3.609375 | 4 | def sorting(arr, i, h):
if i >= h:
return arr
j = i
curr = j
while j < h:
if arr[curr] > arr[j + 1]:
curr = j + 1
j += 1
if curr != i:
arr[i], arr[curr] = arr[curr], arr[i]
return sorting(arr, i + 1, h)
sorting([10,2,9,8,7,6,5,4,3,1], 0, len([10,2,9,8,... |
4e9133cccdf03738d6e0284b6f212cc0376f7595 | khezam/Learning_process | /sorting/bubble_sort/bubble_sort3.py | 251 | 3.875 | 4 | def bubble_sort(arr):
n = len(arr) - 1
while n:
i = 0
while i < n and arr[i] > arr[i + 1]:
arr[i], arr[i + 1] = arr[i + 1], arr[i]
i += 1
n -= 1
return arr
bubble_sort([10,9,8,7,6,5,4,3,2,1]) |
a69bdf85ba9874e74c5ff2e1373336e104602c02 | khezam/Learning_process | /recursion/recBubbleSort/recur-right-side.py | 298 | 3.59375 | 4 | def bubble(arr, i, h):
if i >= h:
return arr
j = h
while j > i and arr[j] < arr[j - 1]:
arr[j], arr[j - 1] = arr[j - 1], arr[j]
j -= 1
return bubble(arr, i + 1, h)
bubble([10,9,8,7,6,5,4,3,2,1], 0, len([10,9,8,7,6,5,4,3,2,1]) - 1) |
fc5f60335fbde6d866f232cb723cfaec30c26094 | khezam/Learning_process | /recursion/recInsertionSort/start-left.py | 265 | 3.6875 | 4 | def insertion(arr, i, h):
if i >= h:
return arr
j = i
while j > 0:
if arr[j] < arr[j - 1]:
arr[j], arr[j - 1] = arr[j - 1], arr[j]
j -= 1
return insertion(arr, i + 1, h)
insertion([5,4,3,2,1], 1, len([5,4,3,2,1])) |
9b9aee7ebdf4c72e3e1e7550966c08e37f41a017 | khezam/Learning_process | /sorting/bubble_sort/bubble_sort2.py | 618 | 4.28125 | 4 | def bubble_sort(arr):
"""This function is O(n^2)"""
n = len(arr) - 1
i = 0
"""For every iteration of the parent iterator subtract 1 from the len of arr"""
while i < n:
j = 0
while j < n - i:
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
j += 1
i += 1
return arr
def linear_bubble... |
80395e47fe58e7e0a374d0245c5ce86dba8a09f6 | khezam/Learning_process | /sorting/bubble_sort/bubble-sort1.py | 481 | 4.03125 | 4 | def swapItems(arr):
subPointer = 0
subLoopCount = len(arr) - 1
while subPointer < subLoopCount:
cp = subPointer + 1
if arr[subPointer] > arr[cp]:
temp = arr[cp]
arr[cp] = arr[subPointer]
arr[subPointer] = temp
subPointer += 1
return arr
def bubbleSort(arr):
loopCount = len(arr) - 1
i = 0
while i... |
e01d5d139387a1a8e33523d72face13d341fd25b | khezam/Learning_process | /sorting/insertion-sort/insertion-sort2.py | 542 | 3.96875 | 4 | def insertion_sort(arr):
j = 1
while j < len(arr) - 1:
i = j - 1
# A copy of the pointer
# The reason why I have a copy of the pointer so I can decrement the copy of the pointer
subj = j
# Coming from right to left
while i > -1:
# if the copy of the pointer is less than the before the pointer
if ... |
ca8418d9bb7b0c790f1e93082ab25c7fd38b22f5 | limapvictor/backup-materias-antigas | /MAC110/P3/recursao_mergesort.py | 1,993 | 3.921875 | 4 |
""" Exemplo de algoritmo recursivo de ordenação: MergeSort
Ele se baseia na função intercala, que havíamos implementado
para a união de conjuntos representados em listas ordenadas.
"""
def intercala(v,a,b,c):
""" Intercala os conjuntos A = { v[i] | a<=i<b }
e B = { v[j] | b<=j<c }, copiando os val... |
27351d6b3462fb6abced916e66a365121413b633 | limapvictor/backup-materias-antigas | /MAC110/EP3/personagenss/personagem_02.py | 9,070 | 3.609375 | 4 | # flag para depuração
__DEBUG__ = False
# Variaveis globais (do módulo) que o mundo acessa para passar informações para a personagem.
global nFlechas
global mundoCompartilhado
global N
global mundo
global posicao
global orientacao
global alguemNaSala
global girouE
global andou
andou = False
girouE = False
girouD = ... |
96bcf0de6598ea6ff7b6e0d128b38fc057dd44b7 | dbuterin/Practice-Python | /ToDoApp/ToDoApp.py | 610 | 3.640625 | 4 | print "TODO aplikacija"
taskovi = {}
while True:
task = raw_input("Unesite task: ")
done = raw_input("Rijeseno (y/n): ").lower()
taskovi[task] = (done == "y")
print "Vas task %s" % task
jos = raw_input("Zelite li jos (y/n): ")
if jos.lower() != "y":
break
print "Rijeseni taskovi"
for... |
db3686967e801f28ca199839b8371876aca5f209 | punch2475-cmis/punch2475-cmis-cs2 | /simple.py | 618 | 4.21875 | 4 | import math
#pythagorean theorem
#a**2+b**2=c**2
def cal(legA, legB):
return math.sqrt((legA)**2+(legB)**2)
def output(Name,legA,legB,legC):
out = """
Hello {}, This program will help you solve triangle by using pythagorean theorem.
Shortest length of your triangle is{}
Second longest length of your triangle is ... |
19ef31bdeb35acb6435e8dc8f4ab5546d11c435c | punch2475-cmis/punch2475-cmis-cs2 | /pppkk.py | 2,620 | 4.25 | 4 | #this text game will help you determine which phone is best for you by answering 3 questions. So from this the program will use the input to calculate the phone that is best for he/she.
import random
def main():
Name= raw_input("Your name:")
phone= raw_input("Your current phone:")
afford= money()
use= rely()
p... |
326de3c99d0b2007139e30fd99ecd6a6b82bcb7a | xsauce/leetcode | /3_LongestSubstringWithoutRepeatingCharacters.py | 816 | 3.625 | 4 | def lengthOfLongestSubstring(s):
"""
:type s: str
:rtype: int
"""
longest_num = 0
hash_set = dict()
sp = 0
for ep, c in enumerate(s):
if c in hash_set:
longest_num = max(longest_num, ep - sp)
sp = max(sp, hash_set[c] + 1)
hash_set[c] = ep
retur... |
684c55fbecaa0228424c0f01732be2c6749b1f09 | xsauce/leetcode | /20_ValidParentheses.py | 741 | 3.84375 | 4 | # Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
#
# The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.
class Solution(object):
def isValid(self, s):
"""
:type s: str
... |
fda9782174ba472bf3d0efea3328783e8574c7c3 | syntacticsplenda/adventofcode2017 | /day6.py | 585 | 3.5 | 4 | import os,functools
def combine(list):
return functools.reduce(lambda x,y:x+y,list)
instructions = [l.split() for l in open('./input/{0}.txt'.format(os.path.basename(__file__)[:-3]))][0]
instructions = [int(x) for x in instructions]
history = []
steps = 0
while instructions not in history:
steps += 1
hi... |
ac0e1ebf2448e20a448f135827cd746d5c0e34d0 | LaurentLabine/fcc_demographic_data_analyzer | /demographic_data_analyzer.py | 4,802 | 4.1875 | 4 | import pandas as pd
data_url = 'https://raw.githubusercontent.com/LaurentLabine/fcc_data_analysis_python/main/demographic.csv'
def calculate_demographic_data(print_data=True):
# Read data from file
df = pd.read_csv(data_url)
df.info()
# How many of each race are represented in this dataset? This sho... |
b39abc40fdff77ed319322d2b1a8be47fc73e3ed | jessicabarnett8219/python-orientation-05classes | /employees.py | 2,341 | 4.25 | 4 | class Company(object):
"""This represents a company in which people work"""
def __init__(self, company_name, date_founded):
self.company_name = company_name
self.date_founded = date_founded
self.employees = []
def get_company_name(self):
"""Returns the name of the company""... |
399aaa8e6e873e598590b6df8d2a4c16cf17ab28 | ziggi0703/EKPyTools | /ekpytools/statistics.py | 2,822 | 3.859375 | 4 | #!/usr/bin/env python
from __future__ import division, absolute_import, print_function
import pandas as pd
import numpy as np
def weighted_mean(series, weights=None):
"""
Calculate the weighted mean of a series.
:param series: calculate mean of this series
:type series: pandas.Series
:param weig... |
2d9d3e2edc37473accaa62d0089b2b7aa24a84c0 | shivakrishna36/Python-Basics | /Demo1/lists.py | 262 | 3.8125 | 4 | A = [1,2,3,'hello world']
print(A[3])
A[1] = 'one'
print(A)
B = [[1,1,2,2],'one',1,('a','b')]
print(B[0][1])
#Dictionaries
nmes = { 'Age': 23,'name':'hero'}
print(nmes['Age'])#case-sensitive
#set example
Set = {1,1,2,3,33,2}
print(Set) |
60c552a3380720120b415b88f0bf81d7dc715675 | csev/class2go | /tools/SummarizeSurveyFromJSON.py | 2,384 | 4.03125 | 4 | """
Takes a text file for a particular survey with one JSON db entry from c2g_examrecords per line, and summarizes the results as a survey.
Args:
the filename of JSON strings
Returns:
text formatted with summarized results - text entries at the end, grouped by question. Eg:
question q02a
... |
2664cc93f10fbe30d8f6b0ab30d85cb5891ef44a | deanagan/py-graph-algorithms | /dijkstra_algorithm.py | 1,908 | 3.71875 | 4 |
# Difference to unweighted shortest path
# 1. Prefer this method when dealing with weighted edges as it enqueues neighbours based on the edge weight.
# 2. Calculates distance by adding weights.
# 3. Recalculates distance to visited nodes, updating if needed.
# 4. Re-enqueue distance if it is updated.
from queue import... |
dfd15cc7fa3fd6764f1eee99e3d35e0ea273a131 | supsomen/python-practice | /silky4.py | 133 | 3.8125 | 4 | lst=[]
print("Enter the size of the array")
n=int(input())
for i in range(n):
a=int(input())
lst.append(a)
print(lst)
|
4d6d68000d4861c29aeddcf601c9615051649d79 | chanaabramov/csci127-assignments | /exam_01/compress.py | 652 | 3.609375 | 4 | vowels = "aeiou"
def compress_word(w):
rest = w[1:]
first = w[0]
new_word = ""
new_word = new_word + first
for i in rest:
if i not in vowels:
new_word = new_word + i
return new_word
print (compress_word("apple"))
print (compress_word("audacious"))
print (compr... |
2cd7f927b413ccde40e182bf3be5c4ad7c4415ef | chanaabramov/csci127-assignments | /hw_08/counts.py | 1,333 | 3.75 | 4 |
import operator
def build_word_counts(words):
d={}
for word in words.split():
d.setdefault(word,0)
d[word]=d[word]+1
return d
def clean_data(s):
result=""
for letter in s:
if letter in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
result = result + le... |
36f978c7f9a5c8df2b9b3dcaa79e84bfc7c46ebd | chanaabramov/csci127-assignments | /lab_04/lady.py | 847 | 3.609375 | 4 |
testcases = ["RB_BY_YY", "XY_XY"]
for test in testcases:
b = test
newb= list(b)
countlist = []
empty_list = []
def sort(b):
val = "_"
for item in (newb):
if item == "_":
empty_list.append(item)
while val in newb:
newb.remove(val)
newb2 = sorted(newb)
return ... |
c4883d88a7ffd1f0715196c1308a9d56d51cdcd4 | MINHSKI/python_shapes | /shapes/chaos_game.py | 1,903 | 3.671875 | 4 | import random
from shapes.core.colors import Colors
from shapes.core.image import new_image, save_image
def draw_chaos_game(image_width=1080, image_height=1080, polygon_points=None, iterations=10 ** 5, color=Colors.white):
"""
:param image_width: the image width in pixels
:param image_height: the image ... |
88e91d8e8bb7d9a1395bad216e0a65fef25f2cdf | BarYar/Loop4 | /P615.5.py | 49 | 3.6875 | 4 | l=[1,2,3,4,5,6,7,8,9,10]
l3=l[:3]
print (l)
for i |
7a1826e8c7848e34a87ca7f57fdfa6bf9fffb5ae | BarYar/Loop4 | /D9.py | 1,893 | 4.125 | 4 | #Write a Python program to remove duplicate values from a Dictionary.
#Write a python program that creates a dictionary. Then it will create a new dictionary that will swap the keys and values in a dictionary (the key will become a value and vice versa)
#Write a python program that creates a dictionary that contains 5 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.