blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
00c509b57392c260e220534717f51a5a26b0d2b3 | Ayoyiinka/Automate-the-Boring-Stuff-with-Python | /chapter7RegularExpressions.py | 1,563 | 4.53125 | 5 | # Strong Password Detection
'''Write a function that uses regular expressions to make sure the password string it is passed is strong. A strong password is defined
as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit. You may
need to test the stri... |
683c83da7eb618834c45b06129f658737263a521 | MenMor/vectores_matrices_1 | /ejemplos_matrices.py | 1,117 | 3.640625 | 4 | import numpy as np
matriz = np.arange(12).reshape((3, 4))
print(matriz)
# diagonal = np.arange(matriz[range(0, 4), range(0, 4)])
# print(tablero[range(0, 7), range(0, 7)]) Diagonal principal
# Recorrer matriz invertida
matriz_1 = [[0, 1, 2, 3],
[4, 5, 6, 7],
[8, 9, 10, 11],
... |
08e1e111e5e0b08bc2660d628bc026874a9afcec | candyer/leetcode | /01317_getNoZeroIntegers.py | 1,475 | 4.1875 | 4 | # https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers/description/
# 1317. Convert Integer to the Sum of Two No-Zero Integers
# Given an integer n. No-Zero integer is a positive integer
# which doesn't contain any 0 in its decimal representation.
# Return a list of two integers [A, B] wh... |
ff64f6aac357cd8f80580e23bbddb34483e73a66 | ageekymonk/playground-1Kk9xRSj | /python-project/collections_namedtuple.py | 275 | 3.578125 | 4 | from collections import namedtuple
Contact = namedtuple('Contact', 'name, age, address')
jason = Contact(name='Jason Bourne', age='40', address='unknown')
print(jason)
print(f'Name: {jason.name} \nage: {jason[1]}')
name, age, address = jason
print(f'Name: {name} \nage: {age}')
|
1e7ed3d272aa191b5789ba2aa49fd068aa7dc079 | deepak1214/CompetitiveCode | /Hackerrank_problems/Triangle_Quest_2/Solution.py | 638 | 4.15625 | 4 |
'''
A positive integer N.
The task is to print a palindromic triangle of size N.
For example, a palindromic triangle of size is:
1
121
12321
1234321
123454321
'''
#Here in for loop the range from 1 to input+1
#It prints the number raised to power 10 and then divide by 9 and the whole result is having power 2.
#Th... |
b76cf9561679c97bd921fb45081e00b95bab06a9 | Carly-Schaaf/algorithms | /climb_stairs.py | 426 | 3.6875 | 4 | # class Solution(object):
def climbStairs(n):
"""
:type n: int
:rtype: int
"""
table = [None] * (n + 1)
for step in range(1, n + 1):
if step == 1:
table[1] = 1
elif step == 2:
table[2] = 2
else:
step1 = step - 1
step2 = ste... |
7739dcad5452e95099637e6d8cfa0f9b97000922 | kruOm/TicTacToe | /inputModule.py | 1,637 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 13:36:09 2020
@author: Unmesh
"""
import updateList as moduleupdateList
proceedOrInputAgain = 0
listOfChoices = [0]
def takeInput(XOrO):
inputString = XOrO
x = input(inputString)
try:
x = int(x)
except:
x=10
... |
f20ddc23865e24dd3bb3cf3fb9d7a0da0229a03f | akimi-yano/algorithm-practice | /lc/95.UniqueBinarySearchTreesII.py | 2,449 | 3.890625 | 4 | # 95. Unique Binary Search Trees II
# Medium
# 3772
# 244
# Add to List
# Share
# Given an integer n, return all the structurally unique BST's (binary search trees), which has exactly n nodes of unique values from 1 to n. Return the answer in any order.
# Example 1:
# Input: n = 3
# Output: [[1,null,2,null,3]... |
7d26759491796f378450db1fa8478d0006f19f29 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/meetup/08e4a68040744113a0ee4da13873cd68.py | 879 | 3.796875 | 4 | import datetime
def meetup_day(year, month, weekday, position):
weekdays = [
"Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday"
]
targ_weekday = weekdays.index(weekday)
### Default is teenth
targ_pos = -1
if position[0].isdigit(... |
f08009beae6ceb1dc0e53b25e13a0f15e43e5c4e | gdotmount/CS313E | /A12/boxes.py | 3,206 | 4 | 4 | # File: Boxes.py
# Description:
# Student Name: Gabriel Mount
# Student UT EID: gmm2767
# Partner Name:
# Partner UT EID:
# Course Name: CS 313E
# Unique Number:
# Date Created:
# Date Last Modified:
# generates all subsets of boxes and stores them in all_box_subsets
# box_list is a list of boxes th... |
0fc7d1572bb57a7885542beb5af6a51b23dc4128 | hoomanfor/python-crash-course | /04-working-with-lists/4-8_cubes.py | 83 | 3.59375 | 4 | cubes = [number**3 for number in range(1, 11)]
for number in cubes:
print(number) |
47ec92220447364c0ed45371d22fb6a6dbfb28a9 | Shen-Jianfei/MyCode-Python | /Exercises-PythonBasics-PekingUniversity/章节四作业2.py | 434 | 3.546875 | 4 | # 对列表元素进行分类后加标签存入字典。
# 输入一个列表,要求列表中的每个元素都为正整数且列表包含的元素个数为偶数;
# 将列表中前一半元素保存至字典的第一个键值1中,后一半元素保存至第二个键值2中。
alist = list(map(int, input().split()))
n = len(alist)
clist = alist[:int(n/2)]
dlist = alist[int(n/2):]
adict = {'1':clist, '2':dlist}
print(adict) |
6018e7440568448216e343843f8a168190fe1cd2 | CMNatic/Learning-Python | /BasicCalculator.py | 377 | 4.3125 | 4 |
num1 = input("Enter a number: ")
num2 = input("Enter another number: ")
# Python will always convert user input into a string, so we have to make it a number
# e.g. result = num1 + num2 will combine both inputted numbers together rather then adding
# int(num1) will only accept whole decimals
# so we need to use float... |
e5230bcfb6b0a383148d9be4670842f4f70e0727 | zhangrong1722/interview | /code/basis/smallest_dict_order.py | 1,227 | 3.578125 | 4 | class Prior:
def findSmallest(self, strs, n):
temp = [''] * n
self.merge_sort(strs, 0, n - 1, temp)
print(strs)
return ''.join(strs)
def merge_sort(self, strs, left, right, temp):
if left < right:
middle = (left + right) // 2
self.merge_sort(s... |
5f452e792f6cddbad9a4182d8ed1f0e54a387210 | vijayvammi/songsDB | /app/util.py | 914 | 3.609375 | 4 | import re
def get_config(config_params):
'''
Reads the credentials file to extract application specific configuration
parameters.
config_params is a list of params you seek
returns a dictionary of the parameters you asked if they exist in
credentials
Raises exception if one of the config_... |
d06e5dbe79392823f0bac4a3329d2f2a60ac0655 | ctir006/Python-and-C-code-submitted-in-HackerRank-contests | /Camel_case.py | 96 | 3.734375 | 4 | str=input()
count=1
for i in range(len(str)):
if str[i].isupper():
count+=1
print(count) |
d8654387c4735279f19b37f09894b909ee651bb7 | hadaszibalazs205/dogozat1 | /nyitvatartas.py | 585 | 3.8125 | 4 | #Egy bolt pontban reggel nyolc órakor nyit, és pontban délután tizenhat órakor zár be – azaz 8:00-kor már nyitva van és 16:00-kor már nincs nyitva. A program kérjen be egy egész órát jelző számot a felhasználótól,majd írja ki, hogy a megadott időpontban nyitva van-e a bolt! Amennyiben igen, akkor azt is írja ki, hogy m... |
bb95590a985e7c83baee8cb9f8cca8f7b0faf6f3 | stefikolo/pythonCrashCourse_learning | /chapter_007/chapter_007_ex.py | 1,447 | 4.21875 | 4 | # 7.1
def car():
what_car_input = input('What car do you want to rent? ')
print(f'Let me see if i can find you a {what_car_input}')
# 7.2
def guests():
how_many_guests_input = int(input('how many people are in the group? '))
if how_many_guests_input > 8:
print(f'you will have to wait')
else... |
b786e38ba791f4cbd53a758b3d9dc743a19d35e1 | benjaminellison/amgt340_python_final | /person.py | 3,148 | 3.71875 | 4 | #############
##
## Class for the person object/sprite
##
#############
#Imports
import pygame, random
class Person(pygame.sprite.Sprite):
#Constructor
def __init__(self, screen, healthy = True, width = 10, height = 10):
#parent class constructor
pygame.sprite.Sprite.__init__(self)
... |
27502305d6866c8f3ffe4395d07c0db71a2b8dd6 | Yozi47/Data-Structure-and-Algorithms-Class | /Homework 9-10/R-12.13.py | 787 | 4.0625 | 4 | '''
In this case when the condition left<=right is replaced with left<right
then there would be flaw as the function could not handle the condition
if left==right and the function will not decrease or increase in the value
due to which the function will continuously repeat by itself ced
if sequence S = [1, 23, 4... |
b58347cd79def462905ef8481b35b3c4f56cedcb | 974744840/Python_base | /day-12xiancheng.py | 1,368 | 3.96875 | 4 | import threading
import time
'''
方式一:类实现线程
1.继承父类的MyThread
2.重写run方法
3.start方法启动
'''
# class MyThread(threading.Thread): #继承父类方法
# def run(self):
# for i in range(1,11): #循环遍历
# print(threading.current_thread().getName(),i)#显示线程+数字
# time.sleep(0.1) #延时,定时器函数
# t1=MyT... |
bdb5818bafafe4b96dd5145a5f212d43a65bbc62 | Laurahpro/EXERCICIOS-EM-PYTHON | /ex000.py | 323 | 3.828125 | 4 | nome = input('Qual o seu nome?')
print('É um grande prazer te conhecer,', nome)
idade = input('Quantos anos você tem?')
print('Bacana que você tem', idade,'anos', nome,'!')
filho = input('Você tem filhos?')
print('Que bacana!')
nomeFilho = input('Qual o nome do seu filho?')
print('Então ele se chama', nomeFilho, '!') |
a8f03d410eab158faf811e8eac533b8ab9e3ae2c | qwerty-123456-ui/pythontuts | /sum30.py | 963 | 4.03125 | 4 | # # tuple--data str. but immutable--no append,no insert,no pop,no remove--once data created data can't be changed
# e=('one','two','three')
# d=('mon','tues')
# # tuples r faster than list
# # methods
# # count
# # index
# # len
# # slicing
# print(e[:2])
# # looping
# n=(1,2,3,4.0)
# for i in n:
# print(i)
# #... |
597a046a5cc1f3190cf438ca6445b97fd55ceca1 | kaptotonindet/Python | /first.py | 532 | 3.953125 | 4 | print("Hello World")
# for x in "banana":
# print(x)
# a=['peter','kiplangat','Towett']
# for a in a:
# print(a)
# #print(a)
# b=[20,31,76,32]
# sum=0
# for elements in b:
# sum=sum+elements
# print(sum)
# # c= list(range(1,11))
# # print(c)
# total=0
# for i in range(1,11):
# total=total + i
# prin... |
f3396fb0b2c871870055301d61ed0222cfd2569b | SoftwareDevEngResearch/SolarCalcs | /SolarCalcs/LocationComponents.py | 1,571 | 3.625 | 4 | #!/usr/bin/env python
# Author: Nicole Guymer
# Date: May, 16 2018
# File: LocationComponents.py
# Description: This file uses geopy to find the latitude and longitutde values, and time zones in decimal form for user given locations.
# Note: Not all addresses or locations can be found using geopy.
from geopy.geocode... |
66d57425a6303b76ed9401958fd2f56152ae02b0 | rafaelperazzo/programacao-web | /moodledata/vpl_data/117/usersdata/237/27473/submittedfiles/al2.py | 114 | 4.03125 | 4 | # -*- coding: utf-8 -*-
a=float(input("digite um numero qualquer:"))
print("a parte inteira do numero é: %d" % a) |
5557f7438277bb891b64385eaa141206c9eed6db | opencv/opencv | /samples/python/tutorial_code/ImgTrans/SobelDemo/sobel_demo.py | 1,913 | 3.546875 | 4 | """
@file sobel_demo.py
@brief Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
"""
import sys
import cv2 as cv
def main(argv):
## [variables]
# First we declare the variables we are going to use
window_name = ('Sobel Demo - Simple Edge Detector')
scale = 1
del... |
c927c8c217cec7eb07561d1d74cabb0cc9490206 | OscarEAlaniz/Python | /07-ejercicios/ejercicio6.py | 519 | 4 | 4 | """
Ejericico 6
Mostrar todas la tablas de multiplicar del 1 al 10
mostrando el titulo de la tabla y luego las multiplicaciones del 1 al 10
"""
numero_contador =0
numero_tabla =0
for cabecera in range(1,11):
print("########################################")
print(f"############ TABLA DEL {cabecera} ########... |
124172a027472b57a02422332c20bda4bc06255a | Addlaw/Python-Cert | /fluid_mechanics_aclawrence.py | 1,034 | 4.28125 | 4 | ################################################################################
# Author: Addison Lawrence
# Date: 2/4/2020
# Calculates the Reynold's number for for a pipe when given certain inputs
################################################################################
#asks user to in put velocity, p... |
50d9ff0c3ce3585fe84b6e791f191774562ecaa6 | kmsalah/pythonPractice | /even_odd_merge_LL.py | 458 | 4 | 4 | #even odd merge of a linked list
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
def even_odd_merge(head):
if not head:
return head
even_head = ListNode(0)
odd_head = ListNode(0)
tails = [even_head, odd_head]
turn = 0
curr = head
while curr:
tails[turn].next = curr
c... |
ce781b8051db1e144997f5bee9b9da21f36c2ba3 | renkeji/leetcode | /python/src/main/python/Q005.py | 837 | 3.890625 | 4 | from src.main.python.Solution import Solution
# Given a string S, find the longest palindromic substring in S.
# You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
class Q005(Solution):
def expand_center(self, s, i, j):
while i >= 0 and j < len... |
29b45f41d2cf08364f89897c1d3ea838d61050d5 | jaehoonhwang/advent-of-code | /aoc/twenty/day2/day.py | 2,641 | 3.703125 | 4 | import os
from aoc.utils.file_reader import read_file_line
from aoc.utils.file_reader import path_join
directory_path = os.path.dirname(os.path.realpath(__file__))
input_filename = "input.txt"
"""
Each line gives the password policy and then the password. The password policy indicates the lowest and highest number o... |
a75364a9eb063c0378603e3e65dbaeaf42adbf23 | limichel/twitch-chatbot-hackathon | /socket_setup.py | 1,030 | 3.8125 | 4 | import socket
class Socket:
def __init__(self):
'''Initializes a new socket with a read file and a write file'''
self.socket = socket.socket() # Creates a socket
self.input = self.socket.makefile('r') # Creates a file where we read outputs from the server
self.output = self.socket.makefile('w') # Creat... |
87cb4cff20e1d8e093310704dad61e3869dffe63 | kfz0131/DataScience-Hack | /sortLibsvmKeys.py | 2,171 | 3.578125 | 4 | def sortLibsvmKeys(inputPath,outputPath):
'''
This function requires an inputPath string and an outputPath string
The input file must already be in libsvm format as shown below
label key:value key:value key:value .......
The sorted libsvm file will be write to outputPath
'''
... |
2a17a9176272aaade8b0a5f6037d0fe11648d0ba | kiwanter/Python-Workspace | /work1/1-2.py | 103 | 3.578125 | 4 | dict={1:60,2:65,3:85,4:90,5:40,6:75,7:95,8:25,9:80,10:100}
print({k:v for k,v in dict.items() if v>80}) |
0301a2ab340ea26c190b901b720973873050c38a | wlgud0402/pyfiles | /error_file_closed2.py | 395 | 3.6875 | 4 | #파일처리 중간에 에외 발생
try:
file = open("info.txt", "w")
예외.발생합니닷()
file.close()
except Exception as e:
print(e)
# finally:
# file.close() >>>예외가 발생해서 파일을 닫지 않게되도 finally를 넣으면 무조건 닫기 가능
#finally 를 쓰지않고 마지막쪽에 file.close()를 써서 닫는것도 가능
print(file.closed) |
0bcd036c23b9794abca4b792463fd41beb57700c | JackMorash/School-Work | /CS30/Chapter 8/8-09.py | 221 | 3.9375 | 4 | def show_messages(messages):
"""Print all messages in the list."""
for message in messages:
print(message)
messages = ["Hello World", "I am a message!", \
"I am another message!"]
show_messages(messages) |
81d57e1038ead576cc312400799254f3715ff961 | Hopw06/Python | /Python_Deep_Dive/Part 1/7.Scopes-Closures-Decorators/12.DecoratorApplication(DecoratingClasses).py | 7,884 | 3.75 | 4 | ## Monkey Patching ##
from fractions import Fraction
Fraction.speak = lambda self: 'This is a late parrot'
f = Fraction(2, 3)
print(f)
print(f.speak())
Fraction.a = "something"
# f.a = "Or whatever" # read only
print(f.a)
Fraction.is_integral = lambda self: self.denominator == 1
f1 = Fraction(1,... |
d5763edf4bc9843f2918ccfe12453084a2d173ae | tundejulius17/Python2017 | /Ass6_2.py | 495 | 3.578125 | 4 | import re
text = "name=Milk;amount=200;unit_price=0.9\nname=Bread;amount=134;" \
"unit_price=3.48\nname=Butter;amount=58;unit_price=1.65\nname=Cheese;" \
"amount=260;unit_price=4.35"
products = re.split("\n", text)
#print(products)
sum = 0
for i in products:
product = re.split(";",i)
print(produ... |
ea85d44625fbe1583e49e7a794d69c5eb104a8d8 | Tgriff073/Connect4bot | /game.py | 6,742 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 5 15:25:13 2018
@author: thomas
Description: class is used to define what a game consists of, it will control the flow of the game
and perform functions like start the game, get user moves, and get ai moves.
a game object consists of a connect4 object(which is essentiall... |
7574fe85eec860329cc82ce555439c0dfee46472 | catydiaz4863/machine-learning | /Lab5/lab5_3.py | 134 | 4 | 4 | a = [1,2,3,4,5]
b = a[2]
print(b)
a.append(6)
print(a)
a[2] =7
print(a)
a = [1,2,3]
b = a[2]
print(b)
a1, a2, a3 = a
print(a1,a2,a3)
|
48552d7d81b816b9366ee826e16bc7e079cd424f | apdaza/universidad-ejercicios | /python/mod_ordenamiento.py | 1,445 | 4.375 | 4 | def burbuja(list):
"""Este metodo de ordenacion consiste en recorrer los elementos
siempre en la misma direccion, intercambiando elementos adyacentes
si fuera necesario"""
for n in range(len(list)):
for m in range(n,len(list)):
if list[n] > list[m]:
intercambiar(list,n,m)
def seleccion(list):
"""este m... |
af208808cb1cb3e26f77e81b91c5a67d4c399254 | ayaz03248/AI-LAB | /All Labs/Lab2/task3.py | 138 | 3.828125 | 4 | list = []
def sqr(x):
ans = x*x
return ans
for i in range(1,21):
list.append(sqr(i))
print(i," square is ",sqr(i)) |
0d8a88776a8f8d75166c4a76ae3fd35153719bf0 | pepitogrilho/learning_python | /cConsolidation/c_DataTypes/100_NoneObject_001.py | 418 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
The None object represent absence of a value = NULL
"""
if None==None:
print("Nooooone1 !")
if ""==None:
print("Nooooone2 !")
if []==None:
print("Nooooone3 !")
None
print(None)
"""
The None object is returned by a function that doesn't return anything
"""
def hello():
... |
f4232638a2c52374594f4f8d4bdda84aa4f51c22 | rohan345798/cipher | /cipherdriver.py | 184 | 3.5 | 4 | from key import key
from encrypt1 import encrypt
from decrypt1 import decrypt
d = key()
msg = str(raw_input('enter a message: '))
print encrypt(msg,d)
print decrypt(encrypt(msg,d), d)
|
6423de1df7dee7e6c287de814ab1ef6295c9b49f | prasannaaav/Data_Cleaning_project | /DataCleanerV2.py | 1,573 | 3.796875 | 4 | '''
Created on Feb 23, 2021
@author: prasanna
'''
import numpy as np
import pandas as pd
import tkinter as tk
from tkinter import filedialog
#1.Creating a dialog box enabling the user to select the desired excel
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 300, bg = 'lightsteelblue')
canvas1.pack()... |
843e4e246fda3f083fab4821f5e29ea8132f1324 | Oyanna/Decode_Python59 | /GUI_2/calculator.py | 2,020 | 3.625 | 4 | from tkinter import *
from tkinter.ttk import Combobox
class Example(Frame):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.master.title("Simple Menu")
menubar=Menu(self.master)
self.master.config(menu=menubar)
fileMenu=Menu(menubar)
... |
4e25e7ea83d393c3a67e5c71fa3e8a563d6eb91b | fabiovpcaumo/curso-de-python | /semana01/aula02/exercicio_05.py | 329 | 3.5 | 4 | lista = [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, 26, 27, 28, 29, 30]
def pin(lista):
saida = []
for numero in lista:
if (numero % 4 == 0):
saida.append("pin")
else:
saida.append(numero)
return saida
print(pi... |
6c224211afdf733a84ccbb82e6c9968e0193891f | MrJay10/Graph-Algorithms | /Taking input for Competitive Programming.py | 431 | 3.828125 | 4 | from Graph import Graph
graph = dict()
# Remove the message in input(); change str -> int for integer input
vertices = list(map(str, input("Enter vertices :: ").split()))
for vertex in vertices:
# Remove the message in input(); change str -> int for integer input
graph[vertex] = list(map(str, input(... |
911cc054274bf8edb97605be179be3810545c3f0 | RuosongZhang/linux_win | /test/testa/testf.py | 116 | 3.84375 | 4 | letters = ['a', 'b', 'c', 'd', 'e', 'f,' 'g']
for num , letter in enumerate(letters):
print(letter,'is',num + 1) |
727a938833440c5b3aa0c7dad135a1503aa86149 | MacKlinkachorn/NLP-Radiology- | /Glossify/xml_to_text.py | 2,131 | 3.53125 | 4 | # Small, ad-hoc program to convert reports in 'ecgen' folder from xml to txt
# Import lxml if you have it, otherwise xml
try:
from lxml import etree
except ImportError:
import xml.etree.ElementTree as etree
import sys
import os
import errno
# See lxml documentation for more info
def xml_to_dict(xmlfile):
... |
49edc5c02cf8c365e4679ce34a2ed6ee8648efa7 | EmaSMach/python-exercise | /exercise_1_3.py | 2,375 | 3.734375 | 4 | def ask_for_details():
details = {}
user_id = raw_input("User id : ")
while True:
first_name = raw_input("First Name: ")
if first_name.isspace() or len(first_name) != 0:
details["first_name"] = first_name
break
else:
print "Name should not be empty... |
ca1c08df89822a9b08f5ef77864bb08fffb1f5c4 | ShubraChowdhury/extra-references | /CastTensor.py | 418 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 29 16:19:03 2017
@author: shubra
"""
import tensorflow as tf
# TODO: Convert the following to TensorFlow:
x = 10
y = 2
z = x/y - 1
x = tf.constant(x)
y= tf.constant(y)
z = tf.subtract(tf.divide(x,y),tf.cast(tf.constant(1),tf.float64))
# TODO: Print z... |
339fe5458933100e806c2dfa6290b4193625cf49 | MrCuffe/TGPD2020S2_Demos | /5/my_game.py | 9,219 | 3.859375 | 4 | """
Bita Afshar Game development final phase
"""
import pygame
import time
from xlrd import open_workbook
# set up a way to use the maze on excel and import it into python
def load_maze(wb_filename=None, sheetnum=0):
"""
loading maze from excel file by making a function that takes excel file and put all the co... |
c961bd17367e5dbfcf1466cf247c094633af1397 | urbanskii/UdemyPythonCourse | /secao05/se05E18.py | 1,728 | 4.25 | 4 | """
18 - Faça um programa que mostre ao usuário um menu com 4 opções de operações ma-
temáticas (as básicas, por exemplo). O usuário escolhe uma das opções e o seu pro-
grama então pede dois valores numéricos e realiza a operação, mostrando o resultado e
saindo.
"""
def main():
while True:
print('Escol... |
4e55b5330a640e42a05fe0de8aae12240f8b5042 | shahil-chauhan/python_programs | /Q1.py | 144 | 3.953125 | 4 | #write a script that prints the multiples of 7
# between 0 and 100
for num in range(1, 101):
if num % 7 == 0:
print(num, end=' ')
|
1eabb67b8e180359a83c143090247fda771f474c | blueones/LeetcodePractices | /implementingqueueusingstacks232.py | 2,173 | 4.1875 | 4 | class MyQueue:
def __init__(self):
"""
Initialize your data structure here.
"""
self.stack = []
self.length = 0
def push(self, x: int) -> None:
"""
Push element x to the back of queue.
"""
self.stack.append(x)
self.length... |
069352d296be51c03c3011ca1561ee5c3dee2478 | rehanzfr-zz/Python_Codes | /AutoType/AutoTyper.py | 4,023 | 3.84375 | 4 | import time
import sys
import random
import string
import os
import keyboard
# 3 seconds to alt-tab to correct window after running
time.sleep(3)
replace_time = random.randint(5,10)
start_time = time.time()
def randomString(stringLength=10):
"""Generate a random string of fixed length """
letters = string.as... |
e648ce6c07f640225766c38df265cfcca9a356fe | yansikuan/driving | /driving.py | 397 | 4.28125 | 4 | country = input('which country: ')
age = input('enter your age: ')
age = int(age)
if country == 'China':
if age >= 18:
print('you can take a driving test.')
else:
print('you can not take a driving test.')
elif country == "America":
if age >= 16:
print('you can take a driving test.')
else:
print('you can no... |
7674c629c50887bfb5968ed315938f6eac09623b | Ken0706/Crash_Course_Book_Python | /5.11_Ordinal_Numbers.py | 263 | 3.78125 | 4 | def number_list():
numbers = list(range(1,10))
for i in numbers:
if i == 1:
print("1st")
continue
elif i == 2:
print("2nd")
elif i == 3:
print("3rd")
else:
print(f"{i}th")
def main():
number_list()
if __name__ == '__main__':
main()
|
4bc9fbf23c70ff8da18bb758955702f47f7e991f | quanewang/public | /nth_digit.py | 1,159 | 3.984375 | 4 | """
LESSON
-- base += base + ... => base += ...
Find the nth digit of the infinite integer sequence
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
Example 1:
Input:
3
Output:
3
Example 2:
Input:
11
Output:
0
Explanation:
The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0,
which is part of the numb... |
450596af2d645d4f27dd718b9d44d805b39ea2cf | ZainQasmi/Psychic-Poker | /psychic_poker.py | 4,910 | 3.5625 | 4 | import itertools
import sys
class Card(object):
FaceValue = 'A23456789TJQK'
Suit = 'CDHS'
def __init__(self, card):
self.card = card
def __str__(self):
return self.card
def getSuit(self):
return self.card[1]
def getFaceValue(self):
return self.card[0]
class ... |
999c531feb33d398a0461e7e433b0815e3a0a9b6 | gabgerson/coding-challenges | /data-algo/fibonacci.py | 727 | 4.1875 | 4 |
def fibonacci_iterative(n):
# store value
nex = 0
current = 1
# loop n number times
i = 1
ls = []
while i <= n + 1:
ls.append(nex)
ls.append(current)
nex = nex + current
current = current + nex
i += 2
ls.append(nex)
#kee... |
2b685e9d18cec9dc0113eee96bfc7f9582fbf004 | 83715405/- | /31,线程池与队列.py | 784 | 3.5 | 4 | import threading
import time
from multiprocessing.dummy import Pool
# 导入线程池用的不是from multiprocessing.pool import Pool(这个是进程池, 切记)
from queue import Queue
#from multiprocessing import JoinableQueue(这个是多进程例的队列,不能混)
pool = Pool()
queue = Queue()
def func():
for i in range(1, 99):
print("添加{}".format(i))
... |
5dff7ec566dcafd073f87b61f952c7a8ff52eec4 | hebergonza719/cs-module-project-hash-tables | /applications/word_count/word_count.py | 593 | 4.03125 | 4 | import re
def word_count(s):
# Your code here
pattern = '[\"\:\;\,\.\-\+\=\/\\\|[\]\{\}\(\)\*\^\&]'
s = re.sub(pattern, '', s)
lookup = {}
s = s.lower()
s = s.split()
for word in s:
if word not in lookup:
lookup[word] = 1
else:
lookup[word] += 1
... |
9ab69cee119e78a271524b2c6a34e7023ef13756 | prasanna86/fun_with_programming | /trees/binary_search_tree_checker.py | 3,333 | 4.125 | 4 | import unittest
# Determine if the tree is a valid binary search tree
def is_binary_search_tree2(root):
vals = []
in_order_traversal(root, vals)
for i in range(len(vals)-1):
if vals[i] > vals[i+1]:
return False
return True
def in_order_traversal(node, vals):
if node.left:
... |
ebf40c6dcdd1b55ef8c1b7814f90622f50e1cef6 | drtierney/hyperskill-problems | /Python/Topics/Modifying a DataFrame/Growing square/main.py | 204 | 3.875 | 4 | import pandas as pd
df = pd.DataFrame({'a': [1, 4], 'b': [2, 5]})
# your code here
df["c"] = [3, 6]
new_row = {"a": 7,
"b": 8,
"c": 9}
df = df.append(new_row, ignore_index=True)
|
ab2fdddc1bb9dfc42923afecfd4f2ef705605496 | zakneifian/Laboratorio_Algoritmos_1 | /Examen/ExEjercicio2.py | 1,001 | 3.9375 | 4 | # "ExEjercicio2.py" elaborado por Alejandro Martinez (13-10839@usb.ve)
#Ultima modificacion 11:00 almacene
#Valor inicial
lista = []
suma = 0
#Le explica al usuario la funcionalidad del programa
print("\nSe le va a ir pidiendo precios de un mismo producto a lo largo del tiempo para calcular su promedio.\n")
#loop qu... |
8adc7d6db450f2d806254ce8709bba1d1206f8c7 | bencecile/image-outline | /outline.py | 3,787 | 3.828125 | 4 | """
Generates an image that is the outline of an input image
"""
import math
from pathlib import Path
import time
from PIL import Image
IMAGE_IN = Path("crystalized.jpg")
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
def pixelLumin(pixel):
"""
Figures out the luminance of the pixel
"""
... |
f6e66d70b5552c941514dc06dd77dfbac9bf30ba | LDinho/Intro-Python-I | /src/13_file_io.py | 1,011 | 4.28125 | 4 | """
Python makes performing file I/O simple. Take a look
at how to read and write to files here:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
"""
# Open up the "foo.txt" file (which already exists) for reading
# Print all the contents of the file, then close the file
# YOUR CODE HERE... |
04ee8de3d1e077369582ff55315690ea64548251 | magikitty/GetPythonBookPractice | /25.Lists/QuickCheck25.2.py | 383 | 4.34375 | 4 | """
This is Lesson 25: Working with lists
Get Programming: Learn to Code With Python
"""
# Items in lists can be indexed in the same way as items in tuples
desk_items = ["stapler", "tape", "keyboard", "monitor", "mouse"]
print(desk_items[1])
print(desk_items[4])
# print(desk_items[5]) # creates error because index ... |
b16d5d8f3e939ddb4b1ecf0ec92ddf0425d88baa | Cinquiom/dice-game | /dicegame.py | 2,103 | 3.859375 | 4 | import random
import time
from collections import Counter
import argparse
class DieGame:
"""
Encapsulates a dice game.
@param die_num: number of dice in game
"""
def __init__(self, die_num=6):
self.active_dice = die_num
def play(self):
"""
Rolls dice unt... |
c97cff2692bc08da6d8e49e66fd4b9b8498dcdc7 | lmbaeza/Crypto | /math/python/math_gcd.py | 185 | 3.59375 | 4 | # from math import gcd
# Usage:
# ans = gcd(100, 54)
# Euclid's algorithm
def gcd(a, b):
tmp = 0
while b > 0:
tmp = a
a = b
b = tmp % b
return a
|
ebb18316ed1ba5d524394cbf263d9fb173fe7377 | jasonglassbrook/cs28.u1.s2--sorting | /src/iterative_sorting/iterative_sorting.py | 3,301 | 4.40625 | 4 | ############################################################
# ITERATIVE SORTING
#-----------------------------------------------------------
# GUIDED
# - [x] complete insertion_sort() below
#
# MVP
# - [x] complete selection_sort() below
# - [x] complete bubble_sort() below
#
# STRETCH
# - [ ] complete... |
a7b63f095eb633c05fdd4bbb1e46224a41fded3c | vitcmaestro/hunter | /stack_palin.py | 300 | 3.609375 | 4 | def push(l):
stack.append(l)
def pop():
temp = stack[-1]
del stack[-1]
return temp
s = input("")
mid = len(s)//2
stack = []
for i in range(len(s)):
push(s[i])
for i in range(len(s)):
temp = pop()
if(temp != s[i]):
print("NO")
break
else:
print("YES")
|
df472a61d03451cdd9f17eecb3d1b70a90d007e1 | abhr1994/Python-Challenges | /Python3_Programs/Even_Odd_Elements_at_even_and_odd_positions.py | 1,263 | 4.03125 | 4 | ##Given an array. The task is to arrange the array such that odd elements occupy the odd positions and even elements occupy the even positions. The order of elements must remain same. Consider zero-based indexing. After printing according to conditions, if remaining, print the remaining elements as it is.
##
##Input:... |
ca0327b6fe8e362c44545a77210788be31a28762 | chuzhong16/python- | /7.13 5.1.py | 251 | 3.875 | 4 | num=0
tot=0.0
while True:
sval=input('Enter a numer: ')
if sval=='done':
break
try:
fval=float(sval)
except:
print('Invalid input')
continue
fval=float(sval)
print(fval)
num=num+1
tot=tot+fval
print('All done' )
print(tot,num,tot/num) |
499cc32ea164518c43c45bd1bcd3ad0644e76b8f | Shawndace/python9am | /exercise-oop/Vehicle.py | 571 | 3.765625 | 4 | class Vehicle:
def __init__(self, type, wheels=True, engine=True):
self.type = type
self.wheels = wheels
self.engine = engine
def get_type(self):
return f'This vehicle is a {self.type}'
class Car(Vehicle):
def __init__(self, brand, color, type='car'):
self.brand = ... |
f59a23421713362400d1875bed6f58aeb536fd44 | kingapl/mini_projects | /fibonacci_sequence/fibonacci_sequence.py | 456 | 3.75 | 4 | try:
number = int(input("Ile liczb ciągu Fibonacciego wyświetlić? "))
fib_0 = 0
fib_1 = 1
if number == 1:
print(fib_0)
elif number >= 2:
print(fib_0)
print(fib_1)
for i in range(2, number):
fib_n = fib_1 + fib_0
print(fib_n)
fib_0... |
a35a4bb1bb2f7f92000f5685f289c3799ad39f0d | htl1126/leetcode | /81.py | 927 | 3.640625 | 4 | # ref: https://discuss.leetcode.com/topic/37710/clean-python-code
# The code is cleaner than Stefan's and idea is good too
class Solution:
def search(self, nums: List[int], target: int) -> bool:
left, right = 0, len(nums) - 1
# this loop avoids case [1, 0, 1, 1, 1], target = 0
while left <... |
a0fc0bd4d4c377fe765eb03c413b3c03eeae21ca | honkly/pcc | /chapter_10/动手试一试/10-4 访客名单/write_names.py | 182 | 3.890625 | 4 | filename = 'guest_book.txt'
while True:
name = input("Please input your name:\n")
print("Hello! " + name)
with open(filename,'a') as file_object:
file_object.write(name + '\n') |
1336458c9bef8d8296d3d40f253ac0ebe1edcdd0 | Gvence/pythonHW | /10-15/77or7.py | 77 | 3.546875 | 4 | for i in range (101):
if i % 10 == 7 or i/10 % 10 == 7 :
print(i) |
c066717e9fc33591129490314a8040690d6cff57 | Shreyassavanoor/grokking-coding-interview | /2_two_pointer/backspace.py | 505 | 3.6875 | 4 | def remove_backspace(str1, str2):
str1 = parse_strings(str1)
str2 = parse_strings(str2)
print(str1 == str2)
def parse_strings(string):
stack = []
for i in string:
if i != '#':
stack.append(i)
else:
stack.pop()
return ''.join(stack)
def main():
remove... |
a900867f7d5b495bc4dedf677bec6ff7ea415d84 | nandiniananthan/Python | /Data Structures/Array/394. Decode String.py | 862 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 23 16:43:10 2021
@author: nandini.ananthan
"""
s = "3[a]2[bc]"
Output = "aaabcbc"
class Solution:
def decodeString(self, s: str) -> str:
stack = []
curNum = 0 #3
curString = ''
for c in s:
if c == '[':
... |
4840ff6a43e22485f6cfa16422cd8a4a81e8643b | Vinaybabu6767/Day1 | /day3.py | 748 | 4.0625 | 4 | print("Wellcome to Teasure Island")
print("Your mission is to find the Teasure......")
path = input('Select the path which turn would you like to take "Left" or "Right" ' )
if path == "Left":
way = input('would you like to "swim" or "wait" ' )
if way == "wait":
door = input('which door color would you ... |
606255916d7d165de1bec882eddeb048ba442138 | chris510/Coding-Problems | /python/linked_lists/19_removenthNodefromlist.py | 785 | 3.921875 | 4 | # Given a linked list, remove the n-th node from the end of list and return its head.
# Example:
# Given linked list: 1->2->3->4->5, and n = 2.
# After removing the second node from the end, the linked list becomes 1->2->3->5.
# Note:
# Given n will always be valid.
# Follow up:
# Could you do this in one pass?
... |
f5c7f58302f064ec57f4b2dc5c484c36f156446b | UttkarshJha/PythonApplications | /dataloadusingjson.py | 1,189 | 3.765625 | 4 | import json
import difflib
from difflib import get_close_matches
data = json.load(open("yourjsonfile.json"))
#print(data)
def find_closest(word):
mylist=get_close_matches(word,data.keys(),0.85)
print(mylist)
if len(mylist) == 0:
return "no close word found"
else :
return mylist[0]
def ... |
b3044d7d9f0876f2fdf8c333bbff2227fc0c9389 | YorkFish/learning_notes | /Souvenir/Python2/15_note.py | 716 | 3.65625 | 4 | # -*-coding:utf-8-*-
# 1.
print ord('c') # 查看 'c' 的 ASCII 码
# 2.
list1 = []
print list1
for i in "happy":
list1.append(ord(i))
print list1
print list1
# 3.
list2 = [ord(x) for x in "happy"]
print list2
# 4.
id1 = [x for x in range(10)]
print id1
print len(id1)
# 5.
id2 = [x for x in range(50) if x%2 == 1... |
bc7330a3ef6487c23981439754fb3797b53d1491 | picccard/python-assignments | /IINI4014/07_classes/use_01_circle_class.py | 229 | 3.75 | 4 | from Circle import Circle
# Tutorial
print(f'Circuituous version {Circle.version}') # New f'string'-format python 3.6
c = Circle(10)
print(f'A circle of radius {c.radius}')
print(f'has an area of {c.area()}')
print()
|
37fcfb542b0ad566054d79d77c86350c261fd21a | tylerstjacques/SchoolPrograms | /Lab 15.1.py | 277 | 4 | 4 | def main():
for int in range(101):
odd_t = threes(int)
odd_f = fives(int)
print(int)
def threes(x):
if int % 3 == 0:
int = "fizz"
return int
def fives(y):
if int % 5 == 0:
int = "buzz"
return int
main()
|
499b967b3b6cf7bfe4bf4ed4a4a3ea045df06ab5 | Hiroshi97/CV-Analysis | /JsonProcessor.py | 1,320 | 3.78125 | 4 | import json
import os
#this function will extract all the data from the json file and put all the keys (dictionary) into an array.
#Return an array
def jsonfile_reader(jsonFile):
emptyList = []
script_dir = os.path.dirname(__file__)
fileName = 'static/keywords/' + jsonFile
file_path = os.path.join(scri... |
7cfcf788e84b081b12f69ce666286dae0847b3f8 | Heegene/learning_python_200627 | /contact_management_200724.py | 1,036 | 3.828125 | 4 | menu = 0
contacts = []
while menu != 9:
print("---------------------")
print("1. 친구 리스트 출력")
print("2. 친구 추가")
print("3. 친구 삭제 ")
print("4. 이름 변경")
print("9. 종료")
menu = int(input("메뉴를 선택하세요 : "))
if menu == 1:
print(contacts)
elif menu == 2:
name =... |
bba1e14e885d5384ece6ee0b42f21d8b071f19b3 | gabriellaec/desoft-analise-exercicios | /backup/user_004/ch89_2019_06_03_22_38_34_060250.py | 283 | 3.65625 | 4 | class Circulo:
def centro(self, ponto1):
self.centro = (ponto1.x, ponto1.y)
self.raio = 2.5
def contem(self, ponto):
if ponto.x>ponto1.x+2.5 and ponto.y>ponto1.y+2.5:
return 'Está fora'
else:
return 'Está dentro' |
9d9913c72bb9c11e687378a6a17dc6f549417b34 | AntonioRol/first | /p2.py | 399 | 4.03125 | 4 | def cubic(x):
result = x*x*x
return result
def cubic2(x):
return x*x*x
value1 = cubic(3)
value2 = cubic(3)
print "value1 - ", value1
print "value2 - ", value2
def adder(n1,n2):
return (n1+n2)
print "adder - ",adder(10, 1)
def avg_three(n1,n2,n3):
temp = n1+n2+n3
return temp/3.0
print "avg 18, ... |
dd532d1d3030605cce357bfc92cea8f0b1690e99 | BubbleXu/leetcode | /48_rotate_image/rotate_image.py | 1,713 | 4.125 | 4 | # You are given an n x n 2D matrix representing an image.
#
# Rotate the image by 90 degrees (clockwise).
#
# Note:
# You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.
# DO NOT allocate another 2D matrix and do the rotation.
#
# Example 1:
# Given input matrix =
# [
# ... |
21e3eba7f84540c0ce018a3c5379fce687fe65f7 | zhazhijibaba/zhazhijibaba_programming_lessons | /programming_lesson2/compute_pi_monte_carlo.py | 660 | 3.890625 | 4 | # Compute pi value by Monte Carlo sampling
# circle area within a square with unit length
# pi = Area / r^2
# Area = Area of the square * number of points within circle / total number of points
# Area of the square = 4 * r^2
# pi = 4.0 * number of points within circle / total number of points
import random
import math... |
148eb93617a395bcbcccaad133874fa72d8c1e9a | eric6356/LeetCode | /CloneGraph.py | 1,053 | 3.59375 | 4 | # Definition for a undirected graph node
class UndirectedGraphNode:
def __init__(self, x):
self.label = x
self.neighbors = []
class Solution:
def addToDict(self, node_dict, node):
if node.label in node_dict:
return False
nb_list = list()
for nb in node.neighb... |
376ecda95125c6d26e8983d9971aaabea717ef9e | sourav2406/nutonAkash | /DataStructure/BinaryTree/reverseLevelOrder.py | 1,037 | 4.4375 | 4 | # A recursive python process to print reverse level order
#Basic node for binary tree
class Node:
def __init__(self,data):
self.data = data
self.left = None
self.right = None
#compute the height of a binary tree
def _height(node):
if node is None:
return 0
else:
lhe... |
4de472c5a369daabf2ea9a1be209a8518da8d9db | joaothomaz23/Basic_Python_Journey | /cataloga_intervalos.py | 642 | 3.6875 | 4 | num = 1
intervalo0_25 = 0
intervalo26_50 = 0
intervalo51_75 = 0
intervalo76_100 = 0
while num >= 0:
num = float(input('Entre com um numero positivo: '))
if num >= 0 and num <= 25:
intervalo0_25 += 1
elif num >= 26 and num <= 50:
intervalo26_50 += 1
elif num >= 51 and num <= 75... |
c08464fa94d26da8477bacd189c0a60bb4f3541a | doctodd/analytics_bootcamp | /code/stats/plot_clt_unif.py | 1,574 | 3.5625 | 4 | """
Gets N samples from uniform distribution of random numbers, then plot the mean of those samples. Repeat TRIALS times
Should produce a normal curve
"""
from stats import *
import time
import matplotlib.pyplot as plt
setseed( int( round(time.time() * 1000)) ) # Set seed based on current time in milliseconds
N = 2... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.