blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a56e2d4b4a0eda431e36cbe9535222d35915bef3
camblor/CodeAcademyPythonIntensive
/TomeRater.py
12,862
3.921875
4
''' Project: Tome Rater Author: Alfonso Camblor GitHub: https://github.com/camblor Note: Hello, there is something i would like to fix. When I have a constructor error, I don't really know how to handle it. I saw that __del__ with the variable you have created would fix it, but I haven't seen that function in this co...
6fe32bd4e682572932efc41afeeddbb0824666b1
pedrerete/Partum-Figuris
/memoria.py
2,020
3.71875
4
import os inicioEnteros = 1000 limiteEnteros = 1999 limiteDobles = 2999 limiteBoleanos = 3999 limiteTemporales = 4999 limiteConstantes = 5999 limiteDirecciones = 6999 class Memoria: def __init__(self): self.enteros = {} self.dobles = {} self.boleanos = {} self.constantes = {} self.temporales = {} self.dire...
ce49953a42af8ca1b3dba56153170566c305c275
acs3ss/24-card-game-solver
/play24.py
1,378
3.796875
4
#!/bin/python from solver import Solver solver = Solver() gameplay = input("Do you want to...\n\t0 - Play 24\n\t1 - Check solutions\n") while True: if gameplay == "0": # play 24! print() print("If you think there are no solutions, enter 'none'") print("Next Hand: " + " ".join([str(c) fo...
ef40ea50bcade2b40b3f579ccc249f3aacecb4ba
westhak/Applications-Python-R
/functions_numpy.py
1,891
3.953125
4
# -*- coding: utf-8 -*- """ Packages: numpy Task : Practice functions; sigmoid,first derivative, gradient descent etc @author: Swetha """ import hashlib import numpy as np import matplotlib.pyplot as plt # Compute sigmoid function def sigmoid(z): return 1/(1+np.exp(-z)) np.random.seed(2) n = ...
9785b956dfac61062d4e037f147e7feca1c3f5b2
TabsOverSpaces247/number_field_demo
/numberfielddemo.py
1,761
4.03125
4
""" Program: numberfielddemo.py Author: Serghie 10/15/20 Example from page 264-265 This GUI-based program is a simple Python GUI window that outputs the square root of an integer. Check breezypythongui to see all methods and their attributes! """ from breezypythongui import EasyFrame import math """ ...
c3a1eef7ce5b3f1dbca12a15dc22786f4e399c70
aristocrates/vibrating-string
/physicalstring.py
23,020
3.796875
4
""" Solves for the dynamics of a string in two dimensions with initial and boundary conditions Nicholas Meyer """ import numpy as np import problem, integrator class BoundaryCondition: """ Encapsulates a boundary condition. Does not store the surface where the boundary condition applies; this should ...
0a3d63bcbebf131d5cdc9444637c56b83a270116
felmola/code_in_place
/text_practice.py
838
3.921875
4
""" ### Reverse String def main(): str = "Carajo!" print(str) str = reverse_string_simple(str) print(str) def reverse_string(str): reverse = "" for i in range(len(str)): ch = str[i] # print(ch) reverse = ch + reverse return reverse def reverse_string_simple(str): ...
b16fac20ad275a0fa7da70b2bb1f722a2548ff6f
saadi299/Python-with-Mosh
/input.py
704
4.34375
4
'''' name=input('what is your name ?') print('Hi Mr.'+name) ###Exercise: Ask two questions- persons's name and favourite color. Then Print a message like "name Likes color" name=input('What is your name?') color=input("What is your favourite color?") print(name+' likes '+color) ###Type Conversion num=20; name...
456562288dde2236e8c36588f9def68bc4bbc26f
tollek/udacity-data-science
/p3/cracow/audit_postal_codes.py
2,377
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Finds (and tries to fix) postal codes which don't match \d\d-\d\d\d regexp. """ import xml.etree.cElementTree as ET import re import pprint OSMFILE = "krakow_poland.osm" VALID_POSTAL = re.compile('\d\d-\d\d\d') # NON-BREAKING HYPHEN INVALID_POSTAL_NON_BREAKING_HYPHE...
035ca1b62867a04d80bc80e9b9fc0f1ee4973a44
jpch89/picpython
/pp_040_多进程同步之Condition.py
1,496
3.65625
4
from multiprocessing import Process, Condition import time class MyProcess1(Process): def __init__(self, name, cond): super().__init__(name=name) self.cond = cond def run(self): self.cond.acquire() print('%s说:1' % self.name) self.cond.notify() self.cond.wait() ...
e617361de6ee0adb383569bfa9e4d712af301f90
jpch89/picpython
/pp_038_多进程同步之Rlock.py
762
3.53125
4
from multiprocessing import RLock, Process, Value numa = Value('i', 0) numb = Value('i', 0) rlock = RLock() def do_sth(numa, numb): rlock.acquire() try: adda(numa) addb(numb) finally: rlock.release() def adda(numa): rlock.acquire() try: numa.value += 1 final...
d412bd68a9dfce42efbe74a77c902c9b08188642
jpch89/picpython
/pp_054_定时器线程Timer.py
390
3.5625
4
from threading import Timer def do_sth(): print('Hello Timer!') timer = Timer(2, do_sth) timer.start() """ Hello Timer! """ """ 小结 如果想要在指定的时间片段之后再启动子线程,可以使用标准库模块 threading 提供的类对象 Timer。 用于表示定时器线程。 Timer 是 Thread 的子类,也是通过调用方法 start() 来启动线程。 """
aa9059d72dcb5d369818dd851105d56dd8e744cb
dibyakantimahapatra/mnist_hls
/Vivado_hls/tools/tanh_table.py
650
3.640625
4
import sys import math if(len(sys.argv) == 1): bits = 8 integer = 3 elif(len(sys.argv) == 3): bits = int(argv[1]) integer = int(argv[2]) else: print('Using in wrong way. Please refer to source file.') exit() index = [] value = [] _min = 1/(2**(bits-integer)) _begin = -(2**(integer-1)) for i i...
2f5fdb8b1d2754e8c1a67ee896170cf011efd139
dulceadelina/criba
/main.py
1,407
4.03125
4
# Programa que implementa la criba de Erastótenes # donde define los números primos de 2 hasta n # Dulce Adelina Zuñiga Ramos # 20/09/2020 - 21/09/2020 from math import isqrt # here implements sieve of Eratosthenes and receives n def sieve(): # criba in english n = data() # as...
66db9360d8a1e980a33bcc226a94bd52a2a87c14
kimmy2512/03_Programming_Assessment
/02b_Int_check.py
1,207
4.0625
4
# Create Help button # Add in images # Make exit button from tkinter import * import tkinter root = Tk() root.title("Guess the Note") root.geometry("400x400") # A function that checks if the user input is an integer def int_check(): try: int(total_questions.get()) # Check if user input is betwe...
73b64d43b452ec1c22fc2c11a288101b0621b081
sk8erry/python-practice
/sketch/binary_search_tree.py
7,748
4.125
4
import sys class node(): def __init__(self, value=None): self.value = value self.left = None self.right = None self.parent = None class binary_search_tree(): def __init__(self): self.root = None def insert(self, value): if self.root == None: ...
347593dea2bf6a97df32be6b5a45744a4ef57d21
sk8erry/python-practice
/problems/dayscount.py
2,154
4.28125
4
#This program is used to count how many days you have lived! import datetime #My birthday birthYear = int(input('Please enter birth year: ')) birthMonth = int(input('Please enter birth month: ')) birthDay = int(input('Please enter birth day: ')) #Get current date now = datetime.datetime.now() currentYear = now.year c...
6f8fcf6b8b2a9d71026d25d4c10f11dc6b7a0048
Star-Coder-7/FunGames
/turtle_race.py
1,826
4.09375
4
import turtle from tkinter.messagebox import showwarning, showinfo import time import random WIDTH, HEIGHT = 700, 600 COLORS = ['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Black', 'Purple', 'Pink', 'Brown', 'Cyan', 'Gray', 'White', 'Turquoise'] def getRacers(): racers = 0 while True: racer...
d93038c05cfa3d493e1ebe5287014d349ec9728b
Star-Coder-7/FunGames
/rock_paper_scissors.py
3,853
4.15625
4
from random import randint userWins = 0 computerWins = 0 ties = 0 options = ["rock", "paper", "scissors"] while True: randomNumber = randint(0, 2) # rock: 0, paper: 1, scissors: 2 computerPick = options[randomNumber] userPick = input("\nType rock/paper/scissors or q to quit: ").lower() if user...
9ce751d715933058ce138788821b59ab646d318e
UDOM-AI-COMMUNITY/Python-100
/dots.py
197
3.515625
4
def add_dots(name): return ".".join(name) def remove_dots(name): return name.replace(".","") add_dots("hezekiah") remove_dots("h.e.z.e.k.i.a.h") print(remove_dots(add_dots("hezekiah")))
36d6aa1cfc2fa29a00bbcd0378a7c08ea4f12b1c
mariacarolina0810/ejerciciosPython
/ejemplo6.py
502
3.875
4
edad= int(input("Digite su edad")) genero= input ("Digite sexo, H para hombre, M para mujer") if edad>=18: if genero in'Hh': print ("Señor usted es mayor de edad") elif genero in 'Mm': print ("Señora, usted es mayor de edad") else: print("Dato incorrecto") else: if genero in'Mm':...
c13c8359cb2be7029315f2e3f283225a49d605b7
rayz/Boxhead-Remade
/devil.py
2,242
3.5
4
import pygame from sprites import * import math class Devil(pygame.sprite.Sprite): def __init__(self): super().__init__() self.image = devil_down_pic self.rect = self.image.get_rect() self.rect.x = 100 self.rect.y = 100 self.speed = 1 self.changex = 0 ...
e516ee1b07539a03d1a2aebf153974aa4ca780e2
cwake7960/PythonProj
/WordGame/Main.py
579
4.0625
4
print("Welcome to happy fun game") name = input("What is your name ") age = input("what is your age ") print("hello ", name, "you are ", age ," years old") if int(age) >= 18: print(name, " you are old enough") wants_to_play = input("Do you wnant to play? ").lower() if wants_to_play == "yes": print("Lets play...
4d8ed989c9d8624c6c7320f7446f3d63827e54af
cwake7960/PythonProj
/RockPaperSicsor/main.py
463
3.921875
4
import random def is_win (player, oponent): if (player == 'r' and oponent =='s') or (player == 'p' and oponent == 'r') or (player == 's' and oponent == 'p'): return True def play(): user = input(f"pick rock(r), paper (p), sciscors (s)").lower() computer = random.choice(["r", "s", "p"]) ...
a55edcac70b81ee1cfb199508e4d916c69c270b7
AnaErmakov/python
/hw_6_2.py
613
4.0625
4
class Road: def __init__(self, length, width): """Определяем класс Road с атрибутами длины length и ширины width дороги""" self._length = length self._width = width def road_weight(self, weight, thickness): """Функция расчета массы асфальта с заданной массой weight кг/м2 и толщ...
da8fb0ee5d8392eda40f2453a461aa3ee0ed0290
AnaErmakov/python
/hw_1_6.py
333
4
4
print('Введите результат первого дня в км') a = float(input('a = ')) print('Введите желаемый результат в км') b = float(input('b = ')) i = 1 while b > a: i += 1 a = a * 1.1 print(f'Желаемый результат будет достигнут на {i} день')
c9455421b00137624b2c69a31d3e1a0a916240c6
AnaErmakov/python
/hw_1_41.py
253
3.859375
4
print("Введите целое положительное число") n = int(input("n = ")) i = n max_n = 0 while i > 0: if max_n <= i%10: max_n = i%10 i = i//10 print(f'Наибольшая цифра в числе {n}: {max_n}')
f9bd51134a099fb94c03d1f80c39ecd1dc40675c
AnaErmakov/python
/hw_2_2.py
307
3.71875
4
my_list = input("Введите элементы списка через запятую: ").split(',') if len(my_list) > 1: i = 1 while i < len(my_list): my_list[i - 1], my_list[i] = my_list[i], my_list[i - 1] i += 2 print(f'Преобразованный список:{my_list}')
53fc5f2555b65f83dcba23371de293a29bb92a13
ManarSholi/FounderTraining
/Python/shapes.py
191
3.65625
4
import turtle george = turtle.Turtle() george.color("red") # for side in [1, 2, 3, 4, 5, 6]: for side in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]: george.forward(200) george.left(150)
66419e79410d97515a4744f093f5c292cea8a78e
g00364787/52167assessments
/gmit--exercise01--and--exercise02--code--and-output.py
3,596
4.375
4
# AUTHOR = PAUL KEARNEY # STUDENT ID = G00364787 # DATE: 2018-01-23 # # THIS IS AN AMALGAMATION OF WEEK01 AND WEEK02 SOURCE CODE # AND OUTPUT # AND COMMENTS MADE IN THE DICUSSIONGROUP # # EXERCISE 01 # # filename= gmit--week01--FIBINACCI--20180123.py # # STUDENT ID= g00364787 # FINONACCI NUBMERS # I...
99cafe96b5f6af6a9f86464822537a8ff54ed8e0
bmdundar24/assignments
/tic_tac_toe.py
708
3.921875
4
""" def tic_tac_toe (list1): tic = ["X","X","X"] tac = ["O","O","O"] for k in list1: if k == tic: return "X" elif k == tac: return "O" for i in range(len(list1)): for j in range(i,len(list1)): list1[i][j], list1[j][i] = list1[j...
878a16a151217a244289afee267a1b6e587ccecf
bmdundar24/assignments
/yıldız.py
100
3.671875
4
x = ("*") y = 4 for i in range(1,6) : print(x*i) while y >= 1 : print(y*x) y -=1
83dc72e38d9e6c161ca95c563cd706aa8f2c0e5c
bmdundar24/assignments
/asal_sayı.py
256
3.765625
4
n = int(input("Lütfen bir sayı giriniz: ")) list_1 = [] list_2 = [] for i in range(2,n-1): if n % i == 0: list_1.append(i) if list_1: print(f"{n} sayısı asal sayı değildir.") else: print(f"{n} sayısı asal sayıdır.")
566a572d7c62e85078fbc77b5cacb00418daf542
tishyk/python-course-alphabet
/multiprocessing/threading_examples/threads.py
616
3.640625
4
import threading import time from multiprocessing.pool import ThreadPool def print_with_delay(delay, name=None): name = str(delay) if name is None else name i = 0 while i <= 20: time.sleep(delay) i += 1 print(f"My name is {name}; My delay is {delay}; This is my {i} iteration") i...
b951ae62b67b0dd23227ec17740a37cf475c896d
liushuqing506/PythonForBiologists
/PfB_ch6_exercises.py
2,691
3.640625
4
# -*- coding: utf-8 -*- """ Created on Sun May 24 12:14:10 2015 @author: colin """ # chapter 6 exercise: conditional tests: individual test comments inside loop # fucntion calculating AT content # AT content = (#A's + #T's)/stringlength def get_at_content(dna): numA = dna.upper().count("A") numT = dna.uppe...
233bc9210485149dd9a7e0db4f3d9875babc2c13
blukitas/JugandoCodewars
/JugandoCodewars/ResueltosCodeWars/SortOddNumbers.py
352
3.953125
4
# You have an array of numbers. # Your task is to sort ascending odd numbers but even numbers must be on their places. # Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it. # Example # sort_array([5, 3, 2, 8, 1, 4]) == [1, 3, 2, 8, 5, 4] # https://www.codewars.c...
d4414ac12a0d0494c8924b34aeb3ace3bf5afe7c
blukitas/JugandoCodewars
/JugandoCodewars/ResueltosCodeWars/intToIP.py
1,475
3.90625
4
# Take the following IPv4 address: 128.32.10.1 # This address has 4 octets where each octet is a single byte (or 8 bits). # 1st octet 128 has the binary representation: 10000000 # 2nd octet 32 has the binary representation: 00100000 # 3rd octet 10 has the binary representation: 00001010 # 4th octet 1 has the bi...
378e222fb4c3f2beb2fba43b23de99837deec465
blukitas/JugandoCodewars
/JugandoCodewars/ResueltosCodeWars/nextBigger.py
1,307
3.53125
4
# You have to create a function that takes a positive integer number and returns the next bigger number formed by the same digits: # 12 ==> 21 # 513 ==> 531 # 2017 ==> 2071 # If no bigger number can be composed using those digits, return -1: # 9 ==> -1 # 111 ==> -1 # 531 ==> -1 def nextBigger(n): s = str(n) ...
fa2e1610a3c4fe5da530479aa301b10eada38854
blukitas/JugandoCodewars
/JugandoCodewars/squareToSquare.py
1,822
3.625
4
# My little sister came back home from school with the following task: # given a squared sheet of paper she has to cut it in pieces which, when assembled, # give squares the sides of which form an increasing sequence of numbers. # At the beginning it was lot of fun but little by little we were tired of seeing ...
d18273f4b5c654b4860dd5b1dcfe97f75d4442f8
blukitas/JugandoCodewars
/JugandoCodewars/ResueltosCodeWars/highestValue.py
1,768
3.90625
4
# Given a string of words, you need to find the highest scoring word. # Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc. # You need to return the highest scoring word as a string. # If two words score the same, return the word that appears earliest in the original ...
b88ab6dcaef18cf0a45e5dd4ef9853097f0bac62
HackerRankSolutions/HackerRank_Solutions
/Python/Basic Data Types/Nested Lists/Solution.py
708
3.828125
4
if __name__ == '__main__': list = [] for _ in range(int(input())): name = input() score = float(input()) list.append([name, score]) second_lowest = [] smallest = 9999 # considering smallest and second_smallest to be very large second_smallest = 9999 for block in list: ...
2d523cc4a071b1664ad157503407db8cb10201f6
doinalangille/Computer-Architecture
/simple.py
4,168
3.734375
4
PRINT_TIM = 0b01 # 1 This is 1-byte command HALT = 0b10 # 2 PRINT_NUM = 0b11 # opcode 3 SAVE = 0b100 PRINT_REG = 0b101 # opcode 5 ADD = 0b110 PUSH = 0b111 POP = 0b1000 CALL = 0b1001 RET = 0b1010 # RAM (a slot in memory) # memory = [ # PRINT_TIM, # ...
cca61aa07ab743624ba1a8515ae85b6ca740eab7
BazzalSeed/Mianjing
/TP/problems.py
9,414
3.703125
4
""" 1. LRU Caching """ Python /** * 本代码由九章算法编辑提供。版权所有,转发请注明出处。 * - 九章算法致力于帮助更多中国人找到好的工作,教师团队均来自硅谷和国内的一线大公司在职工程师。 * - 现有的面试培训课程包括:九章算法班,系统设计班,算法强化班,Java入门与基础算法班,Android 项目实战班,Big Data 项目实战班, * - 更多详情请见官方网站:http: //www.jiuzhang.com /?source = code */ class LinkedNode: def __init__(self...
3051fa1d184f09990cccd6b48250920fb50d0521
Chanterz/CodeWars
/namelist.py
340
3.96875
4
def namelist(names): if len(names) < 3: if len(names) == 2: return "{} & {}".format(names[0]['name'], names[1]['name']) elif len(names) == 0: return "" else: return names[0]['name'] result = "".join([x['name'] + ", " for x in names[:-2]]) result += "{} & {}".format(names[-2]['name'], names[-1]['nam...
7cd083189a9a63a2da104bf2e28c2bbbfc71b614
Chanterz/CodeWars
/tribonacci.py
238
4.03125
4
def tribonacci(signature, n): a, b, c = signature if n == 0: return [] if n <= 3: return signature[:n] for _ in range(n - 3): a, b, c = b, c, a + b + c signature.append(c) return signature print(tribonacci([1, 1, 1], 1))
fb3abeafd05fa9f733668aed3059e7dbc925851e
apoorvaagrawal86/PythonLetsKodeIt
/PythonLetsKodeIt/Basic Syntax/string_methods_2.py
651
4.1875
4
""" Examples to show available string methods in python """ # Replace Method a = "1abc2abc3abc4abc" print(a.replace('abc', 'ABC', 1)) print(a.replace('abc', 'ABC', 2)) # Sub-Strings # starting index is inclusive # Ending index is exclusive b = a[1] print(b) c = a[1:6] print(c) d = a[1:6:2] print(d) e = 'This is a st...
5a02a76043ddf53bc557354ba0a0027613b5a78b
peace153/ballot-detector
/main.py
1,532
3.875
4
import os import cv2 import numpy as np # function to check if the card is totally in the screen or not # now return boolean, should return boolean and card picture to send to detect_x def detect_card(): found_card = input("Found Card(1=true,other=false) ?:") return found_card == "1" # function to detect res...
627415a65c7fab90e5616a5372c622d213ab8c0c
carol-kangara/python-ip1
/tests/user_test.py
306
3.546875
4
class User: ''' This is a class that generates new instances of account log in ''' def __init__(self,user_name,password): ''' we have created 3 arguments,the first argument is self. Args: self.user_name=user_name self.password=password '''
a2b9a135768b3f195ff98386d350c7799b645923
Arlix/Pa55word1
/scripts/email_list_generator.py
771
4.28125
4
# a quick common email list generator # first you need to create a list of common names and save it as names.txt # then modify the suffixList array so it contains only the suffixes you want # then just run the script...though you might need to output the results to file...or just copy and paste from the terminal suffi...
b079c9245eabb2d241658f8e6eed179d531573b6
Asthabura/Basics-of-data-science
/histogram.py
322
3.703125
4
from matplotlib import pyplot as plt frequency=[6,15,16,21,18] height=[0,10,20,24,30,50] plt.hist(height,bins=height,edgecolor='black') #Bins helps us to decide the band size and edgecolor helps us to distinguish bands. plt.title('Heights of plants growing in a garden') plt.xlabel('Height') plt.tight_layout() plt.show(...
70740eb69bebacc5fe54edf31ce13a9e037f96ca
kanziwoong/kanziwoong
/seminar/algorithm/day02_hash.py
1,790
3.5625
4
import random def genEmptyList(sizeOfList): emptyList = [0 for i in range(sizeOfList)] return emptyList def genSuffledList(selectedNumberRange, selectedNumber): orgList = [i+1 for i in range(selectedNumberRange)] suffledList = [] for i in range(selectedNumber): tmp = random.choice(orgList...
04a99b013bec7ff7db7cd10f0c4f4650fb3f0594
AtharvaJoshi21/PythonPOC
/Lecture 9/Lecture9Assignment4.py
379
4.0625
4
#WAP to accept a string from user and print count of consonants in it def CountConsonants(inputStr): count = 0 for x in inputStr: if x not in ('aeiouAEIOU'): count += 1 return count def main(): inputStr = input('Please enter a string : ') print ('Number of consonants: ', CountC...
743f38bbb2cd70c7c57b41a6715040ff2b56a91d
AtharvaJoshi21/PythonPOC
/Lecture 12/Lecture12HWAssignment2.py
788
4.1875
4
# WAP to accept an unsorted list of integers from user and sort it using # a. Bubble Sort # b. Insertion Sort def BubbleSort(inputList): listCount = len(inputList) for x in range(listCount - 1): alreadySorted = True print('Iteration', x) for y in range(x+1, listCount - 1): ...
c64135dea0eaab32bb41a50abfdd7503ecde740c
AtharvaJoshi21/PythonPOC
/Lecture 5/Lecture5Assignment3.py
290
4.3125
4
#WAP to accept three numbers from user and print minimum of them. num1, num2, num3 = eval(input('Please enter three numbers: ')) print ('The minimum of the three numbers is : ') if num1 < num2 and num1 < num3 : print (num1) elif (num2 < num3) : print (num2) else : print (num3)
e0f6c6fac0c995ce00018a6ba612dfd85761e6c0
AtharvaJoshi21/PythonPOC
/Lecture 6/Lecture6Assignment1.py
313
3.921875
4
#WAP to accept two strings from user and swap their first two chars inputStr1 = input('Enter first string: ') inputStr2 = input('Enter second string: ') outputStr1 = inputStr2[:2] + inputStr1[2:] outputStr2 = inputStr1[:2] + inputStr2[2:] print ('Output is: ') print (outputStr1) print (outputStr2)
b8748c973592922fec61da8d685623e21f1b3fa8
AtharvaJoshi21/PythonPOC
/Lecture 6/Lecture6Assignment2.py
155
4
4
#WAP to accept an integer from user and print it's table inputInt = eval(input('Please enter number: ')) for x in range(1,11): print (inputInt * x)
1c23d26072b22da5ab37c96649b9bc38ed6d3aa9
AtharvaJoshi21/PythonPOC
/Lecture 16/Lecture16HWAssignment2.py
518
4.125
4
# WAP to accept a filename from user and print it in reverse order. Lines should be read only once and not using "readlines()" [Hint: Recursion] def RevPrintFileContent(inputFile, nextLine): if nextLine == '': return "End of file" else: RevPrintFileContent(inputFile, inputFile.readline()) ...
930a18f30ea5f5c9c0505d889676b3cb0bf34be1
AtharvaJoshi21/PythonPOC
/Lecture 8/Lecture8Assignment4.py
377
4.125
4
#WAP to print Fibonacci series starting from 1 to n def Fibonacci(endIndex): a = 1 b = 1 print (a,b, end = ' ') endIndex = endIndex - 2 while endIndex > 0: c = a + b print (c, end = ' ') endIndex = endIndex - 1 a = b b = c def main(): endIndex = eval(input('Please enter number: ')) F...
8e1e23dbcef786ebf937799d377e063baebd438b
AtharvaJoshi21/PythonPOC
/Lecture 13/Lecture13HWAssignment4.py
1,791
4.40625
4
# WAP to accept two lists from user and find symmetric difference of them (exclude common elements) [l1 - l2 union l2 - l1] def SymmetricDiffOptimized(inputList1, inputList2): resultList = [] i=0 j=0 while i < len(inputList1) and j < len(inputList2): if inputList1[i] not in inputList2: ...
37fd23da5dce15b0acd7fefeb5966f411534197e
AtharvaJoshi21/PythonPOC
/Lecture 5/ControlFlowSample2_Function.py
366
4.34375
4
#WAP to accept three numbers from user and print maximum of them. def MaximumNum(num1, num2, num3): if (num1 > num2 and num1 > num3) : return (num1) elif (num2 > num3) : return (num2) else : return (num3) num1, num2, num3 = eval(input("Please enter three numbers: ")) print ('The greatest number ...
3cc7391e238faadd9c341117a042a64a46cd8e02
AtharvaJoshi21/PythonPOC
/Lecture 28/Lecture28HWAssignment4.py
198
4.15625
4
# WAP to accept a filename from user and print all words starting with capital letters. def main(): inputFilePath = input("Please enter file name: ") if __name__ == "__main__": main()
778d18373f1fb6cbe43417af9fd914fbbe4a26d3
AtharvaJoshi21/PythonPOC
/Lecture 14/Lecture14Assignment1.py
805
4.125
4
# WAP to accept list of intergers and check list is palindrome of not. def IfPalindrome(inputList): i = 0 j = -1 k = 0 #Find mid index of list by dividing it by 2 (Floor division) listLenMid = len(inputList)//2 while k <= listLenMid: #Compare elements a i and j respectively an...
1bb9e0ad8d3d12edb1462cd765b0e93a2d9f85b8
johnstaf144/A_Short_Tale
/A_Short_Tale_v0.0.3/auxscripts/init.py
995
3.53125
4
#you chose... poorly class Hero(): def __init__(self, name, Class): self.name = name self.inventory = [] self.Class = Class self.mage = 0 self.warrior = 0 self.berserker = 0 self.assassin = 0 self.yeet = 0 self.hidden_class = 0 #player stats self.speed = 0 self.percep...
b33a30c0b30b66a2322cb435a8eff88132d69a37
dylanupde/MyPygameRepo2
/MyPygame/Vector2.py
1,264
3.625
4
##################################################### # Author: Dylan # Date: 02/15/20 # Email: dupdegra@uccs.edu # # Basically just acts like a Vector2 from Unity ##################################################### import math class Vector2(object): """A vector!""" def __init__(self, inputX...
7da1f4a86cb718e1870a5745387b94ed6bea440e
jhaze420/smiesznepsy
/hajshdjashd.py
200
3.5
4
from random import Random import statistics a = [] r = Random() for i in range(100): a.append(r.randint(0,101)) print("max", max(a)) print("min", min(a)) print("średnia", statistics.mean(a))
faeed660cd204680788994e4a86db40f451c960b
Lavilord/LabsPython
/lab2/Reptile.py
1,405
3.71875
4
from Animal import Animal class Reptile(Animal): def __init__(self, length_in_centimeters: int, weight_in_grams, price, origin_country, is_predator, eats_in_grams): self.length_in_centimeters = length_in_centimeters Animal.__init__(self, weight_in_grams, price, origin_country, is_predator, eats_in...
cce8960bc83678965587047a0abfdc59a62a4b87
agabhi017/Codeforces
/Practice/palin.py
2,109
3.59375
4
import numpy as np def expand(str, low, high, s, indices): # run till str[low.high] is a palindrome while low >= 0 and high < len(str) and str[low] == str[high]: # push all palindromes into the set s.add(str[low: high + 1]) if high - low > 1: indices.append([low, high]) ...
ef2eab1176a1b58fb06e1fb3c71129eb794bf59e
saranshbht/bsc-codes
/semester-6/Python Practice/numpyPractice/program3.py
304
3.6875
4
import numpy as np x = np.array([1, 2, 3, 4]) print("Original array:") print(x) print("Test if none of the elements of the said array is zero:") print(np.all(x)) x = np.array([0, 1, 2, 3]) print("Original array:") print(x) print("Test if none of the elements of the said array is zero:") print(np.all(x))
f1a990112daa9ffdf928c6748531e10209b5d95f
saranshbht/bsc-codes
/semester-6/Python Practice/fib.py
213
4.03125
4
def fib(n): a, b = 1, 1 for i in range(0, n): print(a, end = ' ') a, b = b, a + b n = int(input("Enter a number: ")) if n < 1: print("Please enter a positive number") else: fib(n)
1a22e3559507cd80b976d491939100f8e90fe4b7
wglee0511/hh99-ch2
/app.py
143
3.8125
4
input = [3, 5, 6, 1, 2, 4] def find_max_num(array): array[2] = array[2] + 2 return array result = find_max_num(input) print(result)
e9a886b0c38487024aba315d86d4729c743a4f3f
wglee0511/hh99-ch2
/week_2/06_is_existing_target_number_binary.py
792
3.84375
4
finding_target = 5 finding_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] def is_existing_target_number_binary(target, array): cur_min_index = 0 cur_max_index = len(array) - 1 cur_guess = (cur_max_index + cur_min_index) // 2 find_count = 0 while cur_min_index <= cur_max_index: ...
e1a097b1ad736c2f7fb236463ba4947a8be6d5fb
lob1999/Python-Basics-and-Beyond-2021
/01_python_syntax/03_operators.py
1,582
4.15625
4
""" OPERATORS Operators are used to perform operations on variables and values. 1) ARITHMETIC OPERATORS + Addition x + y - Subtraction x - y * Multiplication x * y / Division x / y % Modulus x % y ** Exponentiation x ** y // Floor division x // y 2) Logical Operato...
866d770e8d25352f9f98b19ac096f2184d0b1add
lob1999/Python-Basics-and-Beyond-2021
/01_python_syntax/01_hello_world_comments_and_indentation.py
694
4.03125
4
""" HELLO WORLD! Let's start with Indentations and comments. """ # INDENTATION """ Indentation refers to the spaces at the beginning of a code line. Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important. Python use...
9925554d19a51f2791397596cfcc2926757a4010
FernandoLavarreda/PasswordManager
/db_manipulation.py
2,206
3.515625
4
# Fernando Jose Lavarreda Urizar # Basic DataBase Manipulation import math import pyperclip import sqlite3 as sql from datetime import date def addWebsite(name, password): """Add a new website and its correspondig password to the database""" db = sql.connect("data.db") cr = db.cursor() cr.execute("INS...
bb246b5efa96be8f6d784b8976256236bd258c7b
gforghieri/TUDelft-CSE2510-ML
/assignment_3/exercise4_1.py
1,241
3.828125
4
from collections import Counter # to count unique occurances of items in array, for majority voting from exercise3_1 import * def get_majority_vote(neighbour_indices, training_labels): """ Given an array of nearest neighbours indices for a given test case, tally up their classes to vote on the correct c...
5959e62e9bda1682312f99463f327090c9248c23
gforghieri/TUDelft-CSE2510-ML
/assignment_4/exercise5_2.py
1,136
3.75
4
from exercise5_1 import * def compute_accuracy(predictions, y_true): """ Computes the accuracy of the predictions based on the true labels. :param predictions: an array of size (n,) of the computed predictions for each image. :param y_true: an array of size (n,) of the true labels of each image. :...
c295a7a2960f66d4b46bf42c6c89670306edeeb7
gforghieri/TUDelft-CSE2510-ML
/assignment_4/exercise4_2.py
1,521
3.921875
4
from exercise4_1 import * def calculate_gradients(theta, x, y): """ Calculate the gradient for every datapoint in x :param theta: numpy array of theta :param x: numpy array of the features :param y: the label (positive (1) or negative (0)) :return: The gradients for every datapoint in x ""...
53a7b7cca8fd084a8f8d4cb0ebf72e9bd2a9dd24
wondering516/Python-repo
/A07/使用类的方式创建窗口.py
959
3.640625
4
import tkinter from main_frame import MainFrame #创建一个TK类的子类 #子类继承父类所有的方法和属性 class MainView(tkinter.Tk): # 构造方法 def __init__(self): #必须调用父类的构造方法 super().__init__() # 窗口居中显示 self.center self.title('sousuo') self.resizable(width=False,height=False) conta...
1b265ee460a415eee77fe1e0701be92d79e07843
blairck/chess_notation
/test/test_board.py
16,450
3.890625
4
"""Tests for board module""" import unittest from src import board class TestTileLine(unittest.TestCase): """Tests for TileLine class""" def test_white_color(self): """Input with 'w'""" actual_result = board.TileLine('w').line expected_result = ' ' self.assertEqual(actual_...
211bfaeed1bec4a48653aac00d0a887ea71bcd77
WinnaZ/PyCaScheduleMk
/main.py
939
3.703125
4
# -*- coding: utf-8 -*- from project import Project from vote import voting def menu_enter(): print "1) para ingresar " print "2) para salir " def menu_vote(): print "l) para levantar la mano " print "p) para pasar " projects = [] out = False while not out: menu_enter() option = raw_input(""...
8f531f047b690023047ddd45c503654cef3f4936
DimitrisOGDimolikas/Python-Exercises
/ask10.py
2,084
3.953125
4
import sys import string from random import randint filename = raw_input("Enter the file's name: ") # File manipulation myFile = open(filename, 'r') myFile.close() wordList = [] # Get the words without punctuation wordList = file.read().translate(None, string.punctuation) wordList = wordList.spl...
1d49c12fd972caa0dcc00a5b023a26806eacb6af
kaushik8890/bounce
/guessing game.py
1,785
4.1875
4
# guessing game from random import randint from sys import exit x = randint(1,100) #print (x) guesses = [0] print('The given number is between 1 and 100. \nTry to guess the number in 10 guesses') #guess = int(input('first guess: ')) #if guess == x: # print('Correct! you have guessed in the very fir...
94767a65cf7a505aee64c39881d4204ff9dc8736
HenriqueHartmann/Pensamento-Computacional
/cap-pc-07-2.py
499
4.09375
4
n1 = float(input("Digite o primeiro valor: ")) n2 = float(input("Digite o segundo valor: ")) print("+ Soma\n- Subtração\n * Multiplicação\n / Divisão\n") op = input("Escolha a operação: ") if op == '+': print("Soma: {}". format((n1 + n2))) elif op == '-': print("Subtração: {}". format((n1 - n2))) el...
e40bc348fbb8b69ee868c6837f72094042420467
HenriqueHartmann/Pensamento-Computacional
/cap-pc-04-1.py
195
3.6875
4
import math pA = {"x": 10, "y": 20} pB = {"x": 30, "y": 45} rx = pow((pB["x"] - pA["x"]), 2) ry = pow((pB["y"] - pA["y"]), 2) r = math.sqrt(rx + ry) print("Resultado: {}".format(r))
1101dc950cde220fd2f59aec285060624fcc1847
HenriqueHartmann/Pensamento-Computacional
/cap-pc-07-3.py
341
3.96875
4
idade = int(input("Digite a idade: ")) if idade >= 0 and idade < 12: print("Criança") elif idade >= 12 and idade < 18: print("Adolescente") elif idade >= 18 and idade < 30: print("Jovem") elif idade >= 30 and idade < 65: print("Maduro") elif idade >= 65: print("Idoso") else: print(...
4068392047bb5129355997cfbbaf75ee8ca7eba9
jasoncwells/Test_3
/scraper.py
1,236
3.875
4
import scraperwiki #next line imports the lxml.html library import lxml.html # # # Read in a page html = scraperwiki.scrape("http://uk.soccerway.com/teams/netherlands/fortuna-sittard/") # # # Find something on the page using css selectors #use the .fromstring function to turn html into a lxml 'object', a variable calle...
3a6052b361cc433457085c01751c1cbff190ece5
Daniel-Kellberg/ct110
/P4HW1_Kellberg.py
384
4.125
4
# CTI 110 # P4 HW1 Distance Traveled # Daniel Kellberg # June 25, 2018 def main(): speed = int(input('What is the speed of the vehicle in mph?')) time = int(input('How many hours has it traveled?')) print(speed) print(time) for time in range(1, 1+ time): DistanceTraveled= speed...
fa1298c4661e572f588e95d2b898ca5ecf2a6d44
olyaromanyuk/data_structures_workshop_initial
/data_structure_tests.py
535
3.5625
4
import unittest from data_structures import List as DataStructure class TestDataStructure(unittest.TestCase): def test_data_structure(self): ds = DataStructure() ds.add(5) ds.add(1) ds.add(0) ds.add(2) ds.add(2) ds.add(4) self.assertEqual(ds.get_min(...
e7fee74b8595a56b188d7815625a562fbc270b51
robertvari/python_alapok_210604
/Blackjack/game_assets/assets.py
3,647
3.609375
4
import random from faker import Faker fake = Faker() class PlayerBase: def __init__(self): self._name = None self._credits = random.randint(100, 1000) self._hand = [] self.in_game = True def create(self): self._name = fake.name() return self def draw_card...
d1b0dbd44cd3c3d1c54a354468c85bdb04bf2f48
cpalm9/PythonDataStructures
/recursionPractice.py
316
3.546875
4
import os def search_directory(level, dirname): # search the dirname print(level, '>>>>>', dirname) #recurse through the directories for fn in os.listdir(dirname): path = dirname + '/' + fn if os.path.isdir(path): search_directory(level + 1, path) search_directory(0,'.')
3a246b852bf8540433e15eb663d80360f57e3ad8
cpalm9/PythonDataStructures
/Projects/sortanalytics/sort_api.py
1,687
4.09375
4
class SortMethods(object): def bubble_sort(self, input): length = len(input) for i in range(length-1, -1, -1): for j in range(i): if input[j] > input[j+1]: input[j], input[j+1] = input[j+1], input[j] return input def insertion_sort(self,...
a663b16bf7059428f1e0a8991e31a89016da097a
cpalm9/PythonDataStructures
/Projects/gen_algo/main.py
2,164
4.0625
4
''' The problem: Maximizing the percentage of time spent being productive while still finding time to be happy ASSUMPTIONS: - Percents are displayed in integers (70 = 0.7 or 70%) - Items to complete are no more than 3 - Optimal percentages are given as a reference ''' class SolvingMyProble...
c9450eabb81a8e0bd336e7fa89780f18aee8ff24
taragor/PythonUebungen
/PyProgs/Aufgabe24.py
528
4.125
4
#/bin/usr/python3 #24. Write a Python program to find numbers within a given range where # every number is divisible by every digit it contains. def divisible(inchen): # lst = [(x,y) for x in inchen for y in [u for u in str(x) if u!='0'] if x%int(y)==0 ] # print(lst) print([x for x in inchen if all(map...
379d62e735e263a5cde8de71ddc813bac405d533
taragor/PythonUebungen
/PyPrgs_Aufgaben/calc.py
560
4.0625
4
#!/usr/bin/python3 import sys def calc(v1, op, v2): if(op == "+"): return(float(v1) + float(v2)) elif(op == "-"): return(float(v1) - float(v2)) elif(op == "*"): return(float(v1) * float(v2)) elif(op == "/"): return(float(v1) / float(v2)) else: print("Bitte re...
196d110f6cdf2fe3241313d5ff92f46c30c2e7cf
taragor/PythonUebungen
/PyPrgs_Aufgaben/rot13.py
842
3.8125
4
#!/usr/bin/python3 import string import sys def lowerRot13(): letters = list(string.ascii_lowercase) dic = {} for i in range(0, len(letters)): dic[letters[i]] = letters[(i+13)%len(letters)] return dic def upperRot13(): letters = list(string.ascii_uppercase) dic = {} for i in range...
e5ba64a0fd7ba98112293c6335c4d8742a51e12d
taragor/PythonUebungen
/PyPrgs_Aufgaben/b1a3.py
179
3.921875
4
#!/usr/bin/python3 def myAppend(liste, ele): liste[len(liste):] += [ele] return liste def main(): print(myAppend([1,2,3], 3)) if __name__ == '__main__': main()
b8dd8fb6f30dd8a5173dd95cdf05390dc2333066
taragor/PythonUebungen
/PyProgs/Aufgabe5.py
273
4.125
4
#!/bin/usr/python3 #5. Write a Python program to filter a list of integers using Lambda. def main(): integers = list(range(1,100)) filteredList = list(filter(lambda x: x%2 == 0,integers)) print(filteredList) pass if __name__ == "__main__": main()
1c3c13bb5773b8fe4fa53f5e19144315981f82a2
taragor/PythonUebungen
/PyPrgs_Aufgaben/b4a5.py
541
3.671875
4
#!/bin/usr/python3 import sys from soundex import soundex import string def main(args): if len(args)<2: print("RTFM") exit file = open(args[1],"r") words = file.readlines() for word in words: cleanWord = "" for letter in word: if letter in list(string.ascii_...
ad5e9161be1fae099557517e477e3feb73c98b71
G90SG/Python-Activity
/Favourite City.py
288
4.375
4
# Create variables for Name and City - get input from the user and concatenate the variable within a string name = input ("What is your name? ") print ("\n") city = input ("Which city do you live in, " + name + "? ") # Print new line print ("\n") print (city + " is my favourite City!")
9bf12d5442fbd0efeec84ce569dac813746df6a0
JBushagour/Python-Terminal-Hangman
/HangmanClass.py
3,042
3.84375
4
import string # The gallows that the hangman will 'use' hangmanRepr =''' ____________ |---------- \\ | || || || || || || || || || ____...