blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
f7096392602abe5e76af20de9fe6dd2f94e68deb | pete5431/PKI-Implementation | /shared_info.py | 5,677 | 3.5625 | 4 | # The DES algorithm used is from the pycryptodome package.
from Crypto.Cipher import DES
import random
import string
import base64
"""
The pycryptodome package uses C language code. Therefore in order use strings with pycryptodome functions, bytes objects are used.
"""
class SharedInfo:
"""
Class that holds ... |
0de2b02083c8ce7beb247e33ddc95e7f5bc40cfd | UWSEDS/hw2-using-functions-PrivacyEngineer | /analysis/usingfunctions.py | 2,662 | 3.859375 | 4 | # Data 515, Software Engineering for Data Scientists
# Homework 2
# M.S. Data Science, University of Washington, Spr. 2019.
# Francisco Javier Salido Magos.
import requests
import io
import pandas as pd
def test_create_dataframe(newdf):
"""
Compares a preselected dataframe to a new dataframe for similarity.
... |
4fdc509cf7ccd024cbb5a462ec7b6fc5963c7fe6 | Novandev/interview_prep_python | /interview_questions/permutation_backtracking.py | 2,305 | 3.96875 | 4 | """
"""
def permutation_maker(a, n, k, depth, used, current_permutation = [], permutations = []):
'''
Implement permutation of k items out of n items
a: the list we will make permutations out of
n: the length of the list as a sentonel value
k: The sentinel value that tracks how deep the recursion... |
31a04058a3931c405cd83d47aa20d8ade4bc514e | viktoriasin/crypto_mai | /sem2/task2/gcd_lib.py | 1,033 | 3.8125 | 4 | import typing as tp
# рекурсивная реализация - плохо для больших чисел
def gcd_recursive(a: int, b: int) -> int:
a = abs(a)
b = abs(b)
if a == 0:
return b
if b == 0:
return a
if a >= b:
return gcd_recursive(a % b, b)
else:
return gcd_recursive(a, b % a)
# нере... |
6690f507189ad0cff4d8a6e239436fefcf7e8b62 | hector81/Aprendiendo_Python | /Excepciones/Ejercicio3_posicion_lista_ValueError.py | 869 | 4.21875 | 4 | '''
EJERCICIOS EXCEPCIONES
3. Función que recibe una lista y el elemento a buscar, devolviendo
su posición si existe, y -1 en caso de que no (ValueError)
[Pista: podemos usar la función list.index(value)]
'''
def encontrarPosicion_Elemento_enLista(lista,elemento):
while True:
try:
... |
21d93929d4b288ca88ab29ae8ea0a31f8c36910f | JudyXhen/2017A2CS | /Ch27/Task27.08.py | 1,302 | 3.6875 | 4 | class Assessment:
def __init__(self, t, m):
self.__AssessmentTitle = t
self.__MaxMarks = m
def OutputAssessmentDetails(self):
print(self.__AssessmentTitle, "Marks: ", self.__MaxMarks)
class Course:
def __init__(self, t, m): # sets up a new course
self.__CourseTitle = t
self.__MaxStudents = m
self.__Numb... |
c4f856003eb61a5a3b37d59d6a98e12ff0472eda | DBordeleau/YOFHLDraftLottery | /lottery.py | 877 | 3.859375 | 4 | import numpy as np
lotteryTeams = []
x = 14
#Prompt user to enter the 6 lottery teams
for _ in range(6):
team = input('Enter the owner of the ' + str(x) + 'th place seed: ')
x = x-1
lotteryTeams.append(team)
#Select a winner based on the probabilities specified
Winner = np.random.choice(lotteryTeams, 1, p=[0.35, ... |
f4021e8727f0afecf7a0bdc8479df954272d1dde | rafaelperazzo/programacao-web | /moodledata/vpl_data/131/usersdata/172/37508/submittedfiles/al10.py | 199 | 3.734375 | 4 | # -*- coding: utf-8 -*-
#NÃO APAGUE A LINHA ACIMA. COMECE ABAIXO DESTA LINHA
n=int(input('digite um valor'))
i=2
d=3
while 0<n
soma=4*((i/d)*((i+2)/d))
i=i+2
d=d+2
print('%.5d'%soma) |
739903e438fef6c28869523b51671b9c9be9a949 | Jfprado11/holbertonschool-higher_level_programming | /0x03-python-data_structures/5-no_c.py | 534 | 3.765625 | 4 | #!/usr/bin/python3
def no_c(my_string):
count_lower_C = my_string.count("c")
count_upper_C = my_string.count("C")
if count_lower_C > 0:
my_string = list(my_string)
while count_lower_C:
my_string.remove("c")
count_lower_C -= 1
my_string = "" .join(my_string)
... |
9520f8d870009121837bd0a2c02c2abb8a2b12cd | naturecreator/mini_projects | /Python/calendar_generation.py | 403 | 4.34375 | 4 | import calendar
year = int(input("enter the year: "))
month = 1
print("\n********Calendar*********")
print()
# An instance of TextCalendar class is created and calendar.SUNDAY means that we need to start displaying the calendar froom Sunday
cal = calendar.TextCalendar(calendar.SUNDAY)
while month<=12:
cal.prmonth... |
90200c88721e64ee1b8d9088a0072076c0884cc3 | kamilsieklucki/python_examples | /dict_union.py | 2,101 | 4.65625 | 5 | # example of using dict ----------------------------------------
# Declare a dict
student = {'name': 'John', 'age': 14}
# Get a value
age = student['age']
# age is 14
# Update a value
student['age'] = 15
# student becomes {'name': 'John', 'age': 15}
# Insert a key-value pair
student['score'] = 'A'
# student becomes {'n... |
febcd1aca6029792bb521a90c383063a648486e8 | jmrafferty/python-challenge | /PyBank/budget_data -- Final Submission.py | 4,548 | 3.875 | 4 | # First we'll import the os module
import os
# Module for reading CSV files
import csv
#Store csvpath as variable.
csvpath = os.path.join("Resources", "budget_data.csv")
# Read w/ CSV Module
with open (csvpath, newline="") as csvfile:
# CSV reader specifies delimiter and variable that holds contents
csv... |
d74c6a525216caa933f7792fd64952653f538bab | henrikmidtiby/TeacherTools | /extract photo name pairs from blackboard/parser.py | 2,724 | 3.734375 | 4 | # Script for extracting student names and associated images
# from an e-learn / blackboard page with the students.
# The data should afterwards be imported into mnemosyne, to aid me
# in learning names of all the students.
#
# Author: Henrik Skov Midtiby
# Date: 2018-10-17
# User guide
# 1. Open the relevant course... |
85942135a0f37c93db63fe063ccdb58770bc1ed1 | Prince-linux/python_for_everyone | /ch03/P3.16/lex.py | 516 | 4.0625 | 4 | #Question: P3.16: Write a program that reads in three strings and sorts them lexicographically.
#Enter a string: Charlie
#Enter a string: Able
#Enter a string: Baker
#Able
#Baker
#Charlie
#Author: Prince Oppong Boamah<regioths@gmail.com>
#Date: 28th February, 2019
string1 = input("Please enter three strings: ")
s... |
3d8e3458a29482640ab1b022320f704a1824f60a | Zepk/DailyCodingProblems | /Problem 4/#4.py | 1,162 | 3.859375 | 4 | '''
This problem was asked by Stripe.
Given an array of integers, find the first missing positive integer in linear time and constant space.
In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.
For example, the input [3, 4, -... |
d6a168f495df8ac49e1978894d405479085e16c9 | MrHamdulay/csc3-capstone | /examples/data/Assignment_3/bttchr004/question3.py | 505 | 3.734375 | 4 | message = input("Enter the message:\n")
y = eval(input("Enter the message repeat count:\n"))
thickness = eval(input("Enter the frame thickness:\n"))
a=len(message)+2*thickness
b=len(message)+2
gap = 0
for i in range(a,b-2,-2):
print('|'*gap,'+','-'*i,'+','|'*gap,sep="")
gap=gap+1
for h in range(y):
... |
df3dc1420791d5283202851effc43090d365b9fc | AB-Yusuf/Blockchain_Project- | /blockChain.py | 4,288 | 3.875 | 4 | # A global blockchain variable as a list structure
genesis_block = {
'previous_hash': '',
'index': 0,
'transactions': []
}
blockChain = [genesis_block]
open_transactions = []
owner = 'Abu'
# To add a value to the block chain List
def record_transactions(recipient, sender=owner, amount=1... |
6cfaf71dc861e1de5294e07c5af3df0adbc72a51 | Sarthak2601/Python_Basics | /guessing_game.py | 296 | 3.84375 | 4 | secret_number = 9
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
input_number = int(input("Guess?"))
guess_count +=1
if input_number == secret_number :
print("Congratulations, you won!")
break # Exits the loop
else:
print("Sorry, you failed")
|
d72bd0b14fe3cbbc2ce97720db8737ccd58996d1 | PemLer/Journey_of_Algorithm | /leetcode/801-/T845_longestMountain.py | 704 | 3.90625 | 4 | from typing import List
class Solution:
def longestMountain(self, A: List[int]) -> int:
i, n = 0, len(A)
if n < 3:
return 0
res = 0
while i < n:
end = i
if end + 1 < n and A[end] < A[end+1]:
while end + 1 < n and A[end] < A[end+1]... |
9f909f6b590f6834bb2f20de03744d6a23129e26 | wherculano/Curso-em-Video-Python | /Desafio028.py | 377 | 3.90625 | 4 | #Desafio28
import random
from time import sleep
n = random.randint(0,5)
op = int(input('\nDigite um numero entre 0 e 5: '))
print('\nLoading...')
sleep(3) #espera 3 segundos para mostrar a linha abaixo
print('\nPC = {} Você = {}'.format(n, op))
if n == op:
print('\nParabens! Você acertou o número')... |
4888cd2e8826537b4efca18753324f328a8a8839 | nicklogin/MasterMLCoursePracticals | /practical1.py | 7,548 | 3.890625 | 4 | #!/usr/bin/env python
# coding: utf-8
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from io import StringIO
from functools import partial
# 1. Use the Tree data structure below; write code to build the tree from figure 1.2 in Daumé.
class Tree:
'''Create a binary tree; keyw... |
3f49fe7f00091bdeaccc6c78e915338dbbc1806a | wangruichens/algorithms | /蓄水池采样.py | 834 | 3.5625 | 4 | # leetcode 382
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
import numpy as np
class Solution(object):
def __init__(self, head):
"""
@param head The linked list's head.
Note that the head is g... |
8175d375d6dca905786624bf0fb13d7f72ba1e93 | Candy0701/python | /class/20210328/for.py | 131 | 3.75 | 4 | a=int(input('輸入數字:'))
total=0
if a>1:
for i in range(1,a+1):
total+=i
print(total)
else:
print('error') |
54d794668f28e5f36f494da3f12477105a3ff2d3 | razstvien01/2D-Console-Resizable-Tictactoe-Game-in-Python | /playTictactoe.py | 12,539 | 3.6875 | 4 | import math
from random import randrange
from time import sleep
from tictactoe import Tictactoe
from tictactoe import CompAI
from record import Record
class PlayTictactoe:
def drawRoof(self, limit):
for i in range(limit):
print(end="-")
print()
def drawSpaces... |
a264e42d0757d08a445544038d79e8d28fe1f0bb | QMJT/myedu | /dy03/while_demo.py | 186 | 3.734375 | 4 | def while_qq():
a=0
while a<5:
print(a)
a+=1
def while_tt():
a=0
while a<8:
print(a)
a+=1
if __name__ == '__main__':
while_tt() |
66f1ad47c9fb7a6619a30bbd9615a3aa21b15ff2 | mchoimis/Python-Practice | /20130813_0051_wrting-reading-files.py | 360 | 3.8125 | 4 | # Writing
outfile = open('tmp.txt', 'w')
outfile.write('This is line #1\n')
outfile.write('This is line #2\n')
outfile.close()
# Reading an entire file
infile = file('tmp.txt', 'r')
content = infile.read()
print content
infile.close()
# Reading a file one line at a time
infile = file('tmp.txt', 'r')
for line in inf... |
cf72f43dae71db477ebe44ee1bfb9f2be8cfb0d8 | Sofista23/Aula1_Python | /Aulas/Aulas-Mundo3/Aula021/Aula021c.py | 195 | 3.875 | 4 | def par(num):
if num%2==0:
return True
else:
return False
n=int(input("Digite um número:"))
if par(n)==True:
print(f"{n} é Par!")
else:
print(f"{n} é Ímpar!") |
e7a5be11574def59dfb49210f433ea65102cfa90 | Tiltedprogrammer/HwProj1 | /3.py | 71 | 3.609375 | 4 | a = int(input())
b = int(input())
a += b
b = a -b
a = a - b
print(a,b)
|
ad4543e56fb7419afb6bc8ba500610e109fdfeae | maximvegorov/hackerrank-python | /src/02-basic-data-types/nested-list.py | 318 | 3.546875 | 4 | if __name__ == '__main__':
n = int(input())
l = list()
for i in range(n):
name = input()
score = float(input())
l.append([name, score])
second_lower = sorted({p[1] for p in l}, reverse=True)[-2]
print(*sorted((p[0] for p in l if abs(p[1] - second_lower) < 1e-6)), sep='\n')
|
ce391661556760c189e74ebd4e64d751ee44dd0d | Samanvay96/python-ds | /data_structures/array/duplicate.py | 485 | 3.75 | 4 | # Find duplicate in an array of integers given that the integers are in random order and
# not necessarily each integer i is 0 <= i <= N where N = length of array
def duplicate(arr):
tortoise = arr[0]
hare = arr[0]
while True:
tortoise = arr[tortoise]
hare = arr[arr[hare]]
if tort... |
e0dbe0b887b2406645c25eedaa2449cbf8f44c4f | DinakarBijili/Python-Preparation | /Problem Solving/Loops/sum_os_squares.py | 166 | 4.09375 | 4 |
"""Sum of Squares"""
def sum_of_squares(n):
sum = n*(n+1)*(2*n+1)
return sum
num = int(input("Enter a number : "))
result = sum_of_squares(num)
print(result) |
e5ef579e45c79fa861798813b133acd670cb0a0d | MarciaCarolinaCarastel/Python | /ex039.py | 594 | 3.859375 | 4 | from datetime import date
print('\033[35mDescubra quanto tempo falta para se alistar no exército.')
nome = str(input('Me informe o sue nome:')).strip() .split()
ano = int(input('Qual o seu ano de nascimento?'))
c = date.today().year - ano
if c < 18:
print('\033[33m',nome[0], ', você vai se alistar ao serviço milita... |
90f9af0e73db5712e947e1bcd43be8bd0e773ee6 | Jordy281/Tic_Tac_Toe_SuperComputer | /gym.py | 11,706 | 3.59375 | 4 | """
Here we will train the Rewards function
"""
import numpy as np
import copy
from random import randrange
import game.py
def trainingAgainstRand1(states, t):
nStates = np.shape(t)[0]
nActions = np.shape(t)[1]
Q = np.zeros((nStates,nActions))
numberOfTimesStateVisted = np.zeros((nStates))
... |
544521eae045094f50a98d82ae7078988bc13b3f | sendurr/spring-grading | /submission - lab6/set2/JEFFERSON LEWIS LANGSTON_9455_assignsubmission_file_Lab 6 JL/Lab 6/f2c_qa2.py | 126 | 3.546875 | 4 | import sys
Farhenheit = float(sys.argy[1])
Celcius = ((F-32)*(5.0/9))
print 'The temperature in Celcius is:'
print Celcius
|
e80097b9a98cbfe4f9cebb1d791be1d35857ebe2 | bengeos/HomeIOT_Rasp | /Threading/TestThread.py | 543 | 3.65625 | 4 | import threading
import time
class MyThread(threading.Thread):
def __init__(self,sleep,name):
threading.Thread.__init__(self)
self.Sleep = sleep
self.Name = name
self.Count = 0
def run(self):
while(True):
print self.Name+">> Time is: "+str(time.time())
... |
19be3f4b680315d4823b027b8b0c88d41c1585c2 | root676/G08_python_for_geosciences | /homework1/player.py | 5,056 | 4.125 | 4 | #-------------------------------------------------------------------------------
# Name: Player
# Purpose: saves the data like money, name of the player an his bets for
# playing Roulette
#
# Author: Stefan Fnord, Clemens Raffler, Daniel Zamojski
#
# Created: 25.03.2015
# Copyri... |
98d057d7fd021546d33dfeb6352865f14bb2f57e | janarqb/Notes_Week2 | /List_day3.py | 1,526 | 3.515625 | 4 | nums = 1, 2, 3
# print(type(words))
# print(words[:2])
# one, two, three = num(s
# print(two)
# a = ()
# b = ()
# print(a is b)
# print(id(a))
# print(id(b))
# a = (1, 2, 3)
# print(id(a))
# del a
# b = (1, 2, 3)
# print(id(b))
countries = (
('Germany', 80.2, (('Berlin', 3.326), ('Huburg', 1.718))),
('Fr... |
dd0d90aa01ced332c66ac1891e1b16c88b4c1ed0 | Platform53/Yes | /yes.py | 14,532 | 3.53125 | 4 | import hashlib
from pathlib import Path
import time
import sys
firsttimecheck = ()
#first time setup
try:
#If it does it prints it in text
d = open('firsttimecheck','r').read()
firsttimecheck = ('')
except IOError:
... |
24858d172d0415abe33840073e0d8ac5fc200a55 | byterotate/lintcode-answer | /binary-tree/109-triangle.conquer-memorize.py | 780 | 3.53125 | 4 | class Solution:
"""
@param triangle: a list of lists of integers
@return: An integer, minimum path sum
"""
def minimumTotal(self, triangle):
self.cache = [[None for y in range(len(triangle[-1]))] for x in range(len(triangle))]
return self._minimumTotal(triangle, 0, 0)
def _minimumTot... |
93358c79f6be3b7ab77ae89e9e58039fb450a325 | FloHab/Project-Euler | /Problem 2.py | 635 | 3.96875 | 4 | #Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
#1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
fibona... |
0fa73411cdbcccb779e5f5c1f479767985d20454 | sourabh1983/music-festival | /festival/music_festival.py | 1,928 | 3.546875 | 4 | import operator
# Record label object consists of record label name and list of bands
class RecordLabel:
def __init__(self, name):
self.name = name
self.bands = []
def add_band(self, band):
if not self.band_exists_in_record_label(band):
self.bands.append(band)
... |
fa5cf1ed5ecd0ab88b9c163dea1c725340e7eae9 | mmarcolina/spreadsheet-comparison | /comparison.py | 1,087 | 3.71875 | 4 | import pandas as pd
import numpy as np
import openpyxl
# creates dataframes for each of the documents
# dataframes are a table or a two-dimensional array-like structure in which each column contains values of one variable and each row contains one set of values
# change the workbook name values inside of df1 and df2 t... |
7b7688a4d39a8b69e56615b44f21e7f3617e57d8 | Addlaw/Python-Cert | /world_series.py | 1,521 | 3.859375 | 4 | ################################################################################
# Author: Addison Lawrence
# Date: 4/11/2020
# Allows a year to be input and returns the world series winner that
# year and how many times they have won
################################################################################... |
29a026566a72864c29f3787d490187930b1c9935 | Taneil-Kew/Hw | /Chapter 12/Chapter12.py | 1,369 | 3.75 | 4 | import calendar
cal = calendar.TextCalendar() # Create an instance
cal.pryear(2018) # What happens here?
#C
cal = calendar.TextCalendar(6)
cal.prmonth(2018, 4)
#D
d= calendar.LocaleTextcalendar(6, "Greek")
d.pryar(2012)
#E
print(calendar.isleap(8))
#it expects a year
#it returns true or false
... |
dd83e0e8834bb8e3003f15506f3581a22e24f1c3 | RohanNankani/Computer-Fundamentals-CS50 | /Python/drivers_license.py | 704 | 4.3125 | 4 | # Author: Rohan Nankani
# Date: October 27, 2020
# Name of Program: DriverLicense
# Purpose: To determine if the user is able to get a driver's license
# Greets user and gives brief detail on what the program does
print("Hello and welcome to the Driver License program!")
print("")
print("I will help you determine if y... |
f208db81e1ddac9a885ff7eae0e2efa952ce9290 | nerutia/Leetcode | /Algorithm/521.py | 747 | 3.859375 | 4 | # 最长特殊序列 Ⅰ
# 给你两个字符串,请你从这两个字符串中找出最长的特殊序列。
# 「最长特殊序列」定义如下:该序列为某字符串独有的最长子序列(即不能是其他字符串的子序列)。
# 子序列 可以通过删去字符串中的某些字符实现,但不能改变剩余字符的相对顺序。空序列为所有字符串的子序列,任何字符串为其自身的子序列。
# 输入为两个字符串,输出最长特殊序列的长度。如果不存在,则返回 -1。
class Solution:
def findLUSlength(self, a: str, b: str) -> int:
if a == b:
return -1
ret... |
f65bd55b7d643b220b43442b58ae639ccd4e2c85 | leelakrishna16/PythonPracticePrgs | /reverse_string.py | 250 | 4.0625 | 4 | #! /usr/bin/python3
def main():
string = 'krishnakarri111'
print(string[::-1])
main()
def revers(num):
rev = num[::-1]
return rev
print(revers('krishnakarri99'))
def reverse_string(str):
print(str[::-1])
reverse_string('krishnakaka')
|
be4436f29c1a3ec4e39ca6aa80def2c884179653 | Roberta-bsouza/pyscripts | /exe037.py | 217 | 3.984375 | 4 | #analise de string
n = str(input('Informe seu nome completo: '))
nome = n.split()#fatia o nome informado
print('Seu primeiro nome é {}'.format(nome[0]))
print('Seu último nome é {}'.format(nome[len(nome)-1]))
|
fd465eec8a063a0bf9395420a4d3457099705bfc | imd93shk/Learning-Python | /E09_Guess_Random_Number.py | 1,083 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
www.practicepython.org
Exercise 09: Guess Random Number
Created on Wed Sep 12 19:01:18 2018
@author: Imaad Shaik
"""
print("This program allow user to guess the random number generated by the program")
import random
play = "Y"
i = 0
old_guess = []
def random_num_gen():
random_num = r... |
2dd17242084342c456cd678043116c14c5df823f | egetoz/solverman | /Mathematics.py | 13,487 | 3.609375 | 4 | #imports
from math import ceil
import random
import json
import urllib
import __future__
import os
import datetime
# functions list
mathfunctions = {
"Mathematics":{
"hy": "calculate hypotenuse given the two other sides of the triangle",
"qe": "solve quadratic equations (equations of the form ax^2 ... |
3c092475049c2ee0197a9392535f224c8aba42a6 | Hashah1/Leetcode-Practice | /medium/59. Spiral Matrix II.py | 1,371 | 3.65625 | 4 | class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
# Create bounds for the new spiral matrix
tr = 0 # Top Row
br = n - 1 # Bot Row
lc = 0 # Left Col
rc = n - 1 # Right Col
# Create a var to keep track of the number to add
num_to_add = 1
... |
af21c66b05880871686a5b370bf1977cf142e334 | techbkr3/DataProgramming | /DataProgramming/Reading/a04.py | 401 | 3.703125 | 4 | #!/usr/bin/env python
file = open("students.csv")
for line in file:
l = line.strip()
print("DEBUG: ", l)
student = l.split(",")
print(student)
print("FULLNAME is ", student[0])
print("GENDER is ", student[1])
print("COURSE is ", student[2])
print("DEPARTMENT_CODE is ", student[3])
pr... |
b2bc6643e9c1eb6f8ca58fc95d768309279af8a2 | thientt03/C4E26 | /C4E26/lab2_homework/draw_star.py | 319 | 3.828125 | 4 | import turtle
window = turtle.Screen()
window.title("Square")
zo = turtle.Turtle()
def draw_star(x,y,length):
zo.penup()
zo.goto(x,y)
zo.pendown()
for i in range(5):
zo.left(144)
zo.forward(length)
draw_star(10,10,100)
window.mainloop()
|
8b9729a17497336e1ccb37a8de0aaec7cc929298 | jacksonpradolima/ufpr-ci182-trabalhos | /201901/Agronomia/CI182A/Agropops/win.py | 3,045 | 3.625 | 4 | from tkinter import *
from datetime import datetime
import tkinter.ttk as ttk
import sqlite3
class janela():
#Janela
win = Tk()
win.title("AgropopsOS 2.0.0")
win.configure(background = "khaki1")
#Aqui ficam as variaveis, por isso o "Var"
nome = StringVar()
quant = StringVar()
preco = StringVar()
#Texto
... |
0ccf8885f08f816762f03743b0ad4d93a954cfd1 | MansourKef/holbertonschool-python | /0x07-python-test_driven_development/100-matrix_mul.py | 1,462 | 4.15625 | 4 | #!/usr/bin/python3
"""
Module to multiply 2 matrices
"""
def matrix_mul(m_a, m_b):
"""
Function to multiply 2 matrices and return the result
"""
if not isinstance(m_a, list):
raise TypeError("m_a must be a list")
if not isinstance(m_b, list):
raise TypeError("m_b must be a list")
... |
8e0f477e9cc3fdc7c04106e49b0546e46ff93de5 | jashburn8020/design-patterns | /python/src/bridge/bridge_test.py | 5,358 | 3.84375 | 4 | """Bridge pattern example.
Circles, squares, and rectangles each can be rendered in vector or raster form.
One way to draw them is by having VectorCircle, VectorSquare, VectorRectangle,
RasterCircle, RasterSquare, and RasterRectangle.
Instead, split the concepts into shapes and renderers.
Based on example in "Desig... |
7a69a428c75b05f0d697e7336c65d7bb73d18f44 | asperaa/back_to_grind | /Binary_Search/378. Kth Smallest Element in a Sorted Matrix [BS].py | 1,339 | 3.984375 | 4 | """We are the captains of our ships, and we stay 'till the end. We see our stories through.
"""
"""378. Kth Smallest Element in a Sorted Matrix [Binary Search]
"""
import pdb
class Solution:
def less_than_equal_count(self, matrix, k, mid, length):
row, column = length-1, 0
count = 0
small... |
1e1db010af8c4cd1fde4efadb13c20ad8bbd0726 | No-Masc-Curt-17/1.2.1-Game- | /1.2.1.py | 1,898 | 3.59375 | 4 | import random as rand
import turtle as trtl
painter = trtl.Turtle()
painter.speed(0)
score_writer = trtl.Turtle()
font_setup = ("Times New Roman", 20, "normal")
timer = 5
counter_interval = 1000 #1000 represents 1 second
timer_up = False
#-----countdown writer-----
counter = trtl.Turtle()
#... |
282b4310b01b06cadacb649bd39382671ad03d82 | yugandharjavvadi/dialycoding | /day21.py | 507 | 3.6875 | 4 | '''Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required.
For example, given [(30, 75), (0, 50), (60, 150)], you should return 2.
'''
#solution
def classroomreq(l):
finishtimes=[]
for i in l:
finishtimes.append(i[1])
... |
4cd8044e74404d46cfa3049049c423bb8b3da599 | ariannasg/python3-training | /advanced/class_computed_attrs.py | 3,680 | 4.53125 | 5 | #!usr/bin/env python3
# classes can use methods to control how attributes are accessed on an object.
# Whenever an object's attributes are retrieved or set, Python calls one of
# these functions to give your class an opportunity to perform any desired
# processing.
# getattribute and getattr, are called to retrieve a... |
48517106cb9536ccdc90f9ec0f4df6e580f5a665 | DoctorSad/_Course | /Lesson_04/_3_for_while_str.py | 403 | 4.25 | 4 | """
Строки можно обойти циклом.
1. Перебрать все элементы строки циклом for.
2. Пройти по индексам элементов строки циклом for либо while.
"""
s = "Hello world!"
for i in s:
print(i)
for i in range(len(s)):
print(s[i])
i = 0
while i < len(s):
print(s[i], end=", ")
i += 1
|
a19b1760817c9cc4a2081cc1c70a60d7d4361426 | joanvaquer/SDV | /sdv/models/copulas.py | 5,636 | 3.5 | 4 | """Wrappers around copulas models."""
import numpy as np
from copulas import EPSILON
from copulas.multivariate import GaussianMultivariate
from copulas.univariate import GaussianUnivariate
from sdv.models.base import SDVModel
from sdv.tabular.utils import (
check_matrix_symmetric_positive_definite, flatten_dict, ... |
1ec088eaa67602456300fe0d4cde4ef27369a688 | imtanmays/Coding-Problems | /Strings/excel_col_num.py | 330 | 3.578125 | 4 | '''
Topic : Strings
Problem : Excel Sheet Column Number
Link : https://leetcode.com/problems/excel-sheet-column-number/
'''
def titleToNumber(s):
col_num = 0
len_s = len(s)
for i in range(1,len_s+1):
char = s[len_s - i].lower()
col_num += (ord(char)-96) * (26 ** (i-1))
retu... |
f409af133ecaff01b9e063572339ff3651f18cca | Rifat951/PythonExercises | /ExercisesForInterview/Exercise5.py | 419 | 3.90625 | 4 | # Write a function to return True if the first and last number of a given list is same. If numbers are different then return False.
# Given list: [10, 20, 30, 40, 10]
# result is True
# numbers_y = [75, 65, 35, 75, 30]
# result is False
def TF(listofNum):
if(listofNum[0] == listofNum[-1]):
... |
95c1f942558ffdf0fa08de18a896a59a792e4bf4 | gaojianshuai/vpc-ui | /pycharm_practice/pycharm_practice_air_quality/pycharm_practice_quality_pachong5.py | 1,149 | 3.5625 | 4 | #coding=utf-8
"""
版本:6.0
作者:高建帅
功能:空气质量计算
日期:10/04/2019
新增功能:网络爬虫获取实时信息
新增功能:将数据保存到csv文件中
版本:6.0
"""
import requests
import csv
import pandas as pd
def main():
"""
主函数
"""
aqi_data = pd.read_csv('china_city_aqi.csv')
print('基本信息:')
print(aqi_data.info())
print('数... |
ef62fa1d76d5fabeec4a7f334266af03390b6b3a | hsnckkgl/Python | /variablesAndConditions.py | 3,109 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
radius = float(input('give me a radius: '))
pi = 3.14
area = pi * radius**2
print('the area of the circle is: ', area)
fah = float(input('please give me a fahreneit tempereture '))
cel = (fah-32) * 5/9
print('this' ,fah, 'is... |
c73edf62f0bb0f6e392c23442903b85e543cbbd3 | GeorgiTodorovDev/Python-Fundamental | /06.Exercise: Basic Syntax, Conditional Statements and Loops/04.double_char.py | 108 | 3.59375 | 4 | str_input = input()
double_char = ""
for index in str_input:
double_char += index * 2
print(double_char) |
d349ceef77e1fc813107badab3ffc0577d897c4f | larcat/create-games-python | /Chapter 3/Quiz -- Larcat.py | 1,924 | 4.34375 | 4 | print("This is a quiz you have to take.")
# Setting up initial variables
current_answer = ""
number_correct = 0
name = " "
# Question 1
print("Question 1:")
name = input("What is your name? ")
print()
print("Hi {!r}, good job getting the first question right!".format(name))
number_correct += 1
print()
# Question 2
p... |
42e3aa451a3680252bebab00a91829b01be2f748 | isharajan/python_stuff | /find the great num.py | 129 | 3.984375 | 4 | a=int(input("enter num a:"))
b=int(input("enter num b:"))
if(a>b):
print("a is great")
else:
print("b is great")
|
0a066c124a8736649f301238720651b97bd5875b | yhw1234/network_dynamics | /network.py | 9,230 | 3.5625 | 4 | """
Luc Blassel
network object
"""
import networkx as nx
import matplotlib.pyplot as plt
import random as rd
from queue import Queue
from node import Node
from info import Info
class Reseau():
"""
Network of nodes
"""
def __init__(self,size,disposition,verbose):
if size <2:
print(... |
66f57bb7155b7d8a73dae4829260232eaab74000 | solareenlo/python_practice | /04_モジュールとパッケージ/defaultdict.py | 696 | 3.59375 | 4 | # Pythonにも標準ライブラリがたくさんある.
# その中のdefaultdictを試してみます.
# 文字列の中の文字の出現回数を数えてみます.
s = 'ksjdflkhasklfalkshfkahsdkjhfakjdhk'
# 方法その1
d = {}
for c in s:
if c not in d:
d[c] = 0
d[c] += 1
print(d)
# 方法その2 (少し短く書ける)
d = {}
for c in s:
d.setdefault(c, 0)
d[c] += 1
print(d)
# 方法その3 (さらに短く書ける)
from collec... |
ed35ab48645c3c2e28cc841c05764db1866a0b0f | Davidbustamante/LenguajeNatural | /suma_enteros.py | 320 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 19 18:18:16 2019
@author: davidbellobustamante
"""
def sumatoria(X, num):
if(num > 0):
X = sumatoria(X, num-1)
X = X + num
return X
else:
X = 0
return X
X = 0
num = int(input("Ingresa un número entero\n"))
X = sumatoria(X, num)
print(X) |
9820f9d5715cb824445d784a0e6b4962cf365ab4 | Sigit-Wasis/Fundamental-Python | /dicoding/static_class_method.py | 720 | 3.796875 | 4 | # =========================================================
# Example @classmethod dan @staticmethod of Geeks for Geeks
# =========================================================
from datetime import date
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
# metode kelas untuk membua... |
5acca47788630bd5941b52fc325df6caa07dfd2c | akb9115/python_training | /using_modules.py | 181 | 3.765625 | 4 | import math
x = 16
my_number_sqrt = math.sqrt(x)
print("Square root of",x,"is",my_number_sqrt)
y = 6
my_number_fact = math.factorial(y)
print("Factorial of",y,"is",my_number_fact) |
a5d79288cb4b5c924994ca35eaf79dc320e72005 | jaymin1570/PythonTutorial | /chapter9/lc_with_if_else.py | 290 | 3.953125 | 4 | # list comprehension with if else
nums = [1,2,3,4,5,6,7,8,9,10]
# new_list = []
# for num in nums:
# if num%2==0:
# new_list.append(num*2)
# else:
# new_list.append(-num)
# print(new_list)
new_list = [num*2 if num%2==0 else -num for num in nums ]
print(new_list) |
0338c9c59ea6bdce50b7a6a7154878ad1ee21ce4 | nanihari/regular-expressions | /check for string and location.py | 369 | 4.3125 | 4 | #to search a literals string in a string and also find the location within the original string where the pattern occurs.
import re
pattern="fortune"
text="An aim in the life is the only fortune worth finding"
match=re.search(pattern,text)
s=match.start()
e=match.end()
print('found "%s" in "%s" from %d to %d ' % ... |
f0c4cef232721b8c43ace2b90a4917463b990c65 | git874997967/LeetCode_Python | /easy/leetCode231.py | 335 | 3.890625 | 4 | # 231. Power of Two
def isPowerOfTwo(n):
testNum = 1
while testNum < 2 ** 31 - 1:
if testNum - abs(n) != 0:
testNum = testNum << 1
else:
return True
return False
print(isPowerOfTwo(-64))
## approach 2
def isPowerOfTwo2(n):
return False if n == 0 else n... |
ca7c5bbfb75a761671dd3929e60b78221d776037 | IvayloValkov/Python_Fundamentals | /Final Exam 13 Dec 2020/task1_demo.py | 973 | 4.0625 | 4 | string = input()
data = input()
while not data == "Done":
command = data.split()[0]
if command == "Change":
char = data.split()[1]
replacement = data.split()[2]
string = string.replace(char, replacement)
print(string)
elif command == "Includes":
new_string... |
e6610dacf1a02becba160f0fc6341020e8dee776 | nurgleth/data_analysis | /less 4/process 3.py | 772 | 3.65625 | 4 | import time
from multiprocessing import Pool
workers_number = 4 # количество процессов
final_fib_number = 40
def fib(n: int) -> int:
return fib(n - 1) + fib(n - 2) if n > 2 else 1
def main():
tasks = list(range(0, final_fib_number))
strt_time = time.perf_counter()
# уход в паралельные вычисления
... |
7e99c35bcc51054c01c37745479bb7ae9fe8936c | davidtweinberger/coding_interview | /algorithms pseudocode/dijkstra.py | 1,595 | 3.859375 | 4 | #! /usr/bin/python
####################################################
# Pseudocode for Dijkstra's Algorithm (Graph Search)
# Takes in:
# - the graph
# - the start node
# - the destination node
# Returns the shortest path
def cs141_dijkstra(graph, start, destination):
PQ = PriorityQueue()
PQ.push(0, [start])
V... |
e73a627953f579fe33276ab81f08ed0693ee991f | CodeW1zard/DS | /Graph/Graph.py | 2,742 | 3.875 | 4 | class Graph():
'''
Undirected Graph
'''
def __init__(self, G=None):
if G:
self.nodes = G.nodes
self.adj = G.adj
else:
self.nodes = set()
self.adj = {}
def add_node(self, node):
if node not in self.nodes:
self.nodes.... |
3851628b1598805c4fc769228995bdfdb715957e | engelspencer/semesterReview | /2problem.py | 369 | 4.03125 | 4 | story = input('Please enter a short story: ')
if('Spencer' in story and 'abhorrent' in story):
print('Please try again, that story could have been written cleaner.')
elif('Spencer' in story):
print("Great job, you've written an awesome story!")
elif('abhorrent' in story):
print('What an interesting story, but a litt... |
9c25f1f9b79c1cc753ed35aab5b6c66c77173ab3 | eflipe/python-exercises | /udemy-py/manejo_excepciones/03-Ejercicio-ManejoExcepciones-parte3.py | 589 | 3.734375 | 4 | resultado = None
try:
a = int(input("Primer número: "))
b = int(input("Segundo número: "))
resultado = a / b
except ZeroDivisionError as e:
print("Ocurrió un error con ZeroDivisionError", e)
print(type(e))
except TypeError as e:
print("Ocurrió un error con TypeError", e)
print(type(e))
#exce... |
8624b8e03b8d2844fa7f374206f045476df2d8c4 | victorhlcavalcante/python | /calculadora.py | 1,124 | 4.34375 | 4 | #calculadora em python
print("\n**************** Python Calculator by Victor *******************")
def add(x, y):
return x + y
def subtract(x,y):
return x - y
def divide(x,y):
return x / y
def multiplication(x,y):
return x * y
print('\nSelecione a operação matemática que deseja fazer: \n')
print('1 - Soma')
... |
600fb13c262df70d97c84c81199ab484e4c7ee37 | godspysonyou/everything | /pythonall/oo1.py | 572 | 3.515625 | 4 | def person(name, age, sex, job):
def walk(person):
print("person %s is walking..." % person['name'])
data = {
'name':name,
'age':age,
'sex':sex,
'job':job,
'walk':walk
}
return data
def dog(name, dog_type):
def bark(dog):
print("dog %s:wang.wa... |
245aeea82b6d97f8b908e25e91d8f2ecd7cd1c5e | yatish27/learn-python-hackerank | /halloween/halloween.py | 172 | 3.5 | 4 | cnt = int(input())
for i in range(cnt):
k = int(input())
if(k % 2 == 0):
print(int((k/2) * (k/2)))
else:
print(int(int(k/2) * (int(k/2) + 1)))
|
2d2345b4a3faadf1da81bb9edca1d4d8f7173b83 | qiaozhu123/zhu | /day14zy.py | 1,303 | 3.6875 | 4 | import threading
import time
bread=0
class cook(threading.Thread):
username=""
def run(self) -> None:
global bread
while True:
if bread<500:
bread+=1
print(self.username,"做了一个面包","现有面包",bread)
time.sleep(3)
elif bread == 500... |
a00c9548740c336e0c19136f04e5aae09f92d4ce | qmnguyenw/python_py4e | /geeksforgeeks/python/python_all/78_16.py | 1,594 | 4.4375 | 4 | hashlib.sha3_224() in Python
With the help of **hashlib.sha3_224()** method, we can convert the normal
string in byte format is converted to an encrypted form. Passwords and
important files can be converted into hash to protect them with the help of
hashlib.sha3_224() method.
> **Syntax :** hashlib.sha3_2... |
9fe8246b7f12ea8f528b5713b83e733e1fbc1d13 | Jsings/Lab4 | /dbDisplay_door.py | 303 | 3.6875 | 4 | import sqlite3
dbconnect = sqlite3.connect("my.db");
dbconnect.row_factory = sqlite3.Row;
cursor = dbconnect.cursor();
cursor.execute('SELECT * FROM sensors where type = "door"');
for row in cursor:
#if row['type'] == 'door':
print(row['sensorID'],row['type'],row['zone']);
dbconnect.close();
|
b74dabe3bb45f58f1fef378b4286f22936e96c69 | Marcus893/algos-collection | /math/my_sqrt.py | 404 | 3.65625 | 4 | def mySqrt(x):
if x == 0 or x == 1:
return x
else:
start, end = 0, x
res = 0
while start <= end:
mid = (start + end) / 2
if mid * mid == x:
return mid
elif mid * mid < x:
start += 1
res = mid
... |
ef085bbfcddf06dc58c436df4ecc8d1743d2c644 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2905/60734/270037.py | 130 | 3.5 | 4 | import re
lst = re.findall(r'\d+',input())
res = 0
base = 0
for x in lst[::-1]:
res += int(x)*(2**base)
base+=1
print(res) |
34e20c31d62fa284807c029e81affb2da90ff51e | rynoschni/python-102 | /reverse.py | 297 | 3.953125 | 4 | nums = [2,3,4,5]
fruits = ["apple", "banana", "orange"]
print(nums)
nums.reverse()
print(nums)
print(fruits)
fruits.reverse()
print(fruits)
a_string = "This is a string"
a= len(a_string) - 1
b_string = ""
while a >= 0:
b_string = b_string + a_string[a]
a -= 1
print(b_string)
|
4d16c46a13e9bb9f88da024dea71896afd2b7178 | anuragmukherjee2001/Python_codes | /OOPs programming/Python oops/Access_specifier.py | 522 | 3.8125 | 4 | # Public Private and protected variables
class Employee:
num_of_leaves = 0
_protected = 1
__private = 200
def __init__(self, name, age, salary, role):
self.name = name
self.age = age
self.salary = salary
self.role = role
def print_details(self):
return f"The name ... |
727ad416c7f6f69a60568e0d22977e94e255ceb1 | brigitteunger/katas | /test_Kth_missing_positive_number.py | 882 | 3.734375 | 4 | import unittest
from typing import List
class Solution:
def findKthPositive(self, arr: List[int], k: int) -> int:
i = 0
j = 0
len_arr = len(arr)
while k != 0:
i += 1
if len_arr == j:
return arr[j-1] + k
if i != arr[j]:
... |
53fbfe6d1fed7d58c94c7a994ba24cd157474776 | Neshametha/Lab-1-Python-Exercises | /Lab1Question3.py | 150 | 3.625 | 4 | '''Yamil Galo'''
'''Ketul Polara'''
'''Stuart Simmons'''
'''Natalie Whitehead'''
n = int(input("Input any number: "))
d = dict()
for n in range(1, n+1):
d[n] = n*n
print(d)
|
b84788d26544e117f45a5a99b0c3b073d1406f7f | afshinatashian/PreBootcamp | /ali.py | 340 | 3.6875 | 4 | def ali(statments):
statments.sort()
smallest_statment=""
for i in statments[0]:
smallest_statment +=i
smallest_statment +=" "
print("\n",smallest_statment)
n=int(input())
statments = []
for i in range(n):
statment=input()
my_list = statment.split()
statments.append(my_lis... |
bf9d890180b7c2e33e39c1e70ce88f5668a6c26b | xiaozuo7/algorithm_python | /offer/LeftRotateString.py | 1,081 | 3.984375 | 4 | #!/usr/local/anaconda3/bin/python3
# -*- coding: utf-8 -*-
"""
汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,
请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。
思路:
先旋转 0-n
再旋转 n-len(s)
再旋转 0-len(s)
@author: xiaozuo
"""
class Solution:
def LeftRotateString(self, s, n):
"... |
356b14550841579aabf70e501ff2d80a76f30d12 | Jallgit/pythonHarjutus2 | /harjutused.py | 1,357 | 3.90625 | 4 | # Harjutus 1 - Leia vahemik
# Looge funktsioon, mis võtab sisendiks ühe arvu
# Funktsioon peab kontrollima, kas antud arv kuulub vahemikku 0 kuni 100 või 101 kuni 1000
# Kui kuulub vahemikku 0 kuni 100, siis tuleb printida tekst "Arv on vahemikus 0st 100ni".
# Kui kuulub vahemikku 101 kuni 1000, siis tuleb prin... |
d95a009fc0dcf1e618d3d2e2bc3aceb428f05d8d | Ali-H-Vahid/mm4w2v | /scripts/remove_stopwords.py | 2,512 | 4.25 | 4 | """
Given a text file and a list of stop-words, this script writes the content of the text file after
removing stop-words. The scripts assumes that the tokens in the text file are separated by spaces.
"""
import sys
import argparse
def remove_stopwords(input_file, stopwords, lowercase=False, remove_punctuation=Fals... |
4f1bf4ee9b06526310f6f8b425cbc21a198db42a | annasw/Project-Euler | /euler20.py | 181 | 3.5 | 4 | # again, python does not have a problem handling big numbers
# (and 100! is way smaller than 2**1000)
from math import factorial
print(sum([int(i) for i in str(factorial(100))]))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.