blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fd00acdfa7e5f6187dcef82ca53e2a34595bb3e9
erinmiller926/adventurelab
/adventure_lab.py
2,337
4.375
4
# Adventure Game Erin_Miller import random print("Last night, you went to sleep in your own home.") print("Now, you wake up in a locked room.") print("Could there be a key hidden somewhere?") print("In the room, you can see:") # The menu Function: def menu(list, question): for item in list: print(1...
f3e0649ba83f365ea5d1a0dd16f04935935f5af5
arihant-2310/Python-Programs
/average height og boys nd girls.py
716
3.6875
4
n= input('enter number of students:-') student= [] print'\t\tENTER STUDENT DETAILS' i=1 while i<=n: name= raw_input('enter name-') rno= input('enter roll number-') gender= raw_input('enter your gender(M/F)-') height= input('enter height in cms-') student.append((name,rno,gender,height)) ...
4dd2b7b009d9eb025d8b867477e8919fdb38f70c
mrseidel-classes/archives
/ICS3U/ICS3U-2022-2023/Code/python-notes/14 - lists/lists.py
838
4.625
5
#----------------------------------------------------------------------------- # Name: Lists (lists.py) # Purpose: To provide examples of how to wor with lists in Python # in a variety of ways including specific functions for lists # # Author: Mr. Seidel # Created: 27-Oct-2018 # Updated...
b5f295bac917dfe6a46e6309b43e0588d0581839
ItamarRocha/DailyByte
/week_012/day84_countingprimes.py
752
3.984375
4
""" This question is asked by Google. Given a positive integer N, return the number of prime numbers less than N. Ex: Given the following N… N = 3, return 1. 2 is the only prime number less than 3. Ex: Given the following N… N = 7, return 3. 2, 3, and 5 are the only prime numbers less than 7. """ # https://www.geeks...
9692cdddbc9a790e746f592936682fbc79f48536
camohe90/-mision_tic_G1
/s5/1.1_input.py
797
4
4
""" Realizar un codigo que simule una persona que saluda a otra, solicitar que el usuario ingrese su comida favorita y su color favorito. El sistema debe imprimir un unico mensaje saludando como el ejemplo y diciendo algun mensaje referente a la comida y al color""" print("Manejo de información de entrata con pytho...
316a9165f446c83160c82e7a48cdd20c70a0dcf6
isabellapepke/SpotifyMatch
/playlist.py
2,243
3.875
4
import song class Playlist: """Class holds a username and a library of songs. It is equipped with a __str__ method and equality operator oveloads List of class variables: userId = Spotify userId of playlist -- dec in function __init__ songs = List of songs in playlist -- dec ...
0c005a91a1073c441040d91cdc5719afad1514f3
jiawu/ChicagoCrime
/checkpoints/checkpoint1.py
1,491
3.609375
4
crime_file_name = '/Users/jjw036/ChicagoCrime/crimes_2001_to_present_parsed.csv' file_object = open(filename, 'r') #read the file line-by-line data_list = [] for line in file_object: #get rid of \n newspace new_line = line.strip() data_list.append(new_line) #first line is the header, remove that from the data and ...
518b3c35d6494096190774c26fb993009c557daa
yveega/CoffeeGraphics
/Kolya_pyprojects/Turtle_Kolya.py
2,981
3.53125
4
from math import * from random import randint def dekahex2(n): n = round(n) lc = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'] return lc[(n % 256) // 16] + lc[n % 16] def tow(x1, y1, x2, y2): return atan((x2 - x1) / (y2 - y1)) def rgb(red, green, blue): retur...
611f3d889139072582ccc696bbe9a6b7e0779ea0
KseniiaPitel/python_course
/functional programming tasks/stairs.py
424
4.0625
4
import sys stairs_num=sys.argv[1] #stairs_num = input("Enter the number of stairs ") stairs_num = int(stairs_num) hashtags = (stairs_num + 1) - stairs_num spaces = stairs_num - 1 n: int = spaces j: int = 1 hash = "#" sp = " " temp_sp = sp * n temp_hash = hash * j while hashtags <= n and spaces >= j: print(temp_sp...
de7058426abcf7dc18cf1e6c364a43ee86de8697
jteti/jteti2013_PyHomework1
/jteti2013_ExtraPoints_classes.py
770
4.03125
4
# Extra Points # Create a class called Student that has the properties: class Student: # Count variable set to 0 studentCount = 0 def __init__(self, name, age, birthmonth ): # name (holds student name) self.name = name # age (holds student age) self.age = age ...
5919738e2e778fc6acb1317abfeb907d18e325cc
damani-14/supplementary-materials
/Python_Exercises/Chapter03/CH03_12.py
413
4.15625
4
# program to find the sum of the cubes of the first n natural numbers import math def main(): print("") print("This program will find the sum of the cubes") print("of the first n natural numbers given user") print("provided input for n") print("") n = eval(input("Please enter a value for n :...
4db43b3627ce71b65078c3610a3ad71319c4c739
Audarya07/Daily-Flash-Codes
/Week4/Day6/Solutions/Python/prog3.py
183
3.609375
4
for num in range(1,101): sum = 0 for i in range(1,num): if num%i==0: sum+=i if sum==num: continue else: print(num,end=" ") print()
e0617aae5d5029ed63f5788e47e0c6b0122f90ab
leo-gs/machine_learning_tools
/regression.py
757
3.53125
4
import data import numpy as np class LinearRegression(): def __init__(self, dataset): self.dataset = dataset def least_squares(self, predictor, label): if not data.is_numeric(self.dataset.get_attribute_datatype(predictor)) or not data.is_numeric(self.dataset.get_attribute_datatype(label)): raise ValueError...
436fb9a968d82e1e3ac337a403b9bab6462dba54
sanjeevseera/Python-Practice
/Data-Structures/Tuple/P03.py
217
4.375
4
""" Write a Python program to create a tuple with numbers and print one item """ #Create a tuple with numbers tuplex = 5, 10, 15, 20, 25 print(tuplex) #Create a tuple of one item tuplex = 5, print(tuplex)
69b43f932c6e231a1231950a154012470614c3fd
colms/programming-and-algorithms-1
/Assignment/selection_sort.py
1,169
4.25
4
# selection sort import sorted_checker def single_iteration(numbers, iteration_number): """Performs one iteration of the sorting algorithm. Mutates input list and does not return a value. """ pass def multiple_iterations(numbers_original, num_iterations_to_complete): """Performs the specified nu...
ac6a3a8d4a3cf2af2dbba211e8c9f5cc81099645
nicktsao88/python
/nick.py
82
3.734375
4
name=input("who are youname?") print("hello,"+name) print("come to learn python")
927ef6b16dbf85fbc068b1acdbcf2f10a99e1cd7
CNieves121/lps_compsci
/problem_sets/problemset4/problemset4.py
742
3.8125
4
bacteria_population = 1 minutes = 0 while bacteria_population < 5000000: print("After " + str(minutes) + " minutes, there are " + str(bacteria_population) + " bacteria in the sink.") print("No need to disinfect the sink yet.") bacteria_population = bacteria_population * 2 minutes = min...
95a9db8725abf044052c99018e08d2814ce77c7b
eachofwhich/Udacity_CS212
/Unit3/find_tags.py
1,318
4.46875
4
# Unit 3 Hw 3-3 # Implement a function findtags() that extracts all HTML tags from a document. import sys, re def findtags(text): """Return a list of all HTML tags within text.""" pattern_string = r'<\s*\w+(?:\s*\w+\s*="?[\w\.\_]+"?)*\s*>' regex = re.compile(pattern_string) return regex.findall(text) t...
f154f49a57a3d0e738584d37579f3e62bd6ab62f
Arwen0905/Python_Test
/TQC_考題練習/b0529_TQC證照_708.py
1,677
3.6875
4
# 1. 題目說明: # 請開啟PYD708.py檔案,依下列題意進行作答,進行兩詞典合併, # 使輸出值符合題意要求。作答完成請另存新檔為PYA708.py再進行評分。 # 2. 設計說明: # 請撰寫一程式,自行輸入兩個詞典(以輸入鍵值"end"作為輸入結束點, # 詞典中將不包含鍵值"end"),將此兩詞典合併, # 並根據key值字母由小到大排序輸出,如有重複key值, # 後輸入的key值將覆蓋前一key值。 # 3. 輸入輸出: # 輸入說明 # 輸入兩個詞典,直至end結束輸入 # 輸出說明 # 合併兩詞典,並根據key值字母由小到大排序輸出,如有重複key值, # 後輸入的key值將覆蓋前一key值 # 輸入...
08b4aa3c2a81787538fe76b1e626708766946aa0
BryceFuller/quantum-mobile-backend
/qiskit/backends/_basebackend.py
967
3.515625
4
"""This module implements the abstract base class for backend modules. To create add-on backend modules subclass the Backend class in this module. Doing so requires that the required backend interface is implemented. """ from abc import ABC, abstractmethod class BaseBackend(ABC): @abstractmethod def __init__...
b6f5b4fbebda9beb5e03c07b5fc105c473097b70
sofiazk/cs108
/CS108/a07_acumulator.py
928
4.09375
4
# file: a07_accumulator.py # author: Sofia Kurd (sofiak@bu.edu) # description: def sum_of_range(start, stop, skip): '''Calculates and returns the sum of the numbers produced by the range function''' sum = 0 for i in range(start, stop, skip): sum += i print(sum) def replace(s, old_ch, n...
897b235f1f3c187c96ca69fdd83c85fdebf3324f
srisar/python_kavi_class
/functions/types_of_func1.py
321
3.953125
4
# Types of functions # 1. With returnable value # 2. Without returnable value (procedure) # # # 1. With returnable value def add(a, b): return a + b x = add(3, 4) # add(1,2) = x # cant do this! # 2. Without returnable value def sayHello(): print("saying hello!") print("saying goodbye!") sayHello()...
259287c41cbc1cffc832192c9656af1fd8aa2f51
santiago-pan/project-euler
/python/problem7/problem.py
986
4
4
import sys def isDivisor(number, divisor): return number % divisor == 0 def isPrime(number): if number < 2: return False for divisor in range(2, int(number**0.5) + 1): if isDivisor(number, divisor): return False return True def getNextPrimeNumber(currentPrime): curr...
10c21cb2a23665dc89c01b9d32b00d7373fe67d1
Bhuvana11/anu
/set1a.py
111
4.09375
4
# your code goes here num=3 if(num>0): print("positive") elif(num<0): print("negative") else: print("zero")
1d5b77607ecdabfc875486e82d36178fb918a1bd
kiraheta/data-structures-and-algorithms
/data structures/hash_table/python/hashtable.py
1,934
3.703125
4
#!/usr/bin/python """ Hash Table implementation Load Factor = num of items / tablesize """ class HashTable(): def __init__(self): self.size = 11 self.buckets = [None] * self.size self.data = [None] * self.size def put(self, key, data): hashvalue = self.hashfunction(key, ...
d5dee3c68ce06e1f95046d443f68c447be0af944
korynewton/Intro-Python-II
/src/room.py
783
3.59375
4
# Implement a class to hold room information. This should have name and # description attributes. from item import Item class Room: n_to = None s_to = None e_to = None w_to = None def __init__(self, name, description): self.name = name self.description = description self.i...
0b48ce4c0c35d93dc7646e23a032550437d09950
tesladodger/Fibonacci
/fibonacci.py
3,582
4.21875
4
#Fibonacci #Calculates the sequence to the nth iteration or up to a certain number #You can save the results to a '.txt' file with the name you want #André Martins, 2018 import sys import os def ntimes(n, clear) : save_file = 0; try : n = int(n); except ValueError : print('\n\nYou must introduce an integer\n\n...
bd37d7f243c7e67aae25294b3a82abb73074b781
jihyun28/Python
/practice.py
16,865
3.8125
4
# -*- coding: euc-kr -*- ### ڷ ## ڷ print(5) print(-10) print(3.14) print(5+3) print(5*4) print(3*(3+1)) ## ڿ ڷ print('abc') print("a"*9) print(""*5) ## boolean ڷ - / print(5>10) print(True) print(not True) print(not (5>10)) ## animal = "" name = "ź" age = 4 hobby = "å" is_adult = age >= 3 print("츮 " +...
b5ad41bfc82ba6fab780f5a7df6705e5413e4922
yhgao96/Pytorch_SourceCode
/LinearRegression.py
3,134
3.609375
4
#pytorch import torch import torch.nn as nn import numpy as np import matplotlib.pyplot as plt import torch.nn.functional as F #fake data x = torch.unsqueeze(torch.linspace(-1,1,100),dim=1) #将1维数据转化为2维 y=x.pow(2)+0.2*torch.rand(x.size()) # plt.scatter(x,y) # plt.show() class Net(torch.nn.Module): def __init__(s...
c3af5c2691f075c1e54288422256b2ce4be76c13
emailechiu/emailechiu.github.io
/lesson_turtle1/gridbg.py
1,839
3.546875
4
from turtle import * from math import * from canvasvg import * def jump(x,y): pu() goto(x,y) pd() def line(x1,y1,x2,y2): pu() goto(x1,y1) pd() goto(x2,y2) pu() def horizontal_line(y,width): line(-width,y,width,y) def vertical_line(x,height): line(x,-height,x,height) def grid(...
b576800600c567a049dcb02bb6365ccc76288500
nazarov-yuriy/contests
/yrrgpbqr/p0023/__init__.py
2,627
3.859375
4
import unittest from typing import List import heapq class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def __lt__(self, other): return self.val < other.val class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: head ...
0e17599aceeca2dbc51cbce8e49f652d95a670af
vasyanch/edu
/first_my_proframm/MY_TIMER/eight_ex_prime.py
1,143
4.40625
4
''' Функции, которые определяют является ли целое положительное число простым. ''' def prime(y): if not y > 1: print(y, 'not prime') elif y != int(y): print(y, 'not prime') else: x = y // 2 while 1 < x: if y % x == 0: print(y, 'has ...
ba792c0a92f602db95c45856b811fa91e43e5864
shivanikarnwal/Python-Programming-Essentials-Rice-University
/week1/numbers-in-python.py
943
4.15625
4
""" Demonstration of numbers in Python """ # Python has an integer type called int print("int") print("---") print(0) print(1) print(-3) print(70383028364830) print("") # Python has a real number type called float print("float") print("-----") print(0.0) print(7.35) print(-43.2) print("") # ...
f9ff961e377d66913a93e6ee76e2c3cc216d72f8
aenglander/command-line-parsing-in-python
/examples/click.py
724
3.828125
4
import click @click.group() def main(): """This is an "click" example CLI argument parsing.""" pass @main.command() @click.option("--times", default=1, type=click.IntRange(1, 5), help="Number of greetings: 1-5") @click.argument("name") def hello(name, times): """This says hello a particular number of ti...
d1ff27255efc83fa8f9164bf9b2cc8fc899ecf7d
stroud109/challenges
/lowest_unique/lowest_unique.py
4,352
4.34375
4
""" 1. Find the smallest element in an array of unique numbers 2. Find nth smallest element 3. Find smallest element in a nested list (recursion!) 4. Find lowest int that's /not/ in the random, unique array, e.g. 'find next available server' Include tests Determine the run time """ import random import datetime ...
865a35e5a487247883ca4a038b16d27870da4d32
YukiHaix86/TheCryptor
/main.py
1,770
3.796875
4
import os, cryptography from cryptography.fernet import Fernet import encryp import key import sys,time,random import yukiutils #key.write_key() key = key.load_key() #check if key exists print("Checking if Key exists...") #if key.check_key() == True: # print("Key found and checked!") #else: # print...
0dfd75ae60e07a0a6da821da6846ba38096191c4
lkmflam/07-Network-Programming
/09_NetworkingExtended/SocketProgramming/Socket Challenge Lab #2 Server.py
1,249
3.921875
4
# Echo server program import socket HOST = '' # Symbolic name meaning all available interfaces. It will acept whoever is wanting to connect. PORT = 50007 # Arbitrary non-privileged port with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: #Instantiates the socket and sets to "s" fo...
8cdfa40ad61ea0c313c47c059255ba076b98d1c9
wljSky/order-receiving-project
/人物拼接/pingjie.py
2,357
3.578125
4
import random import pygame # 初始化 pygame.init() # 窗口标题 pygame.display.set_caption('一个简单的拼图游戏') # 窗口大小 s = pygame.display.set_mode((1200, 600)) # 绘图地图 imgMap = [ [0, 1, 2], [3, 4, 5], [6, 7, 8] ] # 判断胜利的地图 winMap = [ [0, 1, 2], [3, 4, 5], [6, 7, 8] ] # 游戏的单击事件 def click(x, y, map): if y ...
d2fc896a97cffe927a26fc2825886c15faa9ce76
GitError/python-lib
/Learn/Udemy/generators.py
759
4.53125
5
""" Intro to python generators """ # generators allow us to generate a sequence of values over time # the main difference in syntax is the use of yield statement # -- return one element at the time, no need to store entire list in memory # e.g. range() is a generator # in memory list example def create_cubes(n): ...
9145fed51acac489382229cefef64ee6a88ddda8
brunnuscz/uespi-curso-python
/Exercícios de Matriz/#02.py
743
3.9375
4
matriz = [] lista = [] c = 0 for i in range(3): lista.clear() for j in range(3): num = int(input(f"Digite [{i+1},{j+1}]: ")) while (num in lista): print("Erro ! O valor já existe na MATRIZ\n") num = int(input("Digite: ")) lista.append(num) matriz.append(list...
6f5d9b74a44861dd67e7bd36003461f87dc33b10
CODE-Lab-IASTATE/MDO_course
/04_programming_with_scipy/gradient_free.py
679
3.8125
4
#Tutorials for optimization in python #2D #Gradient free algorithms #Nelder-Mead simplex algorithm #Powell algorithm #Import libraries from scipy import optimize #Objective function def f(x): # The rosenbrock function return .5*(1 - x[0])**2 + (x[1] - x[0]**2)**2 #Run the optimizer #Try powell algorithm as wel...
db23aa426ca05bbe5973386e07f3c86609d59cea
jyn514/Stanford-CS-231
/assignment1/cs231n/classifiers/notes.py
3,825
3.796875
4
def L_i(x, y, W): """ unvectorized version. Compute the multiclass svm loss for a single example (x,y) - x is a column vector representing an image (e.g. 3073 x 1 in CIFAR-10) with an appended bias dimension in the 3073-rd position (i.e. bias trick) - y is an integer giving index of correct class (e.g. betw...
2bdfef6f41c390db1779c63227f73b814386a1b8
sarauwu/summerimmersion
/da.py
1,273
3.71875
4
''' In this project, you will visualize the feelings and language used in a set of Tweets. This starter code loads the appropriate libraries and the Twitter data you'll need! ''' from wordcloud import WordCloud import json from textblob import TextBlob import matplotlib.pyplot as plt #Get the JSON data twee...
50ec5e9bb1f12198613e7dd78b07f40f4bf5ec7d
MikSavenka/python_home_tasks
/1_1.py
221
3.75
4
# Get input arguments (sys.argv) and print them and their sum import sys s = sum(int(i) for i in sys.argv[1:]) args = '' for arg in sys.argv[1:]: args += arg + ", " print("Got {0}. Sum is {1}.".format(args[:-2], s))
4a74c4daefbfad8cfeb973d8cb284e7e82e58356
Adpeen/Some-Random-Stuff-I-created
/Joke App.py
1,379
3.90625
4
from tkinter import * import random joke = "" def Joke(): global joke jokes = list(my_jokes.keys()) joke = random.choice(jokes) entry.delete(0.0, END) output.delete(0.0, END) entry.insert(END, joke) def Answer(): output.delete(0.0, END) try: answer = my_jokes[j...
fcb14f19f6b43e58dd14f0985c5c53493f37f299
froycard/ProjectEuler-33
/solution.py
613
3.546875
4
from fractions import Fraction from itertools import permutations def one_dig_div(x,y): if x[0]==y[0]: a=x[1] else: a=x[0] if x[1]==y[1]: b=y[0] else: b=y[1] return a/b ans=Fraction(1,1) perm = permutations(range(1,10), 2) perm=list(perm) for num in perm: for den in perm: if num == de...
0ad6b04ad246ede1317c2da178c27a8b62ae1893
mjoze/kurs_python
/codewars/recursive_reverse_string.py
909
4.25
4
""" ##Do you know how to write a recursive function? Let's test it! * Definition: Recursive function is a function that calls itself during its execution * Classic factorial counting on Javascript function factorial(n) { return n <= 1 ? 1 : n * factorial(n-1) } Your objective is to complete a recursive function reve...
3bba34e12c30c167f3ad5b7632a3968769ca9882
WazedKhan/Tic_Tac_Toe-Game
/TicTacToe.py
1,878
3.765625
4
board = {'Top-L': ' ', 'Top-M': ' ', 'Top-R': ' ', 'Mid-L': ' ', 'Mid-M': ' ', 'Mid-R': ' ', 'Low-L': ' ', 'Low-M': ' ', 'Low-R': ' '} def winner(board): # Colunm if board['Mid-R'] == board['Top-R'] == board['Low-R'] != ' ': return 'win' elif board['Mid-M'] == board['To...
878e8722a01be94ed9b4fb7e9d5f760660d78355
sgouda0412/Coding-Questions
/algoexpert/easy/remove_duplicates_from_linked_list.py
461
3.75
4
# This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None def removeDuplicatesFromLinkedList(linkedList): currentNode = linkedList while currentNode is not None: checkNode = currentNode.next while checkNode is not None and checkNod...
1e512beedfd930b088265c5187aaa9216f3352c3
CodingDojoDallas/python_oct_2017
/Daryll_Dade/Python_Fundamentals/15List to Dict/List_to_Dict.py
881
3.765625
4
name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar"] favorite_animal = ["horse", "cat", "spider", "giraffe", "ticks", "dolphins", "llamas"] """def make_dict(arr1, arr2): new_dict = {} compare = [len(arr1),len(arr2)] if (max(compare) == compare[0]): keyslist = arr1 else: ...
e0e14f6b9abd89f0ef7549cc6902fce98182d9cd
lhwd521/python
/calc.py
2,632
3.640625
4
#coding=utf-8 import random pom = ">" def start(): print u"""-------------------------------------------- 开始计算游戏吧! -------------------------------------------- """ def newuser(): name = raw_input("请输入您的姓名:".decode('utf-8').encode('gbk') + pom) return name def random_new(num): x = random.randint(0, num) ...
a79289a65b7f23290ca85640436eee09748ec418
JasonOnes/PythonWork
/fibo.py
1,116
4.25
4
""" Write a function that outputs a list of fibbonacci numbers. Input is how many numbers to calculate. >>> fibo(10) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] >>> fibo(20) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]d >>> fibo(30) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] Write a Generator function named 'fib_infinite()' to calculate fibbon...
bcd3d0643493588c032eb4bf9e60e6dbb40c0f35
RamgopalBhadu/Python-with-DS-and-Algo
/Linked list/k_reverse.py
1,202
3.59375
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: class Node: def __init__(self, data): self.data = data self.next = None def kReverse(head, k) : prev = None curr = head temp = None tail = None newHead = None join = None t = 0 while (curr) : t = k ...
f138a6ee857b585d8e8d04ec7b94016d855127e4
assem-ch/owtf
/tests/testing_framework/doubles/files.py
893
3.578125
4
class FileMock(): """ This class simulates a file object, in order to be sure about the content of the file, and speed up the execution of tests, avoiding the access to the filesystem. """ def __init__(self, lines): self.lines = lines self.max = len(lines) - 1 self.ite...
2ea56b21d236cd5a85f17faf0055e5568b95a4a4
Ahtaylor/Rider-Clustering
/clustfunc.py
10,199
3.765625
4
#!/usr/bin/env python3 # adjaceancy.py # Functions to cluster people together based on distance. import numpy as np import numpy.ma as ma def adjaceancy(riderlist): adj = np.empty((len(riderlist), len(riderlist))) for r1 in range(len(riderlist)): for r2 in range(r1 + 1): adj[r1,r2] = str(...
edb41d61c912984941dda7d3e4d0c8df4f147acd
Eduardo-Mendieta-Est/curso_python_basico
/practica4.py
1,053
3.96875
4
# Generadores: ------------------------------- #Estructuras que extraen valores de una función y se almacenan en objetos iterables #que se pueden recorrer. def funcion_tradicional_genera_pares(limite): num = 1 lista_pares = [] while num<limite: lista_pares.append(num*2) num+=1 r...
ee588e5c73703bff04f1d3460c3f2be2303dd11c
isaiahcoe/basic-age-solver-
/Age Solvery.py
193
4.125
4
#THIS IS AMAZING CODE CREATED BY ISAIAH #GITHUB PLEASE DO NOT STEAL THIS AMAZING CODE birth_year = input('what year were you born? ') age = 2021 - int(birth_year) print(f'Your age is: {age}')
985cd4532c12f099f8455fa45c5b1a748bfab945
HelmuthMN/python-studies
/chapter9/reading_files/read_python.py
355
3.734375
4
filename = 'reading_files/learning_python.txt' with open(filename) as file_object: print(file_object.read()) with open(filename) as file_object: for l in file_object: print(l) with open(filename) as file_object: lines = file_object.readlines() pi_string = '' for line in lines: pi_string...
6c0aa3fcf440ba3b1b4570273243cacceb29b54c
safelyafnan/Muhammad-Safely-Afnan_I0320070_M-Wildan-Rusydani_Tugas6
/I0320070_exercise 6.2.py
146
3.8125
4
#input untuk nilai n n = int(input("masukan banyak pengulangan : ")) #melakukan pengulangan i = 1 while 1 <= n: print(1) i = i + 1
1f66c2d6b18ab487899c1ac07bf409c0d1126219
Dushyanttara/Competitive-Programing
/conditional_tests.py
1,624
4.28125
4
#Dushyant Tara(18-06-2020): This program helps you understand conditionals by practice #Exercises #Conditional tests car = 'subaru' print("Is car == 'subaru'? I predict True.") print(car == 'subaru') print("\nIs car == 'audi'? I predict False") print(car == 'audi') fruit = 'pineapple' print("is fruit ==...
ef309613c2cb542557ebe4e8efa7892b9f36ce68
utpalsacheen/Python_programs
/tigera.py
741
3.8125
4
from array import * class TrainRide: def __init__(self): self.station= [1,2,3,4,5] self.seats = [1,2,3,4,5,6,7,8,9] self.reserved = {} def findAvailableSeats(self, start, end): for seat, station in self.reserved.items(): if str(start) == station: self.seats.append(seat) del self.reserved[seat] ...
c13d83d7512d0feeb29da137462e11f7024e0f08
thevivekshukla/learning-python
/basics/myprogram.py
205
3.984375
4
greeting = input("Enter some greeting message: ") print(greeting) a = 2 b = 3 print(a + b) def curr_converter(rate, euros): dollars = rate*euros return dollars print(curr_converter(10, 56))
1dbcca822d3d64f04870f25ba9ba847c568be229
xys234/coding-problems
/algo/dp/text_justification.py
1,751
4.1875
4
""" """ from math import pow def cost(w, page_width): """ calculate the cost of a line of words based on page width :param w: :param page_width: :return: """ char_len = sum([len(i) for i in w]) + len(w) - 1 # character plus the spaces between words if char_len > page_width: ...
3c8fcbbe88fcc2ae8ba0e0c2467bf00c8ea537f7
PranavDev/Searching_Techniques
/Linear_Search.py
561
3.9375
4
# Implementing Linear Search using Python # Date: 01/05/2021 # Author: Pranav H. Deo import numpy as np def Linear_Search(L, element): loc = 999999 for index, ele in enumerate(L): if ele == element: loc = index return loc # Main MyList = np.random.randint(0, 500, 100) print(MyList) ...
e5992fd33a8207f2a4c318e4bb2c94c932ad2ed8
TracyOgutu/Password-Locker
/run2.py
6,619
3.875
4
#!/usr/bin/env python3.6 import random from user import User from credential import Credential def create_user(usern, userpass): new_user = User(usern, userpass) return new_user def save_users(user): user.save_user() def del_user(user): user.delete_user() def login(user, passw): login = Use...
c4dfe7e3a0b3466acacfeed8906939c2a6501a61
nixxby/alien-invasion
/alien_invasion/scoreboard.py
2,283
3.5
4
import pygame.font from pygame.sprite import Group from alien_invasion.ship import Ship class Scoreboard(): """To report live score in a scoreboard""" def __init__(self,setting,screen,stats): """Initialize scoreboard attributes""" self.screen = screen self.setting = setting self.stats = stats...
e32147afac3f1b4c55c38fdf1891c229a7db96a4
Rudrajit12/Lab_Exam
/wordcount.py
284
3.71875
4
import re import string freq = {} file = open('sample.txt','r') text = file.read().lower() pattern = re.findall(r'\b[a-z]{3,15}\b',text) for word in pattern: count = freq.get(word,0) freq[word] = count + 1 freq_list = freq.keys() for words in freq_list: print words, freq[words]
55335e83defaf036add9feffea6258b252fbd534
sakshichavre20/Eulers-Projects
/Python/square.py
527
3.671875
4
sum1=0 sum2 = 0 squares = [] #find squares upto 100 def square(): global squares,sum1 for i in range (1,101): sq=i**2 squares.append(sq) for i in squares: sum1=sum1+i square() #find addition of all numbers upto 100 def results(): global sum2 for i in range(1,101)...
5c9fc5d42b359a122534991835e3cb04493be230
CleitonSilvaT/URI_Python
/1-Iniciante/2028.py
986
3.90625
4
# -*- coding: utf-8 -*- # Computar elementos da sequencia, em ordem inversa def sequencia(num, seq): if(num == 0): return seq.append(num) seq += num * [num] return sequencia(num - 1, seq) if __name__ == '__main__': # Variavel caso_teste = 1 while(True): # Condicao de parada ...
4606f278cb7c5a94058a78c70fd03795b282190d
Andrey-Strelets/Python_hw
/hw05/dz5_fizzbuzz.py
654
4.28125
4
# Продолжаем идеализировать fizzbuzz, теперь применяем функции и map везде, где можно и нельзя! rint ("Enter first number :") number1 = int(input()) print ("Enter second number :") number2 = int(input()) print ("Enter third number :") # number3 = int(input()) number3 = [5, 18, 9] def fizzbuzz(num): for num in ran...
4bb152b990e86c9032072f399e94817fa140cf83
Littlemansmg/pyClass
/Week 2 Assn/Project 4/4-2.py
343
4.1875
4
# created by Scott "LittlemanSMG" Goes on 11/05/2019 def miles_to_feet(miles): feet = miles * 1520 return int(feet) def main(): miles_input = input("How many miles did you walk?: ") miles_input = float(miles_input) print("You walked {} feet.".format(miles_to_feet(miles_input))) if __name__ == ...
56259f1dc1775d67b219b3856fc3252b107f0f94
ams103/-vningar
/TextAdventure.py
567
3.609375
4
import random, os, sys from time import sleep from typewriter import typewriter typewriter("Welcome to xxx!!!") print() typewriter("What do you wish to be called? ") name = input() typewriter("What race do you wanna be? Type \"raceinfo " "to find out details.") print() races = ["Dwarf", "Elf","Human", "Orc"] typewrite...
4ca70d473207e49a30e34c1c56e1b89aebbf6ec0
Yang1k/tools
/webshell_scan/scan/scan_file/scan/scan/scan.py
589
3.640625
4
import sys import os import re import zipfile # 解压 def unpack(file_path): f = zipfile.ZipFile(file_path,'r') for file in f.namelist(): f.extract(file,"D:\write\scan\\file") unpack("D:\write\scan\scan.zip") #获取所有文件路径 def get_filepath(file_dir): file_path = [] for root,dirs,files ...
ecc4977a1c51aa34d7815723004f7ff10f38c361
ps4417/algorithm
/Codeup/코드업 데이터정렬/1172.py
242
3.8125
4
# 세 수 정렬하기 #세 수를 오름차순으로 정렬하려고 한다. (낮은 숫자 -> 높은 숫자) # 예) # 5 8 2 ====> 2 5 8 로 출력 data = list(map(int,input().split())) data.sort() for i in data: print(i,end=' ')
f05300ba871f04484f4e2e73de1f5af3a2bec045
ufomaeoju/Python-Challenge
/PyBank/main.py
1,118
3.875
4
#The total number of months included in the dataset import os import csv budget_csv = os.path.join("budget_data.csv") #print("Working") file = open(budget_csv) numline = len(file.readlines()) print ("The total number of lines in" , int(numline - 1)) #The net total amount of "Profit/Losses" over the entire per...
36e3b05b756260b74d60b6b7b99407b64991aaab
ASHISH-KUMAR-PANDEY/python
/Economial_Numbers.py
580
3.703125
4
def prime_factors(n): i=0;primes=[] while i*i<n: i+=2 while n%i==0: primes.append(i) n//=i if i==2:i=1 if n>1:primes.append(n) return primes def is_economical(n): ln=len(str(n)) p=prime_factors(n) c=[];e=0 for i in p: if i not...
fa055698f86eb688e098e523d0baa238f64d39a4
HansleeLX/Python
/basic03.py
79
3.6875
4
age=14 if age <= 18: print 'your age is', age else: print 'adult'
2052e4a541996eda732090f0314b2678d4932035
IS2511/spbstu-homework
/python/task-1.2.5.py
673
3.53125
4
# xxx: Today I will generate random numbers # yyy: But LCG is pseudo-random # zzz: It is?! # zzz: I'm re-generating all my SSH keys # if (type(tonumber(arg[1])) ~= "number") or (type(tonumber(arg[2])) ~= "number") then # print("Usage: "..arg[0].." <seed> <count>") # os.exit() # end # C++11 constants are used for...
15a2284eb9be467f2667c5d5172a54d871aefecd
austindavidbrown/austindavidbrown.github.io
/ML_algorithms/multinomial_logistic_regression.py
2,599
3.546875
4
import numpy as np import matplotlib.pyplot as plt class MultRegression(): @staticmethod def softmax(M): exps = np.exp(M) S_exps = (exps @ np.ones(M.shape[1]))[:, np.newaxis] return 1/S_exps * exps @staticmethod def entropy(Y, P): n_samples = P.shape[0] n_classes = P.shape[1] return -1...
c500cdd2eeb633e0edb20c24e99969598e71849d
rkooo567/CS61A_practice
/Link.py
2,094
4.1875
4
# Linked List is either empty or a first value and the rest of the linked list class Link(object): empty = () def __init__(self, first, rest=empty): assert rest is Link.empty or isinstance(rest, Link) self.first = first self.rest = rest def is_empty(self): if self.first == Link.empty: return True else...
8362e4bfe7f9feabfbb771714aee76d9e468e0c9
elena314/yandex-algos-training
/hw8/e.py
1,836
3.859375
4
# https://contest.yandex.ru/contest/28069/problems/E/ class BSTNode: def __init__(self, key=None): self.key = key self.left = None self.right = None def insert_recursive(self, key): if self.key is None: self.key = key return self if key == self....
f77d7545e824baec6286ff2ea8113fd36a1dc59c
Nekotopec/code-challenge-answer
/task2/src/validators.py
1,346
4.0625
4
import datetime import re class DateValidator(): """ Class for input parametrs validation.""" def date_validation(self, month, year): # Validate month. if not month.isdigit(): print('Input the month using digits.') return False elif int(month) > 12 or int(month...
f4c31de36b051ab903dce04064f41d4a5c2df700
salamf/Ferry-Avg-Monthly-Delay-Calculator
/src/cipher.py
1,865
3.6875
4
#!/usr/bin/env python3 class DecryptException(Exception): pass def decode_line(alphabet, line, key): """ Decrypts an encrypted string, and returns the result """ res = "" for index, letter in enumerate(line): line_char_val = alphabet.index(letter) key_char_val = alphabet.index(key[i...
d9b41c1df8a34978cea5ee03a5d218d0428bb526
sumanblack666/datacamp-python-data-science-track
/Manipulating DataFrames with pandas/Chapter 4 - Grouping data.py
5,744
4.15625
4
#Chapter 4 - Grouping data #Grouping by multiple columns # Group titanic by 'pclass' by_class = titanic.groupby('pclass') # Aggregate 'survived' column of by_class by count count_by_class = by_class['survived'].count() # Print count_by_class print(count_by_class) # Group titanic by 'embarked' and 'pclass' by_mul...
981c9b798a254e3286cb04c6dd6e50e00b7f9367
Charmi15/dailypractice
/rev.py
149
4.0625
4
first_name = input("Please enter your first name") last_name = input("Please enter your last name") print(last_name[::-1] + " " + first_name[::-1])
9d308dc9942c46cfb67d75c5c4e03fb3c650a55e
adityasunny1189/100DaysOfPython
/DSA/Sorting/merge_subarray.py
574
3.8125
4
def merge(arr, low, mid, high): left = arr[low: mid+1] right = arr[mid+1: high+1] i = 0 j = 0 k = low while i < len(left) and j < len(right): if left[i] < right[j]: arr[k] = left[i] i += 1 k += 1 else: arr[k] = right[j] ...
9e49af14a36527aa2a6262fdd39f1954dd947ecd
waltercoan/ALPCBES2017
/maiormenorpessoa.py
904
4.03125
4
#http://www.pythontutor.com/visualize.html#mode=edit altura = 0 pessoa=0 sexo = '' omaior=0 omenor=0 somaaltfem=0 contfem=0 contmasc=0 sexodomaior='' while(pessoa < 10): print("Pessoa > ", pessoa) print("Digite sua altura") altura = float(input()) print("Digite o sexo (M/F)") sexo = input() if ...
8adb675c4dfebb33a371c3579d838e4fa5b97881
flovera1/CrackingTheCodeInterview
/Python/Chapter4TreesAndGraphs/dijkstra.py
881
3.65625
4
import heapq def calculate_distances(valGraph, valStarting_vertex): distances = {vertex:float('infinity') for vertex in valGraph} distances[valStarting_vertex] = 0 entry_lookup = {} pq = [] for vertex, distance in distances.items(): entry = [distance, vertex] entry_lookup[vertex] ...
53324f7cc8d9fa2681ae21f7853289ab0dbc6c95
SIDORESMO/crAssphage
/bin/tree_collapser.py
1,173
3.53125
4
""" Tree collapser. Collapse nodes in a phylogenetic tree. (c) 2018 Alessandro Rossi """ import os import sys import argparse from ete3 import Tree def collapse_nodes(inputfile, threshold, output_name): """ Collapse nodes less than threshold :param inputfile: The tree file :param threshold: The thr...
843e82e118041526099395e85faa8b0f66ab3a84
zuodanlee/snake
/entities.py
2,433
3.625
4
from math import floor import random from main import * def round_to_multiple(num, base): return base * floor(num/base) class Snake(): def __init__(self, x, y): self.x = x self.y = y self.direction = "R" self.true_direction = "R" self.body = [(x, y, block_size, block_s...
5128b6d75cee6db905df53aee7d5a4ebea393329
ks2019575001/python
/2.py
238
3.859375
4
abc = input("문자열 : ") print("개별 문자 출력 :", end="") for i in range(len(abc)): print(abc[i], end="") print() print("역순 개별 문자 출력 :", end="") for i in range(len(abc)-1,-1,-1): print(abc[i], end="")
38808cc4b7daade88fb3021951d8a1b801337473
mkruzil/extract
/extract.py
1,063
3.765625
4
''' =========================================================================== Filename: extract.py Description: Extracts tablular data from ASCII text copied off a web page Author: Michael Kruzil (mkruzil@mikruweb.com) Date Created: 7/21/2019 3:00 PM =================...
855b17bfdfe1cff30ed4201c0b4a1f8617b2b437
danitaanubhuti/PYTHON
/input-1.py
224
4.375
4
#TO INPUT A STRING AND DISPLAY IT str=input("enter a sting") print("the sring entered is: ",str) m=int(input("enter an integer")) x=float(input("enetr a fractional value")) print("entered numbers are:\n n1=\n n2="m,x)
fb909b22063df39393ead3bc5c5d8dad38cb8a7c
jashingden/Python
/Python教材/example/EX07_01.py
550
3.90625
4
#-*-coding:UTF-8 -*- # EX07_01.py # # 例外處理範例 # num1 = 10 num2 = 0 nums = [1,3,5,7,9] try: #除以0,導致例外產生 ZeroDivisionError print(num1/num2) #使用沒有宣告過的變數 NameError print(num1*num3) #索引值超出範圍 IndexError print(nums[100]) except ZeroDivisionError: print('Error發生,除以0') except NameError: ...
fc9bbc7bf8cce8375463a160a69597c6c8c906e1
8563a236e65cede7b14220e65c70ad5718144a3/python3-standard-library-solutions
/Chapter01/0031_re_fullmatch.py
440
3.734375
4
""" Listing 1.31 The fullmatch() method requires that the entire input string match the pattern """ import re def main(): text = "This is some text -- with punctuation" pattern = "is" print("Text :", text) print("Pattern :", pattern) m = re.search(pattern, text) print("Search ...
fe82df835eb46e1dfb3d6341abc5762b8bbd844c
Servsobhagya/assignment
/asig13.py
1,316
4.21875
4
# f=open('new.txt','r') # x=int(input("enter any:")) # fd=f.readlines() # while x: # print(fd[-x]) # x=x-1 # f.close # Write a Python program to count the frequency of words in a file. # count=0 # f=open('new.txt','r') # for line in f: # words=line.split() # count +=len(words) # print(count) #Write a Python progr...
1c96f6ca6044b16ba489615727f971207a638285
chrylzzz/first_py
/day12/5.家具案例.py
1,086
3.8125
4
class Fur(): def __init__(self, name, area): self.name = name self.area = area # def __str__(self): # return f'家具名字:{self.name},家具面积:{self.area}' class Home(): # 这是构造方法,构造的时候传入参数 def __init__(self, address, area): self.area = area self.address = address ...
e6b761942bdd42553a1944fad7f4b92a8d13ef35
Dongzi-dq394/leetcode
/python_solution/0270.py
738
3.703125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def closestValue(self, root: TreeNode, target: float) -> int: # Solution by myself: Recursion + Bina...
b61ab75e388f257570538186c6c66725439f6280
aadharna/Destiny
/OutlierDetectionandRemoval.py
2,902
3.75
4
import pandas as pd import numpy as np def normalize(df): result = df.copy() for feature_name in df.columns: max_value = df[feature_name].max() min_value = df[feature_name].min() result[feature_name] = (df[feature_name] - min_value) / (max_value - min_value) return result ...
de587de82722e858d758acf660ecd831e84be71d
MaciejKaca/Python
/List.py
326
4.09375
4
def filter_list(list): new_list=[] for element in list: if type(element) is int: new_list.insert(len(new_list), element) return new_list def filter_list1(list): #using list comprehensions return [element for element in list if type(element) is int] print(filter_list1([12, "A", 3, ...