blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3726d482990e901257fb732967456adf30f809eb
probhakarroy/Algorithms-Data-Structures
/Algorithmic Toolbox/week6/max_gold.py
595
3.5625
4
# python3 def max_gold_knapsack(W, n, gold_bars): weight = [[0 for i in range(n+1)] for j in range(W+1)] for i in range(1, n+1): for w in range(1, W+1): weight[w][i] = weight[w][i-1] if gold_bars[i-1] <= w: wgt = weight[w - gold_bars[i-1]][i-1] + gold_bars[i-1]...
de9098d791092245f5a0118a241bb70b595e303d
2014cdag21/c21
/wsgi/local_data/brython_programs/boolean1.py
543
3.984375
4
''' program: boolean1.py ''' print(None == None) print(None is None) print(True is True) print([] == []) print([] is []) print("Python" is "Python") ''' not 關鍵字使用 ''' grades = ["A", "B", "C", "D", "E", "F"] grade = "L" if grade not in grades: print("unknown grade") ''' and 關鍵字使用 ''' sex = "M" age = 26 if ...
7e9cccc710d539dbdedf3eb31651c261d5e8ac76
newbiezz101/Map_for_Malls
/A_Star_Pathfinder/button_drawing_with_drawing_recorded.py
7,956
3.859375
4
import pygame import numpy as np from math import inf # ---------------------- Defining colors --------------------------------------- WALL_COLOR = BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) LIGHT_BLUE = (0, 111, 255) ORANGE = (255, 128, 0) PURPLE = (128, 0, 255...
0ca60cafaf7c641aa6d2717758cd4eb041bba59a
EvgeniyVashinko/BSUIR-PYTHON-2020
/Solutions/Task2/853506_Evgeniy_Vashinko/lab2/toJson/core.py
1,014
3.578125
4
def obj_to_json(obj, result="") : symbols = list() if type(obj) == dict : result += "{" symbols.append("}") for item in obj : result += obj_to_json(item) result += ": " result += obj_to_json(obj[item]) result += ", " result = result...
09b13e4cdeab3418bd6fd3360a4415e3336257c9
saturnisbig/euler-python
/pro022.py
1,435
3.9375
4
#!/usr/bin/env python # _*_ coding: utf-8 _*_ """ Problem: Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical p...
9cf2d4f5a24118a9f3433e57a0edc8eba436bcb4
AAKASH707/PYTHON
/Python Program to Multiply All Items in a Dictionary Example 1.py
632
4.5625
5
# Python Program to Multiply All Items in a Dictionary myDict = {'x': 20, 'y':5, 'z':60} print("Dictionary: ", myDict) total = 1 # Multiply Items for key in myDict: total = total * myDict[key] print("\nAfter Multiplying Items in this Dictionary: ", total) *****************************************************...
634bef95e971e68f20af8aefa44422413a1801bb
ftorresi/PythonLearning
/Unit3/ej3.22.py
246
3.5
4
from math import pi, exp, sqrt def gauss(x, m=0, s=1): return exp(-0.5*((x-m)/float(s))**2)/(s*sqrt(2*pi)) print " x gauss(x)" n=40 m=0 s=1 h=10.0*s/n for i in range(n+1): x=m-5*s+h*i print "%7.3f %8.5f" %(x,gauss(x, m, s))
a89f9e73bf870cf9d7f0996d86ab7befae35573d
devendrasingh143/python
/Tuples.py
792
3.890625
4
#this is comment t1 = 'a', print(type(t1),'\n') t = tuple('lupins') print(t,'\n') t = ('a', 'b', 'c', 'd', 'e') print(t[0]) #print index-wise print(t[1:3]) t = ('A',) + t[1:] #modification of tuple print(t,'\n') addr = 'monty@python.org' uname, domain = addr.split('@') # spliting one word into two print(uname) pr...
b726895ba2cd3b99e5aeeb505b6e7094c59c1c02
debolina-ca/my-projects
/Python Codes 2/pre_word_function.py
300
4.15625
4
def pre_word(word_1): if word_1.lower().startswith("pre"): if word_1.lower().isalpha(): print("True") else: print("False") else: print("False") word_2 = input("enter a word that starts with \"pre\": ") pre_word(word_2) print()
3032474d26304de91ee98b4b5632fcfd862d9ddc
Kunal352000/python_adv
/17_builtInFunction_eval1.py
372
4.21875
4
""" eval()-->to read the multiple values from the user input at at time either homogenious or hetrogenious elements. -->eval() automatically to perform type conversion based on our input -->in eval(),the input values are seperted by ',' only """ x,y,z=eval(input("Enter x,y,z value: ")) print(...
18a63525a9083e0a090caf9e21801ec017a0b956
marsmans13/twitter-markov-chains
/markov.py
3,110
3.78125
4
"""Generate Markov text from text files.""" from random import choice import sys import twitter import os def open_and_read_file(file_path): """Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. ""...
a20c4b15461f71dffba5905779c6ae8516720d53
hrafnkellpalsson/Hypersonic-Shock
/Code/data.py
9,311
3.75
4
""" Arrays of upstream velocity where one line in the array corresponds to the velocity range for a single curve. A function for reading csv files outputted by Engauge. This function is then applied to all the engauge csv files and the resulting data is stored. """ # Python library imports import os # 3rd party impor...
ade29ac395b873e047be55677bb3300c8ce23d3c
philmtl/youtube-python-tutorial
/if statments.py
131
3.96875
4
is_male = True is_tall = True if is_male or is_tall: print("you are a male or tall") else: print("you are not male")
0c67a54227d6e34ded6728537f8c243a24c94695
shalom-pwc/challenges
/02.Calculate-Remainder/calculate-remainder.py
57
3.5625
4
def remainder(num): return num % 2 print(remainder(5))
2f39869163e4201e5c47af42b0a6ae4f4723cd8b
arshadafzal/Optimization-Test-Problems
/Hartmann3.py
982
3.671875
4
# HARTMANN 3-DIMENSIONAL FUNCTION # Author: Arshad Afzal, IIT Kanpur, India # For Questions/ Comments, please email to arshad.afzal@gmail.com # Applications (1) Test Problems for Optimization Algorithms # (2) Generate Labelled Data sets for Regression Analysis import numpy as np from math impo...
9219ad77a940c3266d7326725f46916317f8c93a
yujikawa/design_pattern
/singleton/sample.py
263
4
4
from singleton import Singleton if __name__ == "__main__": obj1 = Singleton("dog") obj2 = Singleton("cat") if obj1 == obj2: print("obj1 and obj2 are the same instance.") print("obj1.name={} obj2.name={}".format(obj1.name, obj2.name))
55bf213a24e97d2f344ad65e2388a96521b9bc6c
thewritingstew/lpthw
/ex33sd1.py
315
3.796875
4
numbers = [] l_len = 6 def listLoader(nums): i = 0 while i < nums: print "At the top i is %d" % i numbers.append(i) i += 1 print "Numbers now: ", numbers print "At the bottom i is %d" % i listLoader(l_len) print "The numbers: " for num in numbers: print num
e735adef2309edc03f5bf7f51a8f065ae045e756
gitHirsi/PythonNotes
/001基础/011推导式/02for循环嵌套实现列表推导式.py
203
4.21875
4
""" @author:Hirsi @time:2020/6/1 21:48 """ list1=[] for i in range(1,3): for j in range(3): list1.append((i,j)) print(list1) list2=[(i,j) for i in range(1,3) for j in range(3)] print(list2)
339028bde15f203041efd83454feb2d85cf8a973
HONGghddlwkdrns/cit_JHL
/200206/for.py
92
3.578125
4
number = [5,4,3,2,1] print (len(number)) for jh in number: print(jh) print("발사!")
abb2aa6e99f59695fb21c9120da70fd32a5397c5
weiyuyan/LeetCode
/剑指offer/27. 数值的整数次方.py
1,237
3.875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # author:ShidongDu time:2020/2/14 ''' 实现函数double Power(double base, int exponent),求base的exponent次方。不得使用库函数,同时不需要考虑大数问题。   示例 1: 输入: 2.00000, 10 输出: 1024.00000 示例 2: 输入: 2.10000, 3 输出: 9.26100 示例 3: 输入: 2.00000, -2 输出: 0.25000 解释: 2-2 = 1/22 = 1/4 = 0.25   说明: -100.0 ...
83af0ce9ea9b9f39203fd5a14aa049b0be1de7b8
lezelelena/python
/shufflePO_noseed.py
685
3.78125
4
#!/usr/local/bin/python3 import random import os l = [] try: gr_c = int(input("How many teams participating? ")) except ValueError: print("Not a digit, please try again"); exit() while gr_c < 2 or gr_c % 2 != 0: print("Wrong amount of teams"); gr_c = int(input("How many teams participating? ")) for i in range ...
d5d978289abcebd755cc71e6de790d41a483514b
hampusrosvall/leetcode
/merge_two_linked_lists.py
1,075
3.859375
4
class ListNode: def __init__(self, value): self.val = value self.next = None def merge_lists(l1: ListNode, l2: ListNode): dummy_head = ListNode(0) curr_first = l1 curr_second = l2 node = dummy_head while curr_first and curr_second: if curr_first.val <= curr_seco...
f25bb64b8885e3c5f99445961addc7e476851714
anguillanneuf/bigO
/22 coin.py
1,869
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Nov 11 17:37:31 2017 @author: tz input --- amount = 4 denominations = [1,2,3] output --- number of ways = 4 0 1 2 3 4 [0, 0, 0, 0, 0] coint = 1 range(1,5) [1, 0, 0, 0, 0] [1, 1, 0, 0, 0] [1, 1, 1, 0, 0] [1, 1, 1, 1, 0] [1, 1, 1, 1, 1] coin = 2...
15d5fd943024946a8295f2392d796be8efede53d
Aleksandra-AK/Modul---13
/modul_13.py
390
3.765625
4
ticket = int(input('Введите количество билетов: ')) s = 0 for i in range(1, ticket+1): age = int(input('Введите возраст: ')) if age < 18: s += 0 elif 25 > age >= 18: s += 990 elif age >= 25: s += 1390 print("Сумма заказа: ", s) if ticket > 3: print('Сумма со скидкой: ', s*0.9...
76f4105eff1740e4e0c6667756acd13701d82694
CKMaxwell/Python_online_challenge
/edabit/4_Hard/Words_With_Duplicate_Letters.py
407
3.78125
4
# 20200909 - Words With Duplicate Letters def no_duplicate_letters(phrase): phrase = phrase.lower() word = map(list, phrase.split( )) for i in word: word_set = set(i) word_list = list(i) if len(word_set) == len(word_list): continue else: return False ...
0ea72852820a63c257998e06998f5ec5706e762b
shelldweller/Mars-Rover
/mars_rover/rover.py
2,271
3.671875
4
import logging from .datastructures import Point class Rover(): DIRECTIONS = ('N', 'E', 'S', 'W') def __init__(self, max_point: Point, landing_point: Point, direction: str, name: str): assert direction in self.DIRECTIONS, \ f'Invalid direction {direction}; expected one of {self.DIRECTION...
924b0b9a8dd96b08090a076be67658b8f8c4018c
YuanyuanZh/MapReduce
/hamming.py
3,880
3.515625
4
class Hamming(object): def get_hamming_code(self,binary_str): binary_list = list(binary_str) for i in range(4): binary_list.insert(2**i-1,0) sum =0 for j in [0,2,4,6,8,10]: if binary_list[j] == '1': sum +=1 binary_list[0] = str(sum...
3e60aca70015f4a5ed83ad5e2b9b343a1bcecb5b
GanGaRoo/Langtangen
/Chapter_one/Formulas.py
691
3.953125
4
# -*- coding: utf-8 -*- import math print("The First Programming Encounter: a Formula") v0 = initial_velocity = 5 g = acceleration_of_gravity = 9.81 TIME = 0.6 VerticalPositionOfBall = initial_velocity*TIME - \ 0.5*acceleration_of_gravity*TIME**2 print("The Vertical Position Of The Ball is {} meters".format(Vert...
3861e45d9fe4f61a67a76182c63a7d9ba5fb0c08
ChloeDumit/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
986
4.03125
4
#!/usr/bin/python3 """Divide all elements of a matrix """ def matrix_divided(matrix, div): """ Function to divide elements of a matrix """ e1 = "Each row of the matrix must have the same size" e2 = "matrix must be a matrix (list of lists) of integers/floats" new_matrix = list(map(list, matrix)) ...
99ddf74ccfdb28a3b1d0e025e550e7b7b1b5233f
saradbb/Etch-A-Sketch
/main.py
1,248
4.125
4
from turtle import Turtle,Screen #Simple Etch-A_Sketch Using Turtle # KEYS AND WHAT THEY DO: # W Move forward # S Move Backward # A counter-clockwise turn # D clockwise turn # C clear sketch_turtle =Turtle() def initialize_position(): sketch_turtle.setheading(0) sketch_turtle.penup() sketch_turtle.goto(STA...
32e0d19f0fcf66f49ba8f8b468e1b65afdaa08b9
9Brothers/Learn.Python
/06_files.py
248
3.734375
4
# my_file = open("files/texto.txt") # text = my_file.read() # print(text) # text = my_file.readline() # print(text) # my_file.seek(0) # text = my_file.readline() # print(text) my_file = open("files/text.txt") for line in my_file: print(line)
a1424111bb75dfcd60054d47a67c91ed53a53880
vtrbtf/hackerrank-algorithms
/implementation/kangaroo/main.py
242
3.640625
4
#!/usr/bin/env python3 x1, v1, x2, v2 = [int(n) for n in input('').split(' ')] if (x1 > x2 and v1 >= v2) or (x2 > x1 and v2 >= v1): print("NO") else: if (x1 - x2) % (v2 - v1) == 0: print ("YES") else: print ("NO")
11d7feae06b0316b2ef17d3dc7339d57587f602a
iproduct/intro-python
/acad_2022_01_intro/comprehensions.py
984
3.75
4
from functools import reduce from math import sqrt if __name__ == "__main__": l = [x * x for x in range(1, 11)] print(l) def is_prime(n): for i in range(2, int(sqrt(n))): if n % i == 0: return False return True n = 10 primes= [i for i in range(2, n + 1)...
d097713c99b1fbb893212b79d5dd528220235d5c
ironsubhajit/Udemy_course
/DBMS/utils/database_sql.py
1,000
3.578125
4
from utils.database_connections import DatabaseConnections def create_book_table(): with DatabaseConnections('data.db') as cursor: cursor.execute('CREATE TABLE IF NOT EXISTS books(name text primary key, author text, read integer)') def get_all_books(): with DatabaseConnections('data.db') as cursor: ...
0cc99bb427495d9efe7773a0b4e8f952d04f24e4
Gnorbi951/4th_battleship
/final_battleship_2_player.py
12,801
3.625
4
import random def ai_user_input(player_tips=None): # need of checking the already guessed values isItGuessed = True # init while isItGuessed == True: row_input = True col_input = True while col_input: try: col = int(input("Column: ")) if ...
655202b53dec6e356d3b8cdf68235ea1968e6bc1
You-NeverKnow/Cracking-the-coding-interview
/2/2.6.py
3,499
3.8125
4
from Node import Node # -----------------------------------------------------------------------------| def main(): """ """ _list = Node().init_from_list(list("CAS")) print(is_palindrome_recursive(_list)) print(is_palindrome_stack(_list)) print(is_palindrome(_list)) # ------------------------...
c527a2d7aa83ba214a6cace7b78ed76e2a8a6712
IgoAlgo/Problem-Solving
/choieungi/NewThisIsCT/12_12 기둥과 보.py
868
3.765625
4
def check_possible(ans): for x, y, installed in ans: if installed == 0: if y == 0 or [x - 1, y, 1] in ans or [x, y, 1] in ans or [x, y - 1, 0] in ans: continue return False elif installed == 1: if [x, y - 1, 0] in ans or [x + 1, y - 1, 0] in ans ...
66e54512575aa689c4f4626b5f8627e2f0255ad9
jamal357/hello-world
/flip_clock.py
1,935
4.21875
4
import time secsnow = 0 def twentyfourh(): hoursnow = int(input("Enter the current hour in 24 hour format")) minutenow = int(input("Enter the current minute")) seconds = 0 for hours in range (24): hours = hours + hoursnow for mins in range(60): mins = mins + minutenow ...
d568b4ec4e8e110d4206ffaa0602d49fd9df2682
sureshyhap/Python-Crash-Course
/Chapter 9/8/privileges.py
1,506
3.703125
4
class User(): """User profile""" def __init__(self, first, last, nick, country, age): self.first_name = first self.last_name = last self.nickname = nick self.country = country self.age = age def describe_user(self): print(self.first_name.title() + " "...
6a3aee8c9dc30573306576fc20dc3ec6559f695c
FreshOats/RollerCoaster
/Steel_and_Wood.py
2,027
3.671875
4
import pandas as pd import matplotlib.pyplot as plt wood = pd.read_csv('Golden_Ticket_Award_Winners_Wood.csv') steel = pd.read_csv('Golden_Ticket_Award_Winners_Steel.csv') print(wood.head()) print(steel.head()) # load rankings data here: def plot_rank(coaster, park, df): rankings = df[(df["Nam...
65515c169802b0d55f3dfa458957225c54b91837
dansmyers/Simulation
/Sprint-1-Python_and_Descriptive_Statistics/Examples/guessing_game.py
1,028
4.15625
4
""" A number guessing game Demonstrates the while loop and conditionals """ # randint is another random function that generates integers from a given range from random import randint # Pick a random target value target = randint(1, 1000) guesses_remaining = 10 while guesses_remaining > 0: # Prompt for a g...
610523726c6bbc705c86ddabc561a19e2a76aa35
wrthls/bmstu-5sem
/AA/rk_2/main.py
3,718
3.78125
4
import re def get_symb_type(char): if len(char) == 0: return -1 if char == '.': return 'dot' elif char == ' ': return 'space' elif ord('А') <= ord(char) <= ord('Я') or char == 'Ё': return 'capital' elif ord('а') <= ord(char) <= ord('я') or char == 'ё': retur...
e100f9f293132c9bdf6ae8323683fe265d4b9110
GauthamVarmaK/CBSE-XI-XII-Record-Programs
/Class XI/11-Greatest among two numbers2.py
184
4.125
4
num1=int(input('Enter 1st number ')) num2=int(input('Enter 2nd number ')) if num1>=num2: print(num1,'is greater than or equal to',num2) else: print(num2,'is greater than',num1)
7c2e92172c019c38075f9f8d644511181239f0d0
anjaligeda/Pythonstring-branch
/lnbsplitlist.py
481
3.71875
4
#adding elements in list q=[] for i in range(20): a=int(input('enter number = ')) q.append(a) print(q) #slicing the list l2=q[0:5] l3=q[15:20] l4=l2+l3 print(l4) #squaring the elements of list square=[i**2 for i in l4 ] print(square) #splitting the list length = len(l4) middle_index = length ...
6bc88a4ae524c8e5f2102628537ebb0b76c74bb3
AndrewPau/interview
/maxHistogramArea.py
1,391
4
4
""" Given an array of heights, find the maximum rectangular area of the array. """ def maxArea(array): stack = [] maxArea = 0 for index in range(len(array)): # If it's empty or you have a larger element, add it. if len(stack) == 0 or stack[-1][1] <= array[index]: stack.append((in...
97b4020968a5b700f8060988bbd61ec7145397c1
ramonvaleriano/python-
/Livros/Livro-Introdução à Programação-Python/Capitulo 8/Exercicios 8/Exercicio8_4.py
415
4.0625
4
# Program: Exercicio8_4.py # Author: Ramon R. Valeriano # Description: # Developed: 05/06/2020 - 11:38 # Updated: def area_triangulo(base, altura): if base>=0 and altura>=0: area = ((base*altura)/2) return area else: return 0 base = float(input("Enter com a base de um triângulo: ")) alt...
a3d311efe4643a04aa58fea89dd31bab058e1328
aamerino/EjerciciosClase
/ejercicio Billetes.py
1,052
3.71875
4
def calcularBilletes (importe, billete): numeroDeBilletes = importe//billete return numeroDeBilletes def calcularResto (importe, billete): importeResto = importe % billete return importeResto def contadorBilletes (importe, billetes): for billete in billetes: numBilletes = int(calcularBilletes(import...
71d336a071ed87470f119d2368c537e5507b0f5d
menggod/python_laboratory
/test/find_it.py
332
3.53125
4
def find_it(seq): num_map = {} for num in seq: if num in num_map: num_map[num] = num_map.get(num) +1 else: num_map[num] = 1 for item in num_map.items(): if item[1]%2!=0: return item[0] print(find_it([20, 1, -1, 2, -2, 3, 3, 5, 5, 1, 2, 4, 20, 4, -...
96ce51bede2868cb2d6a02c4b56bc98041f3d262
drunkwater/leetcode
/medium/python3/c0351_767_reorganize-string/00_leetcode_0351.py
716
3.625
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #767. Reorganize String #Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same....
675853a5b6509fe7ab97e47495248d3bf38a6293
Dadajon/100-days-of-code
/competitive-programming/hackerrank/mathematics/12-restaurant/restaurant.py
1,131
4.25
4
def restaurant(length, breadth): """ Martha is interviewing at Subway. One of the rounds of the interview requires her to cut a bread of size lxb into smaller identical pieces such that each piece is a square having maximum possible side length with no left over piece of bread. :param length: the l...
c7e0b2fb37da2789c6f3413a3fa4c06a25dc035f
dong-pro/fullStackPython
/p1_basic/day27_31netpro/day30/02_考试题相关.py
762
4.21875
4
# ########## 第10题 v = [lambda: x for x in range(10)] print(v) print(v[0]) print(v[0]()) # 1.Python中函数时一个作用域;打印?报错 # 正确 # i = 0 # for i in range(10): # pass # 44444444444444444444444 # print(i) # 9 # 报错 # def func(): # for i in range(10): # pass # # func() # print(i) # 2.lambda表达式 # def f1(x): # ...
f1f2e202b31315ef4788b99f7cad0d47d6541da5
MarcinPietkiewicz/SortEfficiencyGraph
/src/quicksort.py
592
3.734375
4
from src.abstractsort import AbstractSort class QuickSort(AbstractSort): def __init__(self): super().__init__() self.sort_method_name = 'Quick sort' def get_numbers_list(self, numbers: list): print('I should get numbers list here ', numbers) self.numbers = numbers def sor...
e8b470bc85e86daffad2df83c3a3364292ef4509
LiriNorkin/myCollage
/GUICollage.py
971
3.71875
4
import tkinter as tk from PIL import Image,ImageTk from tkinter import filedialog import myCollage root = tk.Tk() root.title('Collage Maker') label1 = tk.Label(root, text="Collage Maker", fg="black", bg="pink", height="30", width="70") label1.pack() global imgs def open(): filez = tk.filedialog.asko...
aff5de85c68ad5e908fcb87e1da609d2aa904f1c
INNOMIGHT/hackerrank-solutions
/LinkedLists/insertion_of_nodes_at_diff_pos.py
1,199
3.9375
4
class Node: def __init__(self, data): self.data = data self.next = None class SinglyLinkedList: def __init__(self): self.head = None def insert_at_head(self, data): new_node = Node(data) new_node.next = self.head self.head = new_node def insert_at_ta...
53f8620710aaa648f9df26a03e4ac76a9227c383
aidris823/Bresenbacon
/line_draw.py
2,164
3.84375
4
from display import * import math def draw_line(x0,y0,x1,y1,screen,color): # float slope = (max(y0,y1) - min(y0,y1)) / (x1 - x0)) #Octant 1 / 5 draw_line_one(x0,y0,x1,y1,screen,color) #Octant 2 / 6 #Octant 7 / 3 #Octant 8 / 4 delta_y = y1 - y0 delta_x = x1 - x0 if (delta_y > 0):...
af53224511886f323fa4a0840cb2ad27ef4b99b6
ceciliawambui/byte_of_python
/ex34.py
242
3.765625
4
animals = ['bear', 'python 3.6', 'peacock', 'kangaroo', 'whale', 'platypus'] print("The animal at 1 is", animals[1]) print("The animal at 3 is", animals[3]) print("The animal at 2 is", animals[2]) print("The animal at 4 is", animals[4])
35828fd305f69e633c559159070d4bf25ba9b637
baomanedu/Python-Basic-Courses
/课程源码/03-list.py
906
4
4
##定义 a = [] print(type(a)) numlist = [1,2,3,4,5,6] strlist = ["a","b","c","d"] print(numlist,strlist) ##获取list元素 print(numlist[3],strlist[2]) print(numlist[:5]) print(len(numlist)) ## 应用 ipAddress = [r"192.158.0.1",r"192.168.0.2"] print(ipAddress) ## 遍历 for ip in ipAddress: print(ip) #内置函数 testHosts = ["aa...
1fb5a6782cc5bc87506a5fd39ee5b3e8768a94bc
EdisonZhu33/Algorithm
/备战2020/035-全排列2.py
1,086
3.71875
4
""" @file : 035-全排列2.py @author : xiaolu @time : 2020-02-03 """ ''' 给定一个可包含重复数字的序列,返回所有不重复的全排列 输入: [1,1,2] 输出: [ [1,1,2], [1,2,1], [2,1,1] ] ''' from typing import List class Solution: def permuteUnique(self, nums: List[int]) -> List[List[int]]: result = [] def permute(nums, tmp): ...
8bb3b05bf40c612961bfe8338c74743a99983386
sarvparteek/Data-structures-And-Algorithms
/recursiveEvenOutput.py
569
3.984375
4
__author__ = 'sarvps' ''' Author: Sarv Parteek Singh Course: CISC 610 Term: Late Summer Final exam, Problem 2 Brief: Print out positive even numbers between two given numbers using recursion ''' def evenOutput(lower,upper): if upper - lower <= 1: if lower %2 == 0: print(low...
2fa8f63ba8d39e51838cfffd5899a569c3ecbca0
aligg/markov-chains
/markov.py
2,331
3.984375
4
"""Generate Markov text from text files.""" from random import choice # import random def open_and_read_file(file_path): """Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. """ opened_file =...
a425457bc80922af57eb415cbd49d80ae975e70f
Alejandro-Gonzalez-Barriga/learningPython
/python3basics/dictionaries.py
1,447
4.75
5
##Dictionaries is a collection of key-value pairs ## in order to return a value in a dictionary it must be referenced using the key #dictionaryName = {key1:value1, key2:value2, key3:value3} steakPrices = {"sirloin":18.99, "t-bone":27.99, "ribeye":29.99} print(steakPrices) #prints {'sirloin': 18.99, 't-bone': 27.99, 'ri...
c37b8b4009778c4a85d141bcdb7833a9304ab0e7
hernandez232/FP_Tareas_00075919
/División.py
161
4
4
n = int (input("Ingrese un numero: ")) n2 = int (input("Ingrese un numero: ")) div = (n/n2) print (" ") print ("La división de los numeros ingresados es:",div)
5238c5cddd8fd5c6979672f7bba61962e94e1fa1
YoushaExT/practice
/moreproblems/q39.py
315
4.1875
4
# Define a function which can generate a list where the values are square of numbers between 1 and 20 (both included). # Then the function needs to print the last 5 elements in the list. def myFunc(): L=[] for i in range(1,21): L.append(i**2) print(L[-5:]) #[startIncluded:stop:step] myFunc()
7993bb5446cb24becaba1dca7caf3791f2adc47b
LaurenGeis/PythonNotes
/strings.py
957
4.5625
5
# escape characters # use backslash \ followed by character to add in a string # example: print('go to Dana's house) does not work, tries to create variables after 's house. print('go to Dana\'s house') # \n is for newline print('Hello \nhow are you today? \nI am well') #putting r in front of a string, this is a ...
547ba649fa219f39830b262c6b37641fa02785b4
ejmurray/Codeacademy
/Loops/ex10.py
123
3.796875
4
hobbies = [] # Add your code below! for i in range(3): hobby = raw_input("Enter a hobby: ") hobbies.append(hobby)
b96f7709ac41f65bc34b60539e26978fec132035
gjogjreiogjwer/jzoffer
/其他/扑克牌顺子.py
1,278
3.96875
4
# -*- coding:utf-8 -*- ''' 扑克牌顺子 从扑克牌中随机抽5张牌,判断是不是一个顺子,即这5张牌是不是连续的。 2~10为数字本身,A为1,J为11,Q为12,K为13,而大、小王为 0 ,可以看成任意数字。A 不能视为 14。 example1: 输入: [1,2,3,4,5] 输出: True example2: 输入: [0,0,1,2,5] 输出: True 解: 输入5个数;在0-13之间;除大小王外无重复;大小差值<=5 ''' class Solution(object): def isStraight(self, nums): """ :type...
d321b1c4902ec8f4c546e54b821a8cf9f9d9b70a
pdjan/fcc
/Scientific Computing with Python/Shape_calculator.py
1,863
3.984375
4
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def __str__(self): return Rectangle.__name__ + "(width=" + str(self.width) + ", height=" + str(self.height) + ")" def set_width(self, w): self.width = w ...
e753701fce495c27c930ecd12b5a622db1bdd5e4
soundary219/python
/abs.py
237
3.765625
4
from abc import ABC,abstractmethod import math class shape(ABC): @abstractmethod def getArea(): pass class Circle(shape): def getArea(self): return math.pi*5*5 circle=Circle() print(circle.getArea())
bd84147762cdc829429aa89542f9ac3310708569
rlongo02/Python-Book-Exercises
/Chapter_6/6-11_Cities.py
559
3.78125
4
SA = {'country': 'the united states', 'population': '1.493 million', 'fact': 'home to the Alamo'} CS = {'country': 'the united states', 'population': '464,474', 'fact': 'my birthplace'} GB = {'country': 'the united states', 'population': '69,499', 'fact': 'where my school is'} cities = {'san antonio': SA, 'colorado sp...
ed30249be3e7e2156b58e18db0c131cbe8accf7b
NishchaySharma/Competitve-Programming
/Codechef/Area or perimeter.py
173
3.734375
4
l=int(input()) b=int(input()) if l*b>2*(l+b): print('Area',l*b,sep='\n') elif 2*(l+b)>l*b: print('Peri',2*(l+b),sep='\n') else: print('Eq',l*b,sep='\n')
bd609d3981ec2aca30fb9a993271b9e78860de92
shlampley/learning
/learn python/codewars.py
268
3.875
4
def disemvowel(string_): vowels = ('a', 'e', 'i', 'o', 'u',) for x in string_: if x in vowels: string_ = string_.replace(x, "") return string_ teststring = "This is a test string with several words\n" print(disemvowel(teststring))
ee5680eda52ca273ee33f32416a20d175f094fb4
Gera2019/gu_python
/lesson_5/task_1_2.py
433
4.21875
4
def odd_nums(n): result = (num for num in range(1, n + 1, 2)) return result # for num in range(1, n+1, 2): # yield num # другой вариант вывода нечетных чисел, при использовании yield # print(type(result)) # print(odd_nums(7) # result = odd_nums(7) # print(next(result), next(result), next(result), ...
1b886a864782904b8aa2b4b4f900b65ae91b0a14
gschen/where2go-python-test
/1906101038江来洪/day20191217/Test_3_2.py
627
3.5625
4
#查验身份证是否是正确的 N = int(input('请输入你要查验身份证的个数:')) list1 = [] list2 = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2] list3 = [1,0,'x',9,8,7,6,5,4,3,2] for i in range(N): n = int(input('请输入你要查验的身份证号码:')) for a in range(2,19): m = (n%(10**a))//(10**(a-1)) s = n%10 a += 1 list1.append(m) list...
31048002b75edba6cfd1a9b6cbd2a25efae76242
papalagichen/leet-code
/0231 - Power of Two.py
394
3.515625
4
class Solution(object): def isPowerOfTwo(self, n): i = 1 while i <= n: if i == n: return True i *= 2 return False if __name__ == '__main__': import Test Test.test(Solution().isPowerOfTwo, [ (0, False), (1, True), (2, ...
4f1b722bd93b7538f12106d018836f9858c5d120
King9587/Interesting-projects
/飞机大战/plane_sprites.py
3,852
3.578125
4
import random import pygame # 屏幕大小的常量 SCREEN_RECT = pygame.Rect(0, 0, 480, 700) # 创建敌机的事件 CREATE_ENEMY_EVENT = pygame.USEREVENT # 英雄飞机发射子弹的事件 HERO_FIRE_EVENT = pygame.USEREVENT + 1 class GameSprite(pygame.sprite.Sprite): """游戏主类——继承自pygame.sprite.Sprite""" def __init__(self, image_name, speed=1): #...
869e88c5fa20594b85a6d3d0f8296c1c0521aa0c
SkippyWiggly/SkippyLearnsPython
/ex15.py
960
4.375
4
#imports argv to use for user input from sys import argv #outlines the two inputs we need from user #(the script to load and the filename we'll load) script, filename = argv #defining variable txt as a file object that is opened via the open function. #not necessary to define txt variable, can simply do open(filename...
7b1fb533023fdd6e11ac1aa49356d014dd6e62a1
bgg7547/date_structure
/2020.10.09/02栈.py
1,635
4.0625
4
# # 数组实现栈 # class Stack: # def __init__(self): # self.stack = [] # self.size = 0 # # #压栈 # def push(self,data): # self.stack.append(data) # self.size += 1 # # #弹栈 # def pop(self): # if self.stack: # temp = self.stack.pop() # self.size -...
d6cda1dc01d2f063d59aed48ad92dbd77d83ff2c
dunnette/ctci
/Chapter1.py
3,156
4.125
4
# 1.1 # Implement an algorithm to determine if a string has all unique characters. # What if you can not use additional data structures? def all_unique(s1): return len(s1) == len(set(s1)) def all_unique_no_structs(s1): for c in s1: if s1.count(c) > 1: return False return True # 1.2 #...
503863dcdd5ed24fee2f6d05d29b25a24748a90d
shiniapplegami/NIELIT
/Python_Codes/DAY27/DAY27.py
628
3.640625
4
import pandas as pd import numpy as np #------------------------------------------------------------------------------------- drinks=pd.read_csv("drinks.csv") print drinks.head() print "=======================" group=drinks.groupby('continent') print "\nContinent that drinks more beer on average :",group['beer_servin...
0ba9c66696b0b8a6f93d0f48e690a1dfa6084f76
otecilliblazh/New
/triangle2.py
324
4
4
r=int(input("Введите высоту :")) c=r*2-1 x=0 for i in range(r): for j in range(c): if j==c//2-x or j==c//2+x or i==r-1: print("*", end=" ") elif c//2-x<j and c//2+x>j: print("*", end=" ") else: print(" ", end=" ") x=x+1 print() print()
d420487746d453766dba6c07946925311fba04ce
mebaysan/LearningKitforBeginners-Python
/basic_ödevler/döngüler ödev dosyası/100ekadar3ebölünensayılar.py
382
3.828125
4
print(""" ************************* 1'den 100'e kadar olan sayılardan sadece 3'e bölünen sayıları ekrana bastırın. Bu işlemi continue ile yapmaya çalışın ************************* for i in range(1,101): if (i % 3 != 0): continue print(i) """) for i in range(1,101): ...
7389eb6ab215924a2fe5f45f2494a6fdb82d8e98
minhluanlqd/AlgorithmProblem
/problem13.py
981
3.9375
4
"""""" """ This problem was asked by Apple. #273 A fixed point in an array is an element whose value is equal to its index. Given a sorted array of distinct elements, return a fixed point, if one exists. Otherwise, return False. For example, given [-6, 0, 2, 40], you should return 2. Given [1, 5, 7, 8], you s...
dcd9d136edcf4ce49e82c75dea958404ff4adea1
jjbernard/100DaysOfCode
/Days 16-18/D17.py
626
3.828125
4
import random import itertools NAMES = ['arnold schwarzenegger', 'alec baldwin', 'bob belderbos', 'julian sequeira', 'sandra bullock', 'keanu reeves', 'julbob pybites', 'bob belderbos', 'julian sequeira', 'al pacino', 'brad pitt', 'matt damon', 'brad pitt'] name_list = [name.title() for nam...
a8a8443daaeab7cd059a1050d5856d3f71de3b29
TheMiloAnderson/data-structures-and-algorithms
/Py401/radix_sort/radix_sort.py
805
4.0625
4
def radix_sort(arr): """ Implements radix sort in conjunction with counting sort function below """ if len(arr) > 0: biggest_number = max(arr) exp = 1 while biggest_number/exp > 1: counting_sort(arr, exp) exp *= 10 def counting_sort(arr, exp): """ Implem...
c3f622e303a004de4071b5f263d6508e09ca99c9
sangha25/PythonTutorials
/FindingAge.py
224
3.921875
4
import datetime #This Library will import computer Timer. DOB=input("Enter your Date of Birth:") #date of current system. CurrentYear=datetime.datetime.now().year Age=CurrentYear-int(DOB) print("Your age is {}".format(Age))
dc2b416ab47bf97b1913502be3306b7751d8ed73
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe072.py
757
3.890625
4
""" Counting fractions Problem 72 Consider the fraction, n/d, where n and d are positive integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction. If we list the set of reduced proper fractions for d ≤ 8 in ascending order of size, we get: 1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5...
a1bbaa171729de5727a5e3dc7463421cd953e7fc
firstgenius/-Filming-Location-Next-To-Me
/main.py
5,137
3.5625
4
''' This module creates a web map. The web map displays information about the locations of films that were shot in a given year. ''' def read_info(file_path: str, year: str) -> list(): ''' This function reads the movies of the desired year from the list, lists them, replaces them with coordinates and retu...
0a618218aa261dee2bff504c3787447baa6d5426
saetar/pyEuler
/not_done/py_not_started/euler_448.py
493
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # ~ Jesse Rubin ~ project Euler ~ """ Average least common multiple http://projecteuler.net/problem=448 The function lcm(a,b) denotes the least common multiple of a and b. Let A(n) be the average of the values of lcm(n,i) for 1≤i≤n. E.g: A(2)=(2+2)/2=2 and A(10)=(10+10+30+2...
c88784356587f987135738ee08d8869fd40fb89d
yu-linfeng/leetcode
/python/20_valid_parentheses.py
681
3.84375
4
class Solution: """ 是否是合法的括号,括号成对出现 """ def isValid(self, s): """ :type s: str :rtype: bool """ parentheses = {'{' : '}', '[' : ']', '(' : ')'} stack = [] for i, item in enumerate(s): if item in parentheses.keys(): stack...
8cfe18b4c044c7d92dac02a1dd626e672ce5e7d6
letivela/AnitaBorg-Python-Certification-Course
/Week 6 Coding Challenges/Flow Control Statements/rightTriangle.py
2,060
4.625
5
# SCRIPT: rightTriangle.py # AUTHOR: Sahar Kausar # CONTACT: saharkausar@gmail.com # # Anita Borg - Python Certification Course # # DESCRIPTION: Anna likes to draw right angled triangles. She recently learnt how to code in Python, and she is curious to see if it can be used to print the same. # ...
d66b2aee72ec93cd0a58b274b442f952578446c7
gfpp/MITx6001x2017
/ex/week3_biggest.py
1,181
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 2 17:49:29 2017 @author: gfpp """ # Exercise: biggest # Consider the following sequence of expressions: animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']} animals['d'] = ['donkey'] animals['d'].append('dog') animals['d'].append('d...
067a95caabeef03368f80d3f8cf1062a4e233d8f
kmggh/cards
/play_lots_of_poker.py
1,155
3.625
4
#!/usr/bin/env python # Copyright (C) 2013 by Ken Guyton. All Rights Reserved. """Play many poker hands.""" import cards import hand import player NUM_HANDS = 1000 def improve_hand(the_player, deck): """Optionally throw out a card and draw another one.""" this_hand = hand.Hand(the_player.cards()) if this_...
f27cf24d5ac7b70478883102f72274717f9467fb
maximilianogomez/Progra1
/Practica 5/5.4.py
650
3.6875
4
# Todo programa Python es susceptible de ser interrumpido mediante la pulsación de # las teclas Ctrl-C, lo que genera una excepción del tipo KeyboardInterrupt. Realizar # un programa para imprimir los números enteros entre 1 y 100000, y que solicite # confirmación al usuario antes de detenerse cuando se presione Ctr...
438ab9d7b217a8361d7cb5600bb1fe83e30ea99d
joselpereda/python-lab_06
/L6_4.py
925
3.5
4
#P6_6 Write a binary pickle file for serialization import pickle #std library for pickle file support from random import randrange #support from randam data #generate random data from a dictionary d = {} for each in range(65,95): d[chr(each)] = ...
0f6f5c0dcd441d5da0ba595ff11aebc82407a4b8
buurro/interviews
/solutions/algorithms/fizzbang.py
237
3.6875
4
''' Problem: For the numbers 1 to 100, print fizz if divisible by 3, bang if divisible by 5. ''' print(', '.join(('fizz bang' if ii % 15 == 0 else 'fizz' if ii % 3 == 0 else 'bang' if ii % 5 == 0 else str(ii) for ii in range(1, 101))))
6d56e3132c60a29dd757bc0e2f47ace368f4459a
Yigang0622/LeetCode
/hIndex.py
435
3.8125
4
from typing import List # 274. H 指数 # https://leetcode-cn.com/problems/h-index/ class Solution: def hIndex(self, citations: List[int]) -> int: citations.sort(reverse=True) n = len(citations) # print(citations) i = 0 while i < n and i + 1 <= citations[i]: print(...
3e55998824cc3d02f5356c4561d8004d7243d4bb
PDXCodeGuildJan/SarahPDXCode2016
/Algorithms/bubbles.py
2,375
4.4375
4
unsorted_list=[6, 17, 9, 34, 4] print(unsorted_list) def bubble_sort(unsorted_list): #define a function listLength = len(unsorted_list) # 1)Find the length of the list #2) Compare the value of the current index and compare it with the value of the next index. firstItem = 0 while firstItem < lis...
692aaf8028b6cc5e887a369710b71f849119ab63
Retrnon/cse210-student-dice
/dice/game/thrower.py
815
3.640625
4
import random class Thrower(object): def __init__(self): """ Initializes object attributes """ self.dice = [] self.score = 0 def throw_dice(self): """ Clears previous Dice and throws Dice and randomizes 5d6 dice in self.dice """ self...
7ebdfdf519aaa85d76e5db870ee7655971280feb
jnst/x-python
/leetcode/q0002.py
997
3.734375
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: @classmethod def add_two_numbers(cls, l1: ListNode, l2: ListNode) -> ListNode: dummy = cur = ListNode(0) carry = 0 while l1 or l2 or carry: if l1: carry ...
fbf034dd3aa46185ee25d36f5bd82fbfb699a982
jpfogato/ObjDetc_RP3b-Autonomous_Vehicle
/Exemplos/functions.py
985
4.375
4
def jumpline(): print("\n") def my_function(): print("Hello World from a function") my_function() jumpline() def machado(name,surname): print(name + " " + surname + " Machado") machado("João","Paulo") jumpline() def multplicacao(input): resultado = 5*input return resultado print("resultado: "...