blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
e3fe746897f73d94b61d08af4e6591ede5d3dd27 | vivid-ZLL/tedu | /part_02_system_programming/part_2_1_data_base/day3/sort.py | 774 | 3.765625 | 4 | def choose(list_):
for r in range(len(list_)):
for c in range(r, len(list_)):
if list_[r] > list_[c]:
list_[r], list_[c] = list_[c], list_[r]
def bubble(list_):
for c in range(1, len(list_)):
for r in range(len(list_) - c):
if list_[r] > list_[r + 1]:
... |
ecdc0674ee3b9fdf8661101d0f32cc8571a578d7 | vivid-ZLL/tedu | /part_01_python_base/python_core/day6/homework04.py | 548 | 3.5625 | 4 | dict01 = {"城市": {"北京": {"景区": ["故宫", "天安门", "天坛"],
"美食": ["烤鸭", "炸酱面", "豆汁", "卤煮"]},
"成都": {"景区": ["九寨沟", "峨眉山", "春熙路"],
"美食": ["火锅", "串串香", "兔头"]}}}
for k in dict01["城市"]:
print(k + ":")
for k, v in dict01["城市"]["北京"].items():
print(" "... |
c7e712dd6a656f46ff0926753b19b8f4d4f4b376 | vivid-ZLL/tedu | /part_01_python_base/python_core/day5/__init__.py | 2,171 | 3.921875 | 4 | # for item in range(-1, -3, -1):
# print(item)
# list_name = ["1","2","3"]
# str_input = input("请输入姓名:")
# print(len(list_name))
#
# for item in list_name:
# if str_input == item:
# print("姓名已经存在")
# list1 = [800,[1000,500]]
# list2 = list1[:]
# list1[1][0] = 900
# print(list2[1][0])
# print(type("k")... |
bc278d6b4af5877775729bad7ab6159ef2ab7875 | vivid-ZLL/tedu | /part_01_python_base/python_core/day8/exercise 04.py | 450 | 3.53125 | 4 | def judge_list_same(list_target):
"""
判断列表中的元素是否重复
:param list_target: 目标猎豹
:return: 有重复返回True ,没有重复返回 False
"""
for r in range(0, len(list_target) - 1):
for c in range(r + 1, len(list_target)):
if list_target[r] == list_target[c]:
return True
return Fals... |
849adbaff220dbe1348922b9ecc3a62d504ea5bb | mcharanrm/problem_statements | /thinking_caps.py | 4,828 | 3.890625 | 4 | #!/usr/bin/env python3
#how did i come to know ??
#sunday, last week, i was asked to solve this puzzle.
#puzzle description ??
#each word has two + two blanks and you need to fill up
#with same pair of letters to form a word
#examples ??
#_ _ I _ _ <------ "ONION" is the right answer
#some background ??
#there is... |
94d2f15834ac0986e5ec5e0f2cbef6ef31766e49 | terpyPy/ciphers-in-python | /encryptText/CaesarCipher.py | 1,693 | 4.25 | 4 | #!/usr/bin/python3
#
# Author: Cameron Kerley
# Date: 6 Feb 2019
# Description: Caesar Cipher
# the string to be encrypted/decrypted
import pyperclip
import encryptText
import math
def ceaser(key, message:str, mode):
# set to 'encrypt' or 'decrypt'
# every possible symbol that can be encrypted
... |
eb0780e81078fcba8c0b0e0f5134609426f29e3b | neal-rogers/baseball-card-inventory | /Source Files/slice-by-index.py | 183 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Provides Napoleon's great statement."""
NAPOLEON = "Able was I, ere I saw Elba."
REVERSED = NAPOLEON[::-1].lower()
print REVERSED
|
f9b2831832ed9fe868787f110a2d22e933a5062a | abmeko37/pygame-starter | /main.py | 455 | 3.875 | 4 | import pygame # import library
pygame.init()
# Create the window
win = pygame.display.set_mode((800, 600))
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
# Game code starts here ---------------------
win.fill((0, 0, 0))
# Draw a rectangle
pygame.dr... |
fe86e93729b22ff4e3f3a422c1dab553e2a07e25 | guilherme-lima-santos/2020_02_08 | /3.py | 369 | 3.59375 | 4 | #
#Leia 1 valor inteiro N (2 < N < 1000). A seguir, mostre a tabuada de N:
#1 x N = N 2 x N = 2N ... 10 x N = 10N
#Entrada
#A entrada contém um valor inteiro N (2 < N < 1000).
#Saída
#Imprima a tabuada de N, conforme o exemplo fornecido.
n = int(input())
for i in range(1, 11):
... |
e421bd6604f94d1303c330fd55f046abebf51f1a | Chad-Current/py_data_science | /decorators.py | 3,267 | 3.984375 | 4 | # Implemented as callables that take a callable and return other callables
"""
Example of what is happenend
****Function Decorators
@my_decorator
def my_function(x,y):
return x + y ---> this is a returned function object which is then passed to
the function my_decorator(f):
... |
686e97d5e75bdc0630f8e8f015851a2cd78fbe6f | smita-09/python | /OOPs/Set1.1.py | 779 | 4.125 | 4 | class Person:
# Kind of constructor
def __init__(self, name):
self.name = name
# Function which says hi
def say_hi(self):
print("Hello, my name is {}".format(self.name))
me = Person("smita").say_hi()
# Another class
class CSStudent:
stream = "CS" # since for this variable we want i... |
11c1f8bd39afa8dac24f07b456c1fc12539f093d | NhanGiaHuy/CP1404_Pactical | /Prac_03/temperatures.py | 713 | 4.03125 | 4 |
def main():
celsius_temperature = float(input("Enter the temperature in Celsius format"))
fahrenheit_temperature = Celsius_to_Fahrenheit(celsius_temperature)
print(fahrenheit_temperature)
fahrenheit_temperature = float(input("Enter the temperature in Fahrenheit format"))
celsius_temperature = Fahre... |
5840e67f537664baf6822973f40dd5f3879624d3 | NhanGiaHuy/CP1404_Pactical | /Prac_01/shop_calculator.py | 510 | 3.875 | 4 | def main():
list_price = []
total = 0
number_item = int(input("Enter Number of Item: "))
while number_item <= 0:
print("invalid Number!")
number_item = int(input("Enter Number of Item: "))
for i in range(number_item):
price = float(input("Price of Item: "))
list_price... |
3b02c77d7d6a9f95672bccf07ba52a0574868546 | NhanGiaHuy/CP1404_Pactical | /Prac_06/car_driving_simulator.py | 2,117 | 4.25 | 4 | from Prac_06.car import Car
def main():
print("Let's drive!")
car_name = str(input("Enter your car name"))
my_car = Car(car_name)
print("{}, fuel = {}, odo = {}".format(my_car.name, my_car.fuel, my_car.odometer))
menu_choice = insert_menu()
while menu_choice.lower() == "d" or menu_choice.lower()... |
7029e0e03d55d9cff8e27307c46ecceeae193b51 | reriver/py_hackerrank | /find_str.py | 340 | 3.84375 | 4 | def count_substring(s, sub):
occurs_count = 0
for i in range(len(s)):
f = s[i:len(s)].find(sub)
if f == 0:
occurs_count += 1
print(occurs_count, s[i:len(s)])
return occurs_count
if __name__ == '__main__':
s = input()
sub = input()
res = count_substring(s,... |
428e6ef51f761f99411603e4b54278499be59027 | reriver/py_hackerrank | /day15.py | 1,098 | 3.828125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Solution:
def display(self, head):
current = head
while current:
print(current.data, end=' ')
current = current.next
def insert(self, h, d):
n = Node(d)
# ... |
df1464fe55561d57f4c2468c8f8912f1569210a6 | reriver/py_hackerrank | /nested_lists_full.py | 879 | 3.75 | 4 | if __name__ == '__main__':
n = int(input())
students = []
marks = []
for i in range(n):
name = input()
mark = float(input())
marks.append(mark)
st = [mark, name]
# marks[mark] = name
# students.append([input(), input()])
# students[mark] = name
... |
3b3a15dbdd7411a1d4f64143c0f7f03ed98a17b9 | leead4/python-classes-car | /p.py | 1,171 | 3.75 | 4 | # import sys
class Cars():
def __init__(self):
self.make_list = list()
self.model_list = list()
self.show_dict = dict()
def read_makes(self):
with open('cars-makes.txt', 'r') as car_make:
for cars in car_make:
# print(cars)
self.make_list.append(cars[:-1])
return self.make_list
# self.make_... |
993a694c21225ab2a73964e5a6c4c8fc09f1ef1f | jlaufmann/gehmensch | /gehmensch.py | 3,236 | 3.859375 | 4 | '''
This program will serve as an interface to my waterproof sony walkman.
It will allow:
- automatic playlist creation using every file in a particular folder
This is the most important thing. it will make a playlist file using all the files in a particular folder
on the walkman. The playlist file could have virtu... |
de826e2d7c0ee6cc020d9d18fc3cfd1cf70a909c | ScottSko/Python---Pearson---Third-Edition---Chapter-4 | /Sum of Numbers.py | 199 | 4.21875 | 4 | number = 0
total = 0
while number >= 0:
number = int(input("Please enter a positive number (or a negative number to stop): " ))
total += number
print("The total is ", total - number) |
70d32c86b1d5d2fab74972fd470f645cf98ef0f8 | Abhi848/python-basic-programs | /p45.py | 155 | 3.765625 | 4 | n= int(input("enter the number:"))
sum=0
while n>0:
r= n%10
sum= sum+r
n=n//10
if n/10>1:
print(r, end='+')
else:
print(sum)
|
c9932167ae0c36df7b737ab56e80f92cb01ddde7 | Abhi848/python-basic-programs | /p54.py | 141 | 3.734375 | 4 | sum=0
for i in range(1,8,1):
fact=1
for j in range(1, (i+1), 1):
fact= fact*j
s= i/fact
sum=sum+s
print(sum)
|
5691ae59975f7f51c30fd7dccf278ce265038ade | Abhi848/python-basic-programs | /46.py | 178 | 3.890625 | 4 | n= int(input("enter any number:\n"))
print("Number of prime digits in the entered number is")
c=0
for i in range(n):
if(n%i)==0:
c=c+1
break
print(c)
|
8d4fa35ea4f92e327d39197f2de6720a07bfc6fb | ShubhamBelwal/pyFluent | /14_Iterables/aritprog_v1.py | 539 | 3.546875 | 4 | class ArithmeticProgression:
def __init__(self, begin, step, end=None):
self.begin = begin
self.step = step
self.end = end
def __iter__(self):
result = type(self.begin + self.step)(self.begin) #Produces value = self.begin, but with type equal to that of subsequent additions... |
cd30c4810ee0fc0e7da3614226274f109e938c92 | JoannaJedrzejczak/Python | /checker.py | 1,545 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 16 11:03:36 2021
@author: Joanna
"""
import re
import enchant
class Checker:
def __init__(self, password):
self.dicAng = enchant.Dict("en_US")
self.dicPL = enchant.Dict("pl_PL")
self.password = password
def check_length... |
f1ea90c78b099faf9ad5218d5fc6fa3b8c9aa2bc | valzinha/movieTrailerWebsite_Udacity | /media.py | 714 | 3.546875 | 4 | import webbrowser
class Movie():
"""This class provides a way to store movie related information."""
def __init__(self, movie_title, movie_storyline,
poster_image, trailer_youtube,
movie_imdb, movie_release_date, movie_rating):
self.title = movie_title
... |
c0ed83d6bef4fb0bcd6d96b69c0e9f94463b9897 | SMHari/Python | /stringmore.py | 319 | 3.75 | 4 | def main():
job = "Programmer"
print (job)
count_r=job.count("r")
print("no of r:{0}".format(count_r))
pos_g=job.find("g")
print("position of g:{0}".format(pos_g+1))
mreplace_y=job.replace("m","Y")
print("Replacing m with Y:{0}".format(mreplace_y))
if __name__=='__main__':
main()
|
acd40840443e4bbdc55eb87ec44c767527e3cd64 | Browna7805/CTI110 | /P2HW1_PoundsKilograms_AntwonBrown.py | 396 | 4.28125 | 4 | #Converting Pounds to Kilograms
#2/12/19
#CTI-110 P2HW1 - Pounds to Kilograms Converter
#Antwon Brown
# Input pounds
# Calculate formula
# Display kilograms
#User Inputs Pound
pounds = int(input('Enter pounds here: '))
#Caculate the amount of Pounds lbs/2.2046
kilograms = pounds / 2.2046
... |
b63c5ea664ed009fde2b738a60c1b223cd699b3b | dgtest01/aoc2019 | /1/1-2.py | 373 | 3.859375 | 4 | #!/usr/bin/python3.6
with open('input.txt') as f:
lines = f.readlines()
fuelTotal = 0
for line in lines:
currentModuleFuel = int(line)
while currentModuleFuel > 0:
currentModuleFuel = (currentModuleFuel // 3) - 2
if currentModuleFuel > 0:
fuelTotal += currentModuleFuel
print(f... |
e68b12c28287732891e9be906623781dce295213 | CentMeng/python | /dataAnalysis/test/numpyTest.py | 403 | 4.0625 | 4 | # -*— coding:utf-8 -*
import numpy as np # 一般以np作为numpy的别名
a = np.array([2,0,1,5]) #创建数组
print(a) # 输出数组
print(a[:3])#引用前三个数字
print(a.min()) #输出a的最新值
a.sort() #将a的元素从小到大排序,此操作直接修改a,因此这时a为[0,1,2,5]
print(a)
b = np.array([[1,2,3],[4,5,6]]) #创建二维数组
print(b*b) #输出数组的平方证
|
54c3081368df8bb35a2291b09341989afb6bf65f | DSLituiev/bioutils | /src/bioutils/coordinates.py | 2,724 | 3.5 | 4 | # -*- coding: utf-8 -*-, flake8: noqa
from __future__ import absolute_import, division, print_function, unicode_literals
"""provides utilities for interconverting between coordinate systems
especially as used by the hgvs code. The three systems are:
: A : C : G : T : A : C :
human/hgvs h :-3 :... |
31f990a30b076a11c8df6027cdab5748a557a171 | qiurenping/tiger | /python/study100/5.py | 287 | 3.546875 | 4 | # -*- coding:UTF-8 -*-
a = []
for i in range(0,3):
l = int(raw_input("Please input inger:\n"))
a.append(l)
a.sort()
print a
a = [9,99,20,33,6,2,7,11,50]
for i in range(len(a)):
m = a[i]
for j in range(i+1,len(a)):
n = a[j]
if n < m:
a[i],a[j]=n,m
m = a[i]
print a
|
86125558861463858c932991106977b868b029da | qiurenping/tiger | /python/study100/17.py | 353 | 3.796875 | 4 | #-*- coding:utf-8 -*-
c = input('Please input a string:\n')
i = 0
letters = 0
spaces = 0
digits = 0
others = 0
while i < len(c):
k = c[i]
i += 1
if k.isalpha():
letters += 1
elif k.isspace():
spaces += 1
elif k.isdigit():
digits += 1
else:
others += 1
print('char = %d,space = %d,digit = %d,others = %d' ... |
091fdc351972a72f920314c4cdeef795395b72df | Carvs10/ProgamURI | /Python/ex9.py | 138 | 3.640625 | 4 | name = str(input())
salary = float(input())
comi = float(input())
addition = comi*0.15
print('TOTAL = R$ {:.2f}'.format(salary+addition)) |
79228ace62a58f959abe6a5b737407cc04ced48d | lere01/codility-algorithms | /missing_integer.py | 861 | 3.734375 | 4 | """
This is a demo task.
Write a function:
def solution(A)
that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.
Given A = [1, 2, 3], the function should return 4.
Given A = [−1, −3]... |
bf849ae7db74fce57101044d3edc09b9f518253e | abhispra/python | /substitution_cipher/src/main.py | 1,563 | 3.59375 | 4 | '''
Created on 18-Jan-2015
@author: abhispra
'''
import random
class subCipher:
alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
keyTable... |
47b26f553cde766379b87dc558813ead2bac01c2 | CaptainWilson/BLCK | /blockchain.py | 2,880 | 3.5625 | 4 | #Initalize empty blockchain list
gensis_block = {
'previous_hash': '',
'index': 0,
'transactions': []
}
blockchain = []
open_transactions = []
owner = 'Jabari'
def last_bc_value():
"""Returns last value of blockchain"""
if len(blockchain) < 1:
return None
return blockchain... |
1f86e4edd641fc440a35c00769ad7617baaae3f2 | wangKHNL/algorithm011-class01 | /Week_07/week_07_minMutation.py | 1,894 | 3.5625 | 4 | from typing import List
import operator
"""
最小基因变化
"""
class Solution:
def minMutation(self, start: str, end: str, bank: List[str]) -> int:
bank_set = set(bank)
if end not in bank_set:
return -1
str_map = {'A': 'CGT',
'C': 'AGT',
'G': 'ACT... |
cede98d12fcad96eb1d6ab5bc9569fd1cf370da9 | meurissemax/elen0062-1 | /2/python/data.py | 1,385 | 3.765625 | 4 | """
University of Liege
ELEN0062 - Introduction to machine learning
Project 2 - Bias and variance analysis
Authors :
- Maxime Meurisse
- Valentin Vermeylen
"""
#############
# Libraries #
#############
import numpy as np
from sklearn.utils import check_random_state
#############
# Functions #
############... |
ed16752977a0a5c046ee9860d601b5b7b66717ee | satvikel4/collatz-conjecture | /collatz-conjecture.py | 183 | 4.15625 | 4 | n = int(input("Enter a number: "))
cur = n
while cur != 1:
if cur % 2 == 1:
cur = cur*3+1
else:
cur = cur/2
print(str(n) + " follows the Collatz-Conjecture") |
ffdc843ef2aadf57ae0f999690769ace5af63e07 | guedanie/Regression-Project-Zillow | /feature_engineering.py | 1,744 | 3.71875 | 4 | # We used SelectKBest to select the top 2 features based on how correlated each feature is with the target variable. We ended up with exam1 and exam3.
# We use RFE and a linear regression algorithm to keep the top 2 features based on which features lead to the best performing linear regression model.
# This eliminated ... |
aace4210890130df7445e72d4b7ba5d842b2904e | hanzhi713/ibcs-wd | /mainSpace/files/SortingAlgorithms_basic.py | 3,515 | 4.1875 | 4 | import matplotlib.pyplot as plt
import random
import time
def insertionSort(alist):
### Pseudo-code : Arr: An Array which is one-based
### for our python implementation, it should be zero-based!!!
### when we call insertionSort(alist), the alist is sorted in itself.
# N = LENGTH(Arr)
# FOR i = 2 TO N
# Cur... |
f8082c95325c46789e8749aa33076530b86d91b4 | hanzhi713/ibcs-wd | /mainSpace/files/introDemo.py | 471 | 3.6875 | 4 | # import tkinter as tk
# root = tk.Tk()
# li = ['C','python','php','html','SQL','java']
# movie = ['CSS','jQuery','Bootstrap',1,2,3]
#
# listb = tk.Listbox(root)
# listb2 = tk.Listbox(root)
#
# for item in li:
# listb.insert(0,item)
#
# for item in movie:
# listb2.insert(0, item)
#
# listb.p... |
d86bee77024a99aefa61b6c3e559aae559d248f7 | foleydavid/combinationSum3 | /Solution.py | 2,012 | 3.53125 | 4 | # TESTING PUSH PULL WITH PYCHARM
# MORE TESTING
class Solution(object):
def combinationSum3(self, k, n):
"""
:type k: int
:type n: int
:rtype: List[List[int]]
#may only use 1 - 9, once per sum
"""
# 0 < x < 10 for all numbers used
return(Solu... |
7c53d00bca89e58eaf3e58057daa69071b03d3bb | hartmannw/scripts | /lumann/utils/file.py | 3,649 | 3.609375 | 4 | """Collection of functions for files.
Methods
--------
atomic_write(data, output_file)
Write to file as atmoic operation.
mkdir_p(path)
Mimics the linux call 'mkdir -p'.
open_file(filename, open_mode)
Returns the file handle for either a gzip file or text file.
parse_options_in_string(options, unique_keys)... |
cb7b757188f9a3be82ca5768427c812955dbe0fb | KLKln/Module12 | /unit4/shape.py | 579 | 3.96875 | 4 | from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self):
raise NotImplementedError("Abstract method not implemented")
class InvalidSideError(Exception):
pass
#@Shape.register
class Rectangle(Shape):
def __init__(self, h, b):
if h <= 0:
raise... |
817347640225648805bd64d0c23897419e2db954 | Rauulito/PracticaAmpliacionT3 | /La escalera.py | 400 | 4.09375 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'staircase' function below.
#
# The function accepts INTEGER n as parameter.
#
def staircase(n):
# Write your code here
for i in range(n):
i=i+1
print(i*'#')
print("\n")
#Probamos que funcione
stairc... |
4056f5443b5b225ba15d62c629f53a08ecdacb12 | GhostyPants/Final-Isabela | /puntoFijo.py | 290 | 3.59375 | 4 | from math import *
def g(x):
y=0.5*sqrt(10-x**3)
print y
return y
p0=1
tol=0.001
n0=50
i=1
while i<=n0:
p=g(p0)
if abs(p-p0)<tol:
print "El punto fijo es",p,"despues de",i,"iteraciones"
break
i=i+1
p0=p
if i>n0:
print "El metodo no converge"
|
5767eab67aadf487dbaa75bb19be98f210dc24ea | marcodenisi/advent-of-code | /2018/06/06.py | 2,871 | 3.734375 | 4 | import re
import pprint
with open('input.txt') as f:
data = f.read()
size = 350
####### test data
#data = '''1, 1
#1, 6
#8, 3
#3, 4
#5, 5
#8, 9'''
#size = 10
#######
def manhattan_distance(first_point, second_point):
return abs(int(first_point[0]) - int(second_point[0])) + abs(int(first_point[1]) - int(second_po... |
8d62c5357546694380ae0de29e7d7f9033de6c34 | marcodenisi/advent-of-code | /2021/src/07.py | 820 | 3.53125 | 4 | from typing import List
def get_positions(filename):
with open(filename) as file:
return [int(p) for p in file.readline().strip().split(",")]
def min_fuel(positions: List[int], fuel_calc_func) -> int:
min_x = min(positions)
max_x = max(positions)
return min(
[sum(fuel_calc_func(posi... |
6bb13f9167ec6343a32a5c0e1a8c882679486bed | marcodenisi/advent-of-code | /2015/solutions/03.py | 1,284 | 3.671875 | 4 | def get_instructions():
with open("../inputs/03.txt") as file:
return file.read()
def get_new_position(x, y, instruction):
if instruction == "<":
x -= 1
if instruction == ">":
x += 1
if instruction == "^":
y += 1
if instruction == "v":
y -= 1
return x, ... |
391792be9cba28401ed5f5e7594abd6d058bec94 | marcodenisi/advent-of-code | /2021/src/09.py | 1,801 | 3.53125 | 4 | def parse_map(filename):
with open(filename) as file:
return [[int(el) for el in list(line.strip())] for line in file.readlines()]
def is_out_of_bound(r, c, map):
return r < 0 or c < 0 or r >= len(map) or c >= len(map[0])
def check(r, c, map, current_element):
if is_out_of_bound(r, c, map):
... |
36aac7ec19f20e73aa45d8e84d7898670a687a1d | DavidSuarezM/python-3 | /Diccionario.py | 323 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 18 14:14:16 2021
@author: David Suárez Molina
"""
ipAddress={"R1":"10.1.1.1", 1:'AP', 2:2.5, 3:True}
print(type (ipAddress))
print(len (ipAddress))
print(ipAddress)
print(ipAddress[2]) #Para mostrar valores específicos.
ipAddress['R3']='10.0.0.3'
print('R3' ... |
c79d02d5d4953de377b1ec9f10b7bec231a085a6 | DavidSuarezM/python-3 | /Lista.py | 364 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 11 15:37:52 2021
@author: David Suárez Molina
"""
lista=['R1',5,5.8,True,"R1"]
print(lista)
print(type(lista))
print(len(lista)) #Tamaño de la lista
print(lista[2],'\n') #Elemento de la lista
lista[3]=False #Cambiar un valor de la lista
del lista[3] #Borrar ... |
5e809252c4b7316aa436fe3324692b7c26a74f56 | Alexey-An/ftpu | /ftpm.py | 2,182 | 3.8125 | 4 | import ftplib
import os
# данный метод принимает три параметра:
# 1) ftp-сервер (в данном примере используется ftp-сервер запущенный локально)
# 2) имя файла, который необходимо загрузить с сервера
# 3) путь на локальной машине, куда будет записан файл, загружаемый с сервера
def download_file(ftp_server, filename, sa... |
57af5c354c66e2e2a3d6067483cf0deb6be84457 | at3hira/challenge_commit | /charenge_commit/Chap7/chap7_5.py | 157 | 3.90625 | 4 | list1 = [8, 19, 148, 4]
list2 = [9, 1, 33, 83]
list3 = []
for value1 in list1:
for value2 in list2:
list3.append(value1 * value2)
print(list3)
|
388b710a87f25e6e7dcd73ad6fa4648883ea73e1 | at3hira/challenge_commit | /charenge_commit/Chap14/chap14_2.py | 248 | 3.78125 | 4 | class Square:
def __init__(self, one_side):
self.one_side = one_side
def __repr__(self):
return "{} by {} by {} by {}" .format(self.one_side, self.one_side, self.one_side, self.one_side)
square = Square(20)
print(square)
|
bfe27c03b52e529f211029b2e1ee7fe9cb7e8f6f | at3hira/challenge_commit | /charenge_commit/Chap12/chap12_4.py | 596 | 4.15625 | 4 | """
・Create Hexagon object and class
・find the Hexagon perimeter length output result
"""
class Hexagon:
def __init__(self, one_side):
"""
Parameters
-----------
one_side : int or float
hexagon one side length
"""
self.one_side = one_side
def ca... |
76f6afad87bedf756f980e03106d2458717bced8 | videogames4all/bananabot | /lcr.py | 487 | 3.5625 | 4 | #A drinking game version of Left-Center-Right
#Must have 3 players minimum, each player starts with 3 tokens/drinks
#Allow for self-drinking, a pot that the winner distributes among people
#1 game per Server
#People can drop mid-game, remaining drinks go to center
#Allow game ending in the middle in case of anything
i... |
ad7286d1754a4e04fb0d5ba9b85ce3f340c21340 | xiaoxiaolulu/arithmetic | /Check10.py | 286 | 3.5 | 4 | """
四个参数进行求和汇总,如果两个值是一样,汇总结果为888
"""
def BB_SUM(a, b, c, d):
if a == b or a == c or a == d or b == c or b == d or c == d:
BB_SUM = 888
else:
BB_SUM = a + b + c + d
return BB_SUM
print(BB_SUM(1, 2, 2, 4))
|
a679e2945c7ca7e8af85e5ddca25c613d812581e | xiaoxiaolulu/arithmetic | /Check03.py | 180 | 3.78125 | 4 | """
提取扩展名
"""
filename_with_extension = input("请输入文件名: ")
name_list = filename_with_extension.split('.')
print(f"提取的扩展名为 -> {name_list[-1]}")
|
1653d80773e66a6a61a2adaac0a57c0592ce1c3d | JerrodTanner/negative-strip-colorizer | /hw01_tanner.py | 4,178 | 3.578125 | 4 | '''
Author: Jerrod Tanner
Date: 20 February 2020
'''
import numpy as np
import cv2
import matplotlib.pyplot as plt
import sys
xTranslation = 0
yTranslation = 0
def translate(I, x, y):
''' Translate the given image by the given offset in the x and y directions.
'''
rows, cols = I.shape[:2]... |
cef5e6e6901b2f0293f3c20b294c7b87bf1313aa | eugenepaniot/moriot | /stress-tests/test.py | 1,159 | 3.921875 | 4 | #!/usr/bin/python
import time
import random
def doTimeConsumingStep(N):
"""
This represents the computational part of your simulation.
For the sake of illustration, I've set it up so that it takes a random
amount of time which is occasionally longer than the interval you want.
"""
r = random.... |
f805a0fd460b0e92c0379274e268be1593fa38a0 | TyDunn/hackerrank-python | /GfG/Heap/heapsort.py | 562 | 4.0625 | 4 | #!/bin/python3
def heapify(arr, n, i):
largest = i
left = 2 * i + 1
right = 2 * i + 2
if left < n and arr[largest] < arr[left]:
largest = left
if right < n and arr[largest] < arr[right]:
largest = right
if largest != i:
arr[i], arr[largest] = arr[largest], arr[i]
heapify(arr, n, largest)
def heap_sor... |
0ed99c0a45b70c830b44c66d6ad44a358b308747 | TyDunn/hackerrank-python | /GfG/Linked List/ll_merge.py | 2,614 | 4.03125 | 4 | #!/bin/python3
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def push(self, new_data):
new_node = Node(new_data)
new_node.next = self.head
self.head = new_node
def insertAfter(self, prev_node, new_data):
if not prev... |
bfaae96573e3dfbafd293d67435a2f9b298d1183 | TyDunn/hackerrank-python | /GfG/Array/sum_pair.py | 349 | 3.765625 | 4 | #!/bin/python3
def print_pairs(arr, size, target):
s = set()
for i in range(0, size):
temp = target - arr[i]
if temp >= 0 and temp in s:
print("Pair with sum of {} is {} and {}".format(target, arr[i], temp))
s.add(arr[i])
if __name__ == '__main__':
arr = [1, 4, 45, 6, 10, 8, 12, -29]
target = 16
print... |
69798bc690e9208d231ff4145e88ae71ae943eca | TyDunn/hackerrank-python | /CTCI/check_permutation.py | 464 | 3.890625 | 4 | #!/bin/python3
def check_permutation(str1, str2):
if len(str1) != len(str2):
return False
char_set = [0] * 128
for char in str1:
char_set[ord(char)] += 1
for char in str2:
char_set[ord(char)] -= 1
if char_set[ord(char)] < 0:
return False
r... |
2406e0be272b867be4f3ffc3667ed06d7985fbc9 | TyDunn/hackerrank-python | /GfG/Stack/print_nge.py | 1,056 | 4.125 | 4 | #!/bin/python3
class StackNode:
def __init__(self, data):
self.data = data
self.next = None
class Stack:
def __init__(self):
self.root = None
def is_empty(self):
return True if not self.root else False
def push(self, data):
new_node = StackNode(data)
new_node.next = self.root
self.root = new_nod... |
f1f4046fdf3780ac3bc00561be4c1cc4ca99642b | TyDunn/hackerrank-python | /Python/Collections/ordereddict.py | 266 | 3.625 | 4 | from collections import OrderedDict
sprmkt = OrderedDict()
for _ in range(int(input())):
item, space, quantity = input().rpartition(' ')
sprmkt[item] = sprmkt.get(item, 0) + int(quantity)
for item, quantity in sprmkt.items():
print(item, quantity) |
0583944a70ff736fa0a9617bec740d29a2c466ed | TyDunn/hackerrank-python | /GfG/Array/odd_number.py | 205 | 4.03125 | 4 | #!/bin/python3
def get_odd_occurence(arr):
res = 0
for ele in arr:
res = res ^ ele
return res
if __name__ == '__main__':
arr = [2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2]
print(get_odd_occurence(arr)) |
857b1b724df37ef68f6a76faccc745d592119461 | TyDunn/hackerrank-python | /CTCI/mergesort.py | 950 | 3.96875 | 4 | #!/bin/python3
def mergesort(arr):
helper = [0] * len(arr)
mergesort_helper(arr, helper, 0, len(arr) - 1)
def mergesort_helper(arr, helper, low, high):
if low < high:
mid = (low + high) // 2
mergesort_helper(arr, helper, low, mid)
mergesort_helper(arr, helper, mid + 1, high)
merge(arr, helper, low, mid, hi... |
a9c3ab57ba5703b5547fbb241048f91f38aeddbf | TyDunn/hackerrank-python | /CTCI/quicksort.py | 586 | 3.796875 | 4 | #!/bin/python3
def quicksort(lst, left, right):
idx = partition(lst, left, right)
if left < idx - 1:
quicksort(lst, left, idx - 1)
if idx < right:
quicksort(lst, idx, right)
def partition(lst, left , right):
pivot = lst[(left + right) // 2]
while left <= right:
while lst[left] < pivot:
left += 1
while... |
bf7af277b91558f49895bf1a6db2648f9cb82bc9 | TyDunn/hackerrank-python | /GfG/Graph/dfs.py | 589 | 3.71875 | 4 | #!/bin/python3
from collections import defaultdict
class Graph:
def __init__(self):
self.graph = defaultdict(list)
def add_edge(self, u, v):
self.graph[u].append(v)
def dfs(self, s):
visited = [False] * len(self.graph)
self.dfs_util(s, visited)
def dfs_util(self, v, visited):
visited[v] = True
pri... |
0cc3a96c423e219fb634150ec5ba26dcf4442cdb | wasimashraf88/Python-tutorial | /variable.py | 383 | 3.578125 | 4 | #user_one_name = "Wasim" #snake case writting
#userOneName = "Amir" #camel case writting
# in python recomended we use sanke case writting
#Adding integers using variable
# x = 5
# y = 6
# print(x + y)
#We can,t add integers and string
#For sum int and string we can use typecasting
# x = 5
# y = "6"
#x = 100
def myfun... |
6e01b1f2c2807b4904b96ee745c0c877421c976d | wasimashraf88/Python-tutorial | /string.py | 326 | 4.15625 | 4 | first_name = "Wasim"
last_name = "Ashraf"
full_name = first_name + " " + last_name
print(full_name)
#print(first_name +3) # error can not use like this
print(first_name +"3") #we use like this or
print(first_name +str(3)) # like this
print(first_name*3) # We use multiply and our string multiply 3 time
print(first_name ... |
e387aac0b64bf96cb7781199c9873bf77fa62620 | wasimashraf88/Python-tutorial | /tutmain_1.py | 214 | 3.609375 | 4 | def printhar(string):
return f"Yeh string harry ko de do {string}"
def add(num1,num2):
return num1 + num2 + 5
if __name__ == "__main__":
print(printhar("Harry"))
o = add(4,6)
print(o)
|
38c069a9f7cb7c8aee82074930e661998fd19cc2 | wasimashraf88/Python-tutorial | /real_python_for_loop.py | 209 | 3.671875 | 4 | def hello(**args):
for key, value in args.items():
print("Hello", key,value,"!")
hello(args1 = "Asim",args2 = "sheraz",args3 = "wasim",args4 = "mashar",args5 = "Ghufran")
|
73f0ee9594bc1a4ac02a0b3bbb1b307c1510ba3f | wasimashraf88/Python-tutorial | /player.py | 589 | 3.734375 | 4 | player_1 = 'Sam'
player_2 = 'Alex'
current_round = 1
#current_round = 2
print("Game on!")
print(f"player_1: {player_1}")
print(f"player_2: {player_2}")
print("-------------------")
print(f"Round:{current_round}!")
player_1_score = 10
player_2_score = 13
print(f"player-2 score:{player_2_score}" )
print(f"player_1 score... |
46f56b15b12f3d1627547061d840e4ef30050960 | wasimashraf88/Python-tutorial | /chapter_two_exercise.py | 188 | 4.5 | 4 | name =input("Write your name :") #print reverse of your name in output
reverse = name[-1::-1]
#print(f"Reverse of your name is {reverse}")
print(f"Reverse of your name is {name[-1::-1]}")
|
0077bef62aca4c147e4476b2b8d056c1bb0756eb | toogiii/CompetitiveProgramming | /GASTC Programming Challenge/Lucky Base 13.py | 469 | 4 | 4 | def intBase(number, base):
if number == 0:
return [0]
digits = []
while number > 0:
digits.append(number % base)
number = number // base
return digits[::-1]
digitList = "123456789ABC"
base13Num = ""
number = int(input("Enter your decimal whole number: "))
numDigits = intBase(ab... |
3d1b86ff4688b7363d4a52190fcd5d27e0be77b2 | cmgn/problems | /kattis/bestrelayteam/bestrelayteam.py | 971 | 3.59375 | 4 | import itertools
def main():
n = input()
runners = []
for i in range(int(n)):
a, b, c = input().split()
runners.append((a, float(b), float(c)))
# Pick the 4 best stage 1 runners
# Pick the 4 best stage 2,3,4 runners
# It's one of the combinations of 1 + 2,3,4
runners.sort(... |
bd276552e41dc946ba7d5cee0f2f1fb38b22641e | cmgn/problems | /kattis/mnist2class/mnist2class.py | 125 | 3.546875 | 4 | for i in range(30):
for j in range(51):
if j % 2 == 0:
print(1)
else:
print(-1)
|
706fae1fbd8046e5b99aaf316780ec8e89b71465 | cmgn/problems | /kattis/shortestpath1/shortestpath1.py | 671 | 3.5 | 4 | #!/usr/bin/env python3
from heapq import heappop, heappush
def dijkstra(a, s):
d = {}
q = [(0, s)]
while q:
c, u = heappop(q)
if u in d: continue
d[u] = c
for v, w in a[u]:
if v not in d: heappush(q, (c + w, v))
return d
n, m, q, s = [int(x) for x in inp... |
5cdbbb2974ffe35cc4e9f598407e7e39b31aeb65 | cmgn/problems | /code-jam/2017/qual_b_small.py | 306 | 3.78125 | 4 | #!/usr/bin/env python3
number_of_cases = int(input())
def is_sorted(s):
i = 1
while i < len(s) and s[i] >= s[i-1]:
i += 1
return i >= len(s)
for case in range(number_of_cases):
n = int(input())
while not is_sorted(str(n)):
n -= 1
print(f"Case #{case+1}: {n}")
|
5f21af17a03dfb81c857025704325762a512e05a | cmgn/problems | /kattis/encodedmessage/encodedmessage.py | 225 | 3.53125 | 4 | from math import sqrt
n = int(input())
for _ in range(n):
s = input()
l = len(s)
m = int(sqrt(l))
for j in range(m - 1, -1, -1):
for i in range(m):
print(s[i * m + j], end="")
print()
|
4a96282684973c153831cc30b1e3938da6885ae8 | cmgn/problems | /helpers/datastructures/py/fenwick.py | 464 | 3.890625 | 4 | #!/usr/bin/env python3
class FenwickTree(object):
def __init__(self, nums):
self.nums = [0] * (len(nums) + 1)
for i in range(1, len(self.nums)):
self.add(i, nums[i-1])
def add(self, i, n):
while i < len(self.nums):
self.nums[i] += n
i += (i & -i)
... |
02982425ce7c36ad2996d6f7a6d2b5996bbdec5e | cmgn/problems | /helpers/graph/py/dijkstra.py | 1,071 | 3.765625 | 4 | #!/usr/bin/env python3
from heapq import heappop, heappush
class Node(object):
def __init__(self, value):
self.value = value
self.edges = []
def add_edge(self, target, cost):
self.edges.append((target, cost))
def dijkstra(src, target):
distances = {src: 0}
queue = [(0,... |
299588845e60e3aed8807c332e36a14ac1786d99 | cmgn/problems | /kattis/anagramcounting/anagramcounting.py | 335 | 3.640625 | 4 | #!/usr/bin/env python3
from math import factorial
from functools import reduce
from sys import stdin
for word in stdin:
word = word.strip()
characters = [word.count(c) for c in set(word)]
numerator = factorial(len(word))
denom = reduce(int.__mul__, (factorial(n) for n in characters))
print(numer... |
5f96a3ef256201a50c8e19cae1f9a55cd3265938 | littlechintw/PhysicExp | /calculater.py | 886 | 3.796875 | 4 | import math
pi = 3.1415926
D = 1.12
sumforce = 0.0
R = float(input("吹口半徑:"))
r = float(input("乒乓球半徑:"))
deg = float(input("漏斗半角"))
rate = float(input("風速:"))
phi = float(input("分割度數:"))
d_unit = 90 / phi
area = (R*R - r*r) * pi
raddeg = math.radians(deg)
radphi = math.radians(phi)
def Area(angle):
t = R - r * mat... |
334dbde24fdc7b4b27ff4a54f32c3c9043678a3d | Fernanda2019/-AprendiendoPython | /ACUMULADO.py | 684 | 3.5625 | 4 | # ACUMULADO.PY
# AUTOR: MARIA FERNANDA HERRERA FERNANDA
# FECHA DE CREACION: 19/09/2019
acumulado=int(0)
numero=str("")
# AL USAR TRUE COMO CONDICION EN WHILE, SE FORMARA UN BUCLE INFINITO HASTA QUE DE FORMA EXPLICITA
#SE USE LA INSTRUCCION BREAK
while True:
numero=input("Dame un numero: ")
if nu... |
8caeed6fedc9565b4da7bf3c26f5502de41ba8fb | Fernanda2019/-AprendiendoPython | /ALEATORIO.py | 1,184 | 4.0625 | 4 | # ALEATORIO.PY
# AUTOR: MARIA FERNANDA HERRERA TREJO
# FECHA DE CREACION: 19/09/2019
#PYTHON POSEE UNA GRAN VARIEDAD DE MODULOS, UN MODULO EN PYTHON ES UN ARCHIVO QUE CONTIENE CODIGOS CUYO PROPOSITO
#ES SER REUTILIZADO POR OTROS DESARROLLOS SIN NECESIDAD DE ESCRIBIRLO NI COPIARLO.
#PARA PODER USAR DICHOS MODULO... |
51ca44361f7113374da60c157d09e39f8a994efd | Reyoth/Robotique2020 | /python3/conditions.py | 201 | 3.5 | 4 | # if : si ...
# elif : sinon, si ...
# else : sinon (par defaut)
# on verifie si un nombre est paire ou impaire
nombre = 4
if (nombre%2==0):
print("Nombre paire")
else:
print("nombre impaire") |
da7c1141c2bd57e5e3aa1ee361cf37093b501955 | JendersonQuinter/ProyectoII-SamanCaribben | /rooms.py | 1,061 | 3.671875 | 4 | # GESTION DE HABITACIONES
from clases import Client
def register_client(rooms=[], total=0):
while True:
try:
name = input("Ingrese su nombre: ")
dni = int(input("Ingrese su DNI: "))
age = int(input("Ingrese su edad: "))
disability = input("Tiene alguna discapacidad (S) o (N): ").upper()
... |
a6fe56b72084658350542b6a42ec8a2e36788ab9 | yinSpark/WebSpider-Programs | /algorithms/SelectSort.py | 1,287 | 3.859375 | 4 | # 选择排序算法
# 和插入排序很像
# 算法思想
# 简单的说,就是有一组数,然后从中选择找出最大的一个,把这个数排到第一个或者最后一个,
# 然后找出第二大的数,排到第二个或者倒数第二个,就这样一直到所有数字都排好为止。
# 算法分析
arr = [7, 3, 5, 2, 1, 4]
# 1: 3, 5, 2, 1, 4, 7 找到7
# 2: 3, 2, 1, 4, 5, 7 找到5
# 3: 3, 2, 1, 4, 5, 7 找到4
# 4: 2, 1, 3, 4, 5, 7 找到3
# 5: 1, 2, 3, 4, 5, 7 找到2, 1
# 总结: 循环5次,
# 算法实现
# 每次得到最小值
fro... |
a3ad6399929f0782e737ef2b01b72c5df0505b02 | yinSpark/WebSpider-Programs | /algorithms/BucketSort.py | 1,052 | 3.796875 | 4 | # 桶排序算法
# 算法思想
# 桶排序也叫计数排序,简单来说,就是将数据集里面所有元素按顺序列举出来,然后统计元素出现的次数。最后按顺序输出数据集里面的元素。
# 算法分析
# 1.申请一个包含所有元素的数组,并初始化。
# 2.遍历原始数据,并计数。
# 3.遍历计数完成后的各个数组元素,输出数据。
# 算法实现
from random import randint
def random_array(n):
return [randint(0, 5) for _ in range(n)]
def bucket_sort(arr):
min_ = min(arr)
# 初始化一个m位包含所有... |
fbf73e07d9dd2368a93f4ecc3e38144602fc27fb | admin87OYE/OYE | /crop.py | 542 | 3.546875 | 4 | from PIL import Image
def crop_image(input_image, output_image, start_x, start_y, width, height):
"""Pass input name image, output name image, x coordinate to start croping, y coordinate to start croping,
width to crop, height to crop """
input_img = Image.open(input_image)
box = (start_x, start_y, s... |
d08f601f6d6b00d2fe6e5e7fa00f5d6f7039a0cc | benedikt719/practice_python | /practices/unknown.py | 303 | 3.640625 | 4 | from random import shuffle
def num(number) :
return [x for x in number if x < 0 ] + [y for y in number if y > 0]
large_a = list( [x for x in range(100) if x % 2 == 0 or x % 7 == 0] + [-x for x in range(100) if x % 3 == 0 or x % 5 == 0])
shuffle(large_a)
print(large_a)
print(num(large_a))
|
218b702902a9f29d833259ad421f491ddf2b686a | RealForce1024/flask-echarts | /test.py | 1,489 | 3.640625 | 4 | def split_v1(list):
length = len(list)
collection = []
for i in range(length - 1):
lst = []
for j in range(length - 1 - i):
if list[j] == list[j + 1]:
lst.append(list[j])
collection.append(lst)
return collection
def split_v2(list):
length = len(l... |
22cad40978bc445569dd1042ff73e525aede6a3b | 874795937/Leetcode | /offer_52.py | 1,548 | 3.734375 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# hashset
class Solution(object):
def getIntersectionNode(self, headA, headB):
"""
:type head1, head1: ListNode
:rtype: ListNode
"""
seen = s... |
98f76ed8471538502c3979e5631fa298962f3bb8 | 874795937/Leetcode | /leetcode_617.py | 2,621 | 4.125 | 4 | # Definition for a binary tree node.
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def mergeTrees(self, root1, root2):
"""
:type root1: TreeNode
:type root2: Tr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.