blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
a191ca62cce9c523652777f5b8cd9cf813cb08b9
suraj13mj/Python-Practice-Programs
/05. Python 23-01-20 --- I-O Statements/Program6.py
191
4.0625
4
""" Program to Print the pattern 1 :) 2 :) 3 :) 4 :) 5 :) 1 :) 2 :) 3 :) 4 :) 5 :) 1 :) 2 :) 3 :) 4 :) 5 :) """ for i in range(1,4): for j in range(1,6): print(j,":)",end=" ") print()
5fb8a8668dbc03e0c18b3e98ec85662217cdb38b
suraj13mj/Python-Practice-Programs
/13. Python 05-06-20 --- Dictionary/Program3.py
405
4.125
4
#Program to read Student details into Dictionary and append it a List college=[] N=int(input("Enter No of Students:")) for i in range(0,N): stud={} stud["roll"]=int(input("\nEnter Roll No:")) stud["name"]=input("Enter Name:") stud["per"]=float(input("Enter Percentage:")) college.append(stud) for stud in college:...
01d46d24b6c692f85aec4efcba110013b0b0a579
suraj13mj/Python-Practice-Programs
/10. Python 31-01-20 --- Lists/Program5.py
218
4.21875
4
#Program to sort a 2D List lst=[[25,13],[18,2],[19,36],[17,3]] def sortby(element): #sorts based on column 2 return(element[1]) print("Before Sorting:",lst) lst.sort(key=sortby) print("After Sorting:",lst)
608779f592962415e253d3aebcf77ad6a6824cc9
suraj13mj/Python-Practice-Programs
/15. Python 07-02-20 --- Functions/Program2.py
537
3.59375
4
#Demonstrate the use of Optional arguments def carSpecs(model,brand='TATA',fuel='Petrol',pcapacity=4,cost=100000): print("Model Name:",model) print("Car Company:",brand) print("Fuel Type:",fuel) print("Passenger Capacity:",pcapacity) print("Price:",cost,end='\n\n') carSpecs("SUV") # brand, fuel, pcapacity, c...
fa6f62a2dc710bc95d1f382d5e34cac6b943fade
suraj13mj/Python-Practice-Programs
/05. Python 23-01-20 --- I-O Statements/Program1.py
127
4.1875
4
#Program to display Sum of two numbers a=int(input("Enter 1st value:")) b=int(input("Enter 2nd value:")) c=a+b print("Sum:",c)
4a359ceea3192001418bf250a54fa62a2cb7d735
suraj13mj/Python-Practice-Programs
/33. Python 10-03-20 --- Python MySQL/Student.py
427
3.8125
4
class Student: def __init__(self,rollno=0,name="",per=0.0): self.rollno=rollno self.name=name self.per=per def readStudent(self): self.rollno=int(input("Enter Student Rollno:")) self.name=input("Enter Student Name:") self.per=float(input("Enter Percentage:")) def __str__(self): st="Rollno:"+str(self....
40292e8a70a145fed5ec474774337c5e15e46f0b
suraj13mj/Python-Practice-Programs
/08. Python 29-01-20 --- Loops & Patterns/Program4.py
163
4.03125
4
""" Program to display the following pattern 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 """ for i in range(5,0,-1): print(" ") for j in range(i,0,-1): print(j,end=" ")
511d789b19aa1c9850465d989afadc9f3e5738e5
suraj13mj/Python-Practice-Programs
/35. Python 20-03-20 --- Socket Programming/HTTP/HTTP_Response.py
975
3.765625
4
# Program to transmit an HTTP Response from the Server the Browser # HTTP Response includes : Response Header + HTML contents # URL in the Browser : http://localhost:5000 import socket server = socket.socket() server.bind(('',5000)) server.listen(5) counter = 1 while True: print("Waiting for client ",counter," r...
706558592b4863c72ef112dfc3ab98588d5f796b
suraj13mj/Python-Practice-Programs
/32. Python 06-03-20 --- File Handling/Program1.py
1,247
4.34375
4
#Program to demonstrate basic file operations in Python def createFile(filename): fh=open(filename,"w") print("Enter File contents:") print("Enter '#' to exit") while True: line=input() if line=="#": break fh.write(line+"\n") fh.close() def appendData(filename): fh=open(filename,"a") print("Enter ...
ea6905571e01ef6cb8bd53c2fadd73d8745db7ab
suraj13mj/Python-Practice-Programs
/07. Python 27-01-20 --- Loops/Program2.py
413
4.03125
4
#Program to find the Sum of the series using loops # 1^2/1! - 2^2/2! + 3^2/3! - 4^2/4! --------- N^2/N! sg=1 N=int(input("Enter the value of N for the series:")) fact=1 i=1 sum=0 while i<=N: sum=sum+((i*2)/fact)*sg i=i+1 fact=fact*i sg=sg*(-1) for i in range(1,N+1): if i%2==0: print(str(i)+"^2/"+str(i)+"!",en...
13881008c89c583ab7e30c98d3091ef43bdd7243
suraj13mj/Python-Practice-Programs
/36. Python 28-03-20 --- GUI Tkinter/Employee Template.py
4,064
4.1875
4
#Program to demonstrate the use of various GUI components using Tkinter ''' 1. Label 2. Button 3. TextBox 4. TextArea ''' from tkinter import * from tkinter import messagebox class Employee(Tk): def __init__(self): super().__init__() self.geometry("450x700") self.title("Employee Informatio...
30342271877f7edcf5c7b66362c5955599dee4f7
suraj13mj/Python-Practice-Programs
/38. Python 15-04-20 --- NumPy/Program2.py
498
4.125
4
# Program to read a m x n matrix and find the sum of each row and each column import numpy as np print("Enter the order of the Matrix:") r = int(input()) c = int(input()) arr = np.zeros((r,c),dtype=np.int8) print("Enter matrix of order "+str(r)+"x"+str(c)) for i in range(r): for j in range(c): arr[i,j] = int(inp...
f57d5bd19153dfabaceff223e42b9a87c1481175
suraj13mj/Python-Practice-Programs
/37. Python 10-04-20 --- GUI Mini Projects/Student Login MiniProj MySQL/StudentDB.py
1,074
3.53125
4
#Connection to Backend MySQL import pymysql pymysql.install_as_MySQLdb() import MySQLdb db = MySQLdb.connect("localhost","root","","tkinter_student") cur = db.cursor() #Functions to perform CRUD operations in Backend MySQL from Bean_Student import * def insertStudent(stud): sql = "INSERT INTO student VALUE...
5fc703310bdbf944bf71e3636e27eb8f4c045f8b
suraj13mj/Python-Practice-Programs
/35. Python 20-03-20 --- Socket Programming/TCP/TCP_MessageTransfer/Using Class/Client_Class.py
323
3.59375
4
# Client program to demonstrate how to send connection request to Server and message (name) to the Server import socket sock=socket.socket() sock.connect(("localhost",6000)) print("Connected Successfully to the Server") name = input("Enter your Name:") sock.send(name.encode()) print(sock.recv(1024).decode()) sock.cl...
35304417eee7bb2dbccb1d2dfd746a43725fd853
suraj13mj/Python-Practice-Programs
/05. Python 23-01-20 --- I-O Statements/Program4.py
151
4.21875
4
""" Program to Print the pattern 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 """ for i in range(1,5): for j in range(1,6): print(j,end=" ") print()
d19f5a669848c43da0c09eeaadfe2b7880cdd024
suraj13mj/Python-Practice-Programs
/08. Python 29-01-20 --- Loops & Patterns/Program5.py
157
4.15625
4
""" Program to display the following pattern 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 """ for i in range(1,6): print(" ") for j in range(1,i+1): print(i,end=" ")
6db8f79a1209cd06ab9c1ba797b22f1c125d3cd8
Dexton/advent2020
/d6/d6-p2.py
682
3.546875
4
input = open("input", "r") groups = [] group = set() first_in_group = True for line in input: person = set() if line == '\n': groups.append(group) group = {} first_in_group = True continue for char in line.strip(): person.add(char) if first_in_group: gr...
f8cfeef54502bd99e70511418e554f5aed4dc8e0
spud-bud/exercism_python
/bob/bob.py
391
3.921875
4
def hey(speech): speech = speech.rstrip() if speech.isupper() == True: print('Whoa, chill out!') return 'Whoa, chill out!' elif speech.endswith('?') == True: print('Sure.') return 'Sure.' elif speech == '': print('Fine. Be that way!') return 'Fine. Be that...
ad60ac9d8df6f5450ea064db1f167dc46fa42105
Uchimura85/heartbridge
/heartbridge/app.py
4,162
3.78125
4
""" Main application logic. Parses command line arguments, starts the HTTP server and processes JSON data from Shortcuts when ```main()``` is run. """ import argparse, socket from heartbridge import heart, server # Add command-line arguments: parser = argparse.ArgumentParser(description = "Opens a temporary HTTP endp...
cc88f1c06b6491398275065144285e7ab8e033ca
Mhtag/python
/oops/10public_protected_pprivate.py
862
4.125
4
class Employee: holidays = 10 # Creating a class variables. var = 10 _protec = 9 # Protected variables can be used by classes and sub classes. __private = 7 # Private Variables can be used by only this class. def __init__(self, name, salary, role): self.name = name ...
321d68420082cb5e546e5ea67b1f18c9e2363150
Mhtag/python
/oops/self_and_init.py
498
3.96875
4
class Employee: holidays = 10 # Creating a class variable def __init__(self, name, salary, role): self.name = name self.salary = salary self.role = role # Self is the object where this function will run def printdetails(self): return f'Name is {self.name}, salary is...
51fd88a3b00316108198d8cb3e46e600326b547f
CompRD/BroadCRD
/src/python/BroadCRD/util/pushback_wrapper.py
1,502
3.71875
4
class pushback_wrapper(object): """ Wraps an iterator with another iterator that allows elements to be "pushed back" into the queue. from activestate.com http://code.activestate.com/recipes/502304/ >>> p = pushback_wrapper(iter([1, 2, 3, 37])) >>> L = [] >>> for x in p: ... L.appen...
46123aeae3ac317585425ca9dadcc5e30036143e
CompRD/BroadCRD
/src/python/BroadCRD/bias/IntervalsMinusOne.py
1,322
3.78125
4
#!/usr/bin/env python ############################################################################### # SOFTWARE COPYRIGHT NOTICE AGREEMENT # # This software and its documentation are copyright (2011) by the # # Broad Institute. All rights are reserved. This sof...
26f958b4e7d7feddf61a00d3adcafe6994af9487
skruvi/WorldOfGames
/GuessGame.py
598
3.5625
4
import random from Score import score_calc def generate_number(diff): for x in range(10): secret_number = random.randint(1, int(diff)) return secret_number def get_guess_from_user(diff): user_input = input("Guess a number between 1 to %d: " % (int(diff))) return user_input def compare_results(...
23f1ba91c13beff645683fd3928423a885b5b992
halfrice/euler
/app/p006.py
646
3.8125
4
# The sum of the squares of the first ten natural numbers is, # 1^2 + 2^2 + ... + 10^2 = 385 # The square of the sum of the first ten natural numbers is, # (1 + 2 + ... + 10)^2 = 55^2 = 3025 # Hence the difference between the sum of the squares of the first ten natural numbers # and the square of the sum is 3025 − 385...
1236969d33c8c56768f35f63367e8fd54db295ab
BALAVIGNESHDOSTRIX/py-coding-legendary
/Advanced/combin.py
473
4.1875
4
''' Create a function that takes a variable number of arguments, each argument representing the number of items in a group, and returns the number of permutations (combinations) of items that you could get by taking one item from each group. Examples: combinations(2, 3) ➞ 6 combinations(3, 7,...
7b1fde727d84af14554937482efa2b22c57fb830
StRobertCHSCS/fabroa-Jesse-sudo
/Working/LiveHacks/problem 2.py
823
3.890625
4
''' ------------------------------------------------------------------------------- Name: problem 2.py Purpose: Find how many pieces of chicken will each student and Mr.Fabroa get Author: Chan.J Created: date in 03/10/2019 ------------------------------------------------------------------------------ ''' # obtain ...
1cb56093984b49506492e05687a5bc176c8ebd2b
rodrigo-estrela/harvard-cs50
/pset6/hello/hello.py
62
3.765625
4
name = input("What's is your name?\n") print(f"hello, {name}")
5a124c9822c0e36042ff52ce4d691defa94f6cf1
ccxcxd/mobilepricing
/Cell.py
897
3.625
4
import math class Cell( object ): def __init__( self, center, radius ): # 1 == 1 km self.center = center self.xPosition = center[0] self.yPosition = center[1] self.radius = radius def getCenter( self ): return self.center def getXPosition( self ): r...
03cbdc8bcd976af01d16927053117fd8fe08632d
xuzhongpeng/algorithm_execute
/232.用栈实现队列.py
1,191
4.0625
4
# # @lc app=leetcode.cn id=232 lang=python3 # # [232] 用栈实现队列 # # @lc code=start class MyQueue: def __init__(self): """ Initialize your data structure here. """ self.listA = [] def push(self, x: int) -> None: """ Push element x to the back of queue. """ ...
08fe275c737e98bba6da3a07da958e51d5d23a38
xuzhongpeng/algorithm_execute
/148.排序链表.py
1,426
3.765625
4
# # @lc app=leetcode.cn id=148 lang=python3 # # [148] 排序链表 # # @lc code=start # Definition for singly-linked list. from typing import List class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def sortList(self, head: ListNode) -> ListNode: ...
28b9614294334f08fc2b6b0043aa54901883346a
xuzhongpeng/algorithm_execute
/141.环形链表.py
889
3.625
4
# # @lc app=leetcode.cn id=141 lang=python3 # # [141] 环形链表 # # @lc code=start # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next c...
91dae85dd75de4432a3548d3206ecbc9d1d2670e
abhijeetknayak/Daily-Coding-Problem
/problem68.py
1,520
3.53125
4
def find_attacks(a): count = 0 for (i, j) in a: for (l, m) in a: if i != l and j != m: x, y = abs(i - l), abs(j - m) if x == y: # Expect the absolute difference to be equal(Diagonal) count = count + 1 return int(count / 2) # Cou...
e31f4e567a3d1a8c116e9607943db749eb04a43a
abhijeetknayak/Daily-Coding-Problem
/problem70.py
397
3.65625
4
def get_digits(a): digits = 0 while a > 0: digits = digits + a % 10 a = a // 10 return digits def return_perfect_number(a): digits = 10 - get_digits(a) # The digits should sum up to 10 return (a * 10 + digits) print(return_perfect_number(19)) print(return_perfect_number...
da63eb3a03aefed4ce441b7ac52a18f98d5306c9
abhijeetknayak/Daily-Coding-Problem
/problem198.py
983
3.78125
4
def find_max_subset(max_set): graph = {} # Dict to store possible subsets skip = False # For new elements for val in max_set: # Iterating through all elements in super set for key in graph: if val % key == 0 or key % val == 0: # Part of the same 'key' subset g...
f2aed26a8790c0e284ed58082f9e781ae4ccbc45
ChristianMLand/Flask_QA
/flask_app/config/orm.py
14,532
3.75
4
from flask import flash from flask_app.config.mysqlconnection import connectToMySQL from flask_app import db class Schema: ''' A class to that holds methods for basic sql queries. Classes that represent tables in your database should extend this class. Should only ever be extended and not instant...
e50b0d33a455d13f4dc5662d286e540d1eafc7c5
suryapython/if-programs
/demo1.py
175
4
4
no1=int(input("1st num:")) no2=int(input("2st num:")) if no1==10 or no2==10: print("True") else: if no1+no2==10: print("True") else: print("False")
66ff3e74964c25abc83054955fd99dbc000ad05e
jotawarsd/Shaun_PPS-2
/assignments_sem1/assign7.py
1,865
4.09375
4
''' Assignment no. 7 To write a python program that accepts a string from user and performs the following string operations- i. Calculate length of string ii. String reversal iii. Equality check of two strings iv. Palindrome check v. Substring check ''' string = input("Enter string : ") #obtain an input as a str...
7c2acffba62cb6408f085fb2bf233c1ac2714c64
jotawarsd/Shaun_PPS-2
/assignments_sem1/assign6.py
375
4.3125
4
''' Assignment No: 6 To accept a number from user and print digits of number in a reverse order using function. ''' num1 = input("number : ") #get input from user def reverse(s1): n = len(s1) - 1 #establish index of last digit for i in range(n,-1,-1): #printing the number in reverse print(s1[i]...
318b3b505477d748bc154b95bf1a71721a7edfee
angelahe/NLPPython
/S02_sec2_assess.py
1,432
3.78125
4
import PyPDF2 import re # 1. print NLP stands for Natural Language Processing using variables abbr = 'NLP' full_text = 'Natural Language Processing' print(f'{abbr} stands for {full_text}') # 2. create a file in the current working directory called contacts.txt f = open('contacts.txt', 'w+') f.write('First_Name Last_N...
6a32a530aa936c83f2f7853c530948a0a2fded0b
MaximSidorkin/test
/task_2.py
448
4.375
4
''' 2. Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк. ''' seconds = int(input('введите секунду - ')) hours = seconds // 3600 minutes = (seconds // 60) % 60 seconds = seconds % 60 print(f"{hours}:{minutes}:{seconds}")
2aabe62b4e8f5b2136feb587fe70f3ebfbac779d
saramach/ucsd-deeplearning-tf-CSE-41312
/Week3/Problem2.py
1,536
3.71875
4
''' Week 3 - Problem 2 Solution using Keras ''' import numpy as np import matplotlib.pyplot as plt import tensorflow.compat.v1 as tf import keras from keras.models import Sequential from keras.layers import Dense # Disable 2.0 behavior tf.disable_v2_behavior() ### Generate the data ### def generate_data(random_seed,...
0f72caa21fbfa6153eab5f66fc5485af3f243530
saramach/ucsd-deeplearning-tf-CSE-41312
/Week1/problem4.py
188
3.640625
4
''' Assignment1 - Problem 4 ''' import tensorflow as tf x1 = tf.constant([[1,2,3,4],[5,6,7,8],[9,10,11,12]]) print(x1) reshapedx1 = tf.reshape(x1, [6,2], 'reshaped-x1') print(reshapedx1)
7cba8364e5d733867338144068e596354d525038
OisinDavey/Kattis
/ThreePowers.py
825
3.734375
4
# # ~oisín~ Python3 Template # import sys import math import statistics import datetime import collections powers = [] def fill_powers(): powers.append(1) for _ in range(50): powers.append(powers[len(powers)-1] * 3) def main(): fill_powers() while True: n = int(input()) if(n ...
973182a372bff91af39b160d22b5cdf3db5b343f
snailbaron/poof
/prepare.py
5,540
3.71875
4
#!/usr/bin/env python import os import shutil import glob import urllib import zipfile def remove_if_exists(path): """Remove a file or directory if it already exists.""" if os.path.exists(path): shutil.rmtree(path) def create_dir(path): """Create a directory if it does not yet exist. If th...
c545b9ad241c79ae7c1ee94a51ea1d0abf228bf1
hawkeoni/Semeval2020_task11
/process_data_si.py
4,948
3.5625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright (С) ABBYY (BIT Software), 1993 - 2020. All rights reserved. import os import re import argparse from typing import List, Tuple def merge_spans(spans: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """Merge overlapping spans for SI task.""" spans = sorted...
f5dfe43aabb64365e974a2b9649e786670b4cef5
symfony2018/algorithm-and-data-structures
/search/binary_search.py
1,866
4.0625
4
def iterative_binary_search(items, key): # Inputs # items = list of sorted items # key = item we are looking for # Error checking if len(items) == 0: return None # Find the key in the items min_index = 0 max_index = len(items) - 1 middle_index = int((max_index+min_index)/2)...
03bb255c5fd2666e8948882e5ca4f168c95c2cc7
Irvin-Solis/Monte-Carlo-simulation-
/main.py
2,474
3.53125
4
import random import time def rand_hand(sim, hand): for x in range(13): card = random.choice(deck) hand.append(card) if(not sim): deck.remove(card) def card_value(card): num = card[0] value = 0 if('A' == num): value = 4 elif('K' == num): value = 3 elif('Q' == num): value = 2 ...
b97639963d80069a0c86b5eac5b58cae944877fd
guohuacao/Introduction-Interactive-Programming-Python
/week2-Guess-The-Number.py
2,559
4.21875
4
# "Guess the number" mini-project # This code runs under http://www.codeskulptor.org/ with python 2.7 #mini-project description: #Two player game, one person thinks of a secret number, the other peson trys to guess #In this program, it will be user try to guess at input field, program try to decide #"higher", "lower"...
641618e2889e693f9c266dd14af584861b35062c
shishir-kr92/HackerRank
/Algorithm/dynamic_programming/Recurcive/Moser_De_Bruijn_Sequence.py
896
3.796875
4
from math import floor def get_sequence_element(n, debug = False): if n == 0: return 0 if n == 1: return 1 if debug: print(n) if n % 2 == 0: return 4 * get_sequence_element(floor(n/2)) else: return 4 * get_sequence_element(floor(n/2)) + 1 def get_seque...
6cb1992607cca6ea0a820660e39d44d29c3a2fda
shishir-kr92/HackerRank
/Algorithm/dynamic_programming/Recurcive/Golomb_Sequence.py
493
3.796875
4
def find_golomb(n): if n ==1: return 1 return 1 + find_golomb(n - find_golomb(find_golomb(n-1))) def get_golomb_sequence(n): golomb_no_list = [0 for i in range(n+1)] golomb_no_list[1] = 1 for i in range(2, n+1): no = find_golomb(i) golomb_no_list[i] = no return golo...
a44d22dceefd2d7425380518ae353592780212a9
shishir-kr92/HackerRank
/Algorithm/dynamic_programming/Recurcive/SubSet_Problem.py
398
3.5
4
def checkSubSet(arr, n, sum): if sum == 0: return True if n == 0 and sum != 0: return False if(arr[n-1] > sum): checkSubSet(arr, n-1, sum) return checkSubSet(arr, n-1, sum) or checkSubSet(arr, n -1, sum - arr[n-1]) if __name__=="__main__": arr = [2,4,9,1,3,6] sum = ...
e65cd1dc7f4a0db8748557e291fc9fd417d504e7
shishir-kr92/HackerRank
/InterViewPrepKit/WarmUpChallenge/Repeated_String.py
613
3.625
4
def get_count(s, n): a_count = 0 for c in s: if c == 'a': a_count += 1 if (n % len(s)) == 0: a_count *= (n/len(s)) else: a_count = a_count * int(n / len(s)) for i in range(0, (n% len(s))): if s[i] == 'a': a_count += 1 return a_...
9d05f9307558ae84c86fd30cb9e86ee5e4dbbee4
shishir-kr92/HackerRank
/Algorithm/link_list/rotate_linked_list.py
1,234
4.0625
4
class LinkedList: def __init__(self): self.head = None self.tail = None def push(self, data): if self.tail: temp = self.Node(data) self.tail.next = temp self.tail = temp else: self.head = self.tail = self.Node(data) def rota...
c2dc56926064a8157ffc717e340140c64523c01d
shishir-kr92/HackerRank
/Algorithm/String/CamelCase.py
355
3.734375
4
def count_word(word): result = 0 for i in range(len(word)): print(word[i], ord(word[i]), result) if i == 0: result += 1 elif ord(word[i]) >=65 and ord(word[i]) <= 90: result +=1 else: pass #print(result) return result word = ...
ada3a1a92a6223dc8b110c05d35692f393120829
shishir-kr92/HackerRank
/Algorithm/dynamic_programming/Algo/01_KnapSack_Problem.py
2,072
3.890625
4
def getKnapSackItem(K, value, weight, maxCargoWeight): i, j = len(weight), maxCargoWeight knapSack = [] while ( i >= 0) and (j >= 0): if K[i][j] != K[i-1][j]: knapSack.append(weight[i - 1]) j -= weight[i - 1] i -=1 else: i -= 1 return knap...
e725ed708943e6bbfcd9edb3d44f1b685bf50d61
shishir-kr92/HackerRank
/Algorithm/problem_solving/The_Time_In_Word.py
1,632
4.21875
4
time = ["o' clock", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen", "seventeen", ...
4f8a272053727fb90d6310c5dd754c77cd57def7
HuiwonKo/dev
/python/tryhelloworld7.py
813
3.765625
4
#List/Dictionary Comprehension areas = [] for i in range(1,11): areas = areas + [i*i] print("areas:",areas) areas2 = [ i*i for i in range(1,11) if i%2 == 0 ] print("areas2:",areas2) students = ['태연','진우','정현'] for number, name in enumerate(students): print("()번의 이름은 ()입니다.".format(number,name)) studen...
c58fc47a37279b147a6565662054e7e86d003b36
HuiwonKo/dev
/python/Pro_0626_Huiwon_1.py
745
4.0625
4
import random print('GUESS THE NUMBER') print('Hello! What is your name?') name = input() #이름 입력 answer = random.randint(1,21) #답 print('Well,',name,'I am thinking of a number between 1 and 20. Take a guess') count = 0 #몇 번에 맞췄는지 세는 변수 while True: number = int(input()) #i nput으로 받은 값의 type 이 string 이므로 int로 형변...
a98c0c257dc9f921fa02386b918b46ef8d009487
zb14755456464/pythonCookbook
/第四章:迭代器与生成器/4.12 不同集合上元素的迭代.py
864
4.21875
4
# 问题 # 你想在多个对象执行相同的操作,但是这些对象在不同的容器中,你希望代码在不失可读性的情况下避免写重复的循环 #解决方案 """ itertools.chain() 方法可以用来简化这个任务。 它接受一个可迭代对象列表作为输入, 并返回一个迭代器,有效的屏蔽掉在多个容器中迭代细节。 为了演示清楚,考虑下面这个例子 """ from itertools import chain a = [1, 2, 3, 4] b = ['x', 'y', 'z'] for x in chain(a, b): # 都是循环遍历,a,b两个列表,为了避免这样的重复操作,可以使用chain print(x) #讨论 """ ...
feed0a4b5bbb7163c3cd4cce74b7457d3b898a3d
zb14755456464/pythonCookbook
/第四章:迭代器与生成器/4.1 手动遍历迭代器.py
1,066
4.21875
4
# 问题 # 你想遍历一个可迭代对象中的所有元素,但是却不想使用for循环。 # 解决方案 #为了手动的遍历可迭代对象,使用 next() 函数并在代码中捕获 StopIteration 异常。 比如,下面的例子手动读取一个文件中的所有行 items = [1, 2, 3, 4] it = iter(items) def manual_iter(): try: while True: line = next(it) print(line, end='') except StopIteration: # ...
9787f195cb0329bd7dc96ea386cef2fd60deed80
zb14755456464/pythonCookbook
/第六章:数据编码和处理/6.2 读写JSON数据.py
717
3.828125
4
import json data = { 'name' : 'ACME', 'shares' : 100, 'price' : 542.23 } # 一个Python数据结构转换为JSON json_str = json.dumps(data) # json的格式就是一个字符串 # 下面演示如何将一个JSON编码的字符串转换回一个Python数据结构: data = json.loads(json_str) # 这个就会转换成字典 # 如果你要处理的是文件而不是字符串,你可以使用 json.dump() 和 json.load() 来编码和解码JSON数据。例如: # Writing JSON da...
9f1a34117f187244b23a67754f796dbd9d4a3e68
zb14755456464/pythonCookbook
/第七章:函数/7.6 定义匿名或内联函数.py
320
3.5
4
# 问题 # 你想为 sort() 操作创建一个很短的回调函数,但又不想用 def 去写一个单行函数, 而是希望通过某个快捷方式以内联方式来创建这个函数 add = lambda x, y: x + y add(2,3) # 5 # 尽管lambda表达式允许你定义简单函数,但是它的使用是有限制的
512ec2a9d6863e44e6621ce3f6fbbf8a2d3fd8f1
zb14755456464/pythonCookbook
/第一章数据结构与算法/1.10 删除序列相同元素并保持顺序.py
1,434
3.84375
4
# 问题 # 怎样在一个序列上面保持元素顺序的同时消除重复的值? # 解决方案 # 如果序列上的值都是 hashable 类型,那么可以很简单的利用集合或者生成器来解决这个问题 def dedupe(items): seen = set() for item in items: if item not in seen: yield item seen.add(item) ''' 对上面的代码进行解释,因为dedupe加上了yield后变成了一个生成器,通过集合操作过滤重复出现的值,这样就会返回不重复的一个对象, 在通过list(生成器)转换成一个列表 ...
df262b6aea237c3c89d14a0c844e5b87a5efde7e
zb14755456464/pythonCookbook
/第二章:字符串和文本/2.11 删除字符串中不需要的字符.py
876
4.0625
4
# 问题 # 你想去掉文本字符串开头,结尾或者中间不想要的字符,比如空白。 # 解决方案 # strip() 方法能用于删除开始或结尾的字符。 lstrip() 和 rstrip() 分别从左和从右执行删除操作。 # 默认情况下,这些方法会去除空白字符,但是你也可以指定其他字符 s = ' hello world \n' s.strip() # 'hello world' s.lstrip() # 'hello world \n' s.rstrip() # ' hello world' t = '-----hello=====' t.lstrip('-') # 'hello=====' t.strip('-=') # 'h...
713a87fe95522089d92aaca54f480cb726fc43c1
jchinte/turtleStuff
/sierpinski.py
1,384
3.6875
4
__author__ = 'ajtutor' import turtle t = turtle.Turtle() class Sierpinski: def __init__(self, size=400, turtle=t, color1="#000000", color2="#FFFFFF"): self.size = size self.turtle = turtle self.color1 = color1 self.color2 = color2 self.turtle.color(self.color1, self.color2...
022789df12c50e038732f7bbc2b3996f38346cb6
throwaygithub/TheLastCookie
/the-last-cookie-main-game/main_game.py
9,998
3.6875
4
from room import Room from game_info import GameInfo from character import Character import os import sys class Game1: def __init__(self): self.game_state = "splash" game_name = GameInfo("The Last Cookie") game_name.welcome() GameInfo.info() GameInfo.author = "\nJo Baker, ...
27f53c43b1e7012ddef8a6d98706291aae5db418
zzxmona/pythontrain
/小飞/Lesson10/Lesson10.py
1,742
3.5625
4
# Section0 开场 print("-"*30 + "Begin Section 0 开场" + "-"*30) print("这是Python的第十次课程,主要讲数据操作:") print("1.插入新的行或列\n2.行列互换\n3.apply()与applymap()函数\n") print("-"*30 + "End Section 0 开场" + "-"*30) print('\n') import pandas as pd import copy df1 = pd.read_excel(r"/Users/jack/Desktop/Python/Lesson10/Lesson10.xlsx",sheet_name =...
a4916db104c3ef7f56f5b83e5739acc6132d7a9d
zzxmona/pythontrain
/编程第一步/函数.py
985
3.828125
4
def hello(): print("hello") def max(a, b): if a > b: print(a) else: print(b) def a(): return 1 def change(a): print(a) a += 1 print(a) return a print([change(i) for i in range(4)],'zzx') def zzx(name, age): print('name', name) print('age', age) def test(...
9b48c99cb6029bfb6ae43dcb4ff87e28b61aaefc
zzxmona/pythontrain
/小飞/Lesson7/Lesson7.py
2,144
3.703125
4
# Section0 开场 print("-"*30 + "Begin Section 0 开场" + "-"*30) print("这是Python的第七次课程,主要讲数据的选择:") print("1.列选择\n2.行选择\n3.行列同时选择") print("-"*30 + "End Section 0 开场" + "-"*30) print('\n') import pandas as pd # Section1 列选择 df = pd.read_excel(r"/Users/jack/Desktop/Python/Lesson7/Lesson7.xlsx") df.index = ["一","二","三","四","五"...
eb13799265d044f7deda3c43b8dc3777bcceb07a
savithapalanivel/python
/testnum.py
171
3.609375
4
def testnum(x,y): if(x==y) or (x+y==5) or abs(x-y==7): return True else: return False print(testnum(2,3)) print(testnum(5,2)) print(testnum(10,3))
445fb34843796af35d6a7932d08cee06631049fe
fedsp/site2data
/repositories/scrapping_result_repository.py
418
3.515625
4
from dataclasses import dataclass @dataclass class ScrappingResult: '''This class stores a single scrapping result''' website: str phones: list logo: str class ResultRepository(): def __init__(self): self.result_list = [] def add_new_item(self,item_to_be_added:ScrappingResult)->None: ...
b7794a9242c7208fa794536b3b395c2dfac263d3
BhatiaAnuradha/Meme-Generator
/QuoteEngine/IngestorInterface.py
1,106
3.71875
4
"""Abstract class for parsing and extracting data""" from typing import List from abc import ABC, abstractmethod from .QuoteModel import QuoteModel class IngestorInterface(ABC): """IngestorInterface class Methods: can_ingest parse """ allowed_extensions = [] @classmethod def ...
bd4114acc65562e12220d12531cbf26c40f17b41
muratbalcitr/python-Examples
/egzersiz/_armstrong_number.py
351
3.8125
4
sayi = input("sayı giriniz : ") eleman_sayisi = len(str(sayi)) toplam = 0 temp = int(sayi) sayi2 =int(sayi) while temp>0: digit = temp %10 toplam += digit**eleman_sayisi print(digit**eleman_sayisi ," =>", toplam) temp //=10 if(sayi2 == toplam): print(sayi,"amstrong sayı") else: print(sayi...
9ecffa709c9b6008606aa614f6265f0584c58723
muratbalcitr/python-Examples
/kosullular/enbuyukbulma.py
239
3.6875
4
a = int(input("sayı 1 => ")) b = int(input("sayı 2 => ")) c = int(input("sayı 3 => ")) enb =0 liste = [a,b,c] count =0 lent = len(liste) while(count<lent): if(liste[count] > enb): enb = liste[count] count+=1 print(enb)
bdfa4c9791d874e6064f54374b51da3243c2f592
neovasili/serverless-guru-code-challenge
/tests/unit/helper_model_test.py
3,594
3.515625
4
import unittest from src.helper.exception import ( MissingMandatoryInput, NotAllowedInputValue, ) from src.helper.model import ModelHelper class TestModelHelper(unittest.TestCase): def setUp(self): return super().setUp() def test_should_return_default_value_when_get_desired_and_does_not_exis...
b9100bec21608b92b346f8edb0857c62a3ec0461
chadhs/project-euler
/prob0009.py
692
4.0625
4
#!/usr/bin/env python """ find 3 numbers that add up to 1000 that are also a pythagorean triplet iterate through a list of sum sets checking with is_py_trip helper function return the product of a b & c """ def is_py_trip(a, b, c): if a**2 + b**2 == c**2: return True else: return False def ...
e33f71ec867753fa1a5029f0891fad03c9fce52b
sachinsaxena021988/Assignment7
/MovingAvarage.py
599
4.15625
4
#import numpy module import numpy as np #define array to for input value x=np.array([3, 5, 7, 2, 8, 10, 11, 65, 72, 81, 99, 100, 150]) #define k as number of column k=3 #define mean array to add the mean meanarray =[] #define range to loop through numpy array for i in range(len(x)-k+1): #in...
19801fea421a78906fc5cd0de64b9ff864d85983
polora/polora.github.io
/scripts_exercices_1/C6Ex3_moyenne_amélioré.py
1,152
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @author : YF # @date : octobre 2022 ### Correction de l'exercice - Calcul d'une moyenne de 3 notes - version améliorée # déclaration des variables et initiation nb_notes=0 somme=0 moyenne=0 i=1 # demande du nombre de notes while True: try: nb_notes=fl...
fa73aa82a3de503a6a28e302990b1ef02db31d7a
polora/polora.github.io
/scripts_exercices_1/C4Ex2_calculs.py
864
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @author : YF # @date : octobre 2022 ### Correction de l'exercice - programme qui utilise notre module de Maths from ex7_mon_module_math import * # utilisation de la fonction carré nombre = input("Entrer un nombre : ") nombre = float(nombre) print("Le carré de %f e...
1b6c20510ffbb589741130f1caeeee1e173eb79f
polora/polora.github.io
/scripts_exercices_1/C4Ex2_signe.py
353
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @author : YF # @date : octobre 2022 ### Correction de l'exercice - nombre positif, négatif ou nul ? nombre = input("Saisir un nombre : ") nombre = int(nombre) if nombre>0: print("Ce nombre est positif") elif nombre<0: print("Ce nombre est négatif") else: ...
795c7187f012330885499a218e6b07764835ad3f
Veraxvis/PRG105
/5.6/5.4_HW.py
1,302
3.953125
4
def main(): score1 = int(input("Please enter your test score: ")) score2 = int(input("Please enter your test score: ")) score3 = int(input("Please enter your test score: ")) score4 = int(input("Please enter your test score: ")) score5 = int(input("Please enter your test score: ")) stuff = (score...
4fa2954258c033bc635614a03bde2f888e9e360f
Veraxvis/PRG105
/5.2/derp.py
726
4.1875
4
def main(): costs = monthly() print("You spend", '$' + "{:,.2f}".format(costs) + " on your car per month.") per_year = yearly(costs) print("In total you spend", '$' + "{:,.2f}".format(per_year) + " on your car per year.") def monthly(): car_payment = float(input("Please enter your monthly car paym...
6c3370844ca9229f72f64bab2cd688ebd96c2c85
jrdagoat/cse
/Junious Barnes.py
389
3.625
4
#New python File: warmups.py # 12.4.17 # Write a Python function # which accepts the user's # first and last name # with a Space between them. def Name(first_ name,last_name) # 12.5.17 """Write a function called add_py that takes one parameter called"name" and prints out name.py """ def add_py(name): print (...
4df1a34c4be19855b3de290eaf3ecbcaeafcd387
mahieyin-rahmun/cse425csv
/python/main.py
4,124
3.875
4
# import necessary modules import argparse import csv from time import time def search_each_row(output, row, key, value): """ This is a helper function that takes in the current row of the csv file, the current output list and the key and value pair. Then, it matches the key and value pairs against the appropriat...
57ce2eea110caa21bedf0af9e52a7df42c1170f8
eilyi/Week3
/stringsandlists.py
238
3.921875
4
#Strings and Lists s= "This is a long string, oh boy" l= [1, 2, 3, 4] for number in l: print(number) for letter in s: print(letter) #newlinecharacter print("\n") l.append(121) print(1) s.append("France") print(s)
a948f9c603bfe23b45225eefb69e2b37218fe174
Ralph-Wang/LeetCodeSolution
/algorithms/Excel_Sheet_Column_Number/solution.py
503
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class Solution: # @param s, a string # @return an integer def titleToNumber(self, s): ret = 0 for char in s: ret = 26 * ret + ord(char) - 64 return ret s = Solution() assert s.titleToNumber('A') == 1 assert s.titleToNumber...
533a7ee393bc55b920b021a2ceaed3ed4ed8a19f
Ralph-Wang/LeetCodeSolution
/algorithms/LRU_Cache/solution.py
2,599
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class _dlnode(object): """ node of a doubly linked list. """ def __init__(self): self.empty = True self.key = None self.value = None self.prev = None self.next = None class LRUCache(object): def __init__(self, capa...
30e0f1d4b793864d4a611ceea745328714b0330f
Ralph-Wang/LeetCodeSolution
/algorithms/Maximum_Product_of_Word_Lengths/solution.py
686
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import itertools class Solution(object): def ctob(self, c): return 1 << (ord(c)- 97) def stob(self, s): res = 0 for c in s: res |= self.ctob(c) return res def maxProduct(self, words): """ :type words...
512063b2e84a774a4b90a14eb66c4bae74938b1d
ivanhrabcak/advent-of-code-2020
/day 7/main.py
2,140
3.59375
4
# class Node: # def __init__(self, children, color): # self.children = children # self.color = color # def __str__(self): # return str(self.children) + ", " + self.color def find_applying_rules(bag, rules): bag = bag.replace("bags", "").replace("bag", "") applying_rules = ...
2f779dc64f5d85af25347169617d089a608107ec
alex-precosky/AdventOfCode2015
/Day03.py
1,586
3.890625
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 3 22:18:33 2015 @author: Alex """ # ^ north # v south # < east # > west # how many houses receive at least one present? def solve(robo_santa_exists): santa_pos_x = 0 santa_pos_y = 0 roboSantaPosX = 0 roboSantaPosY = 0 inp...
0a318085ea3756b590d7ce32f55f93b42c867410
islanga/python
/Programs/Google-Command-Line/index.py
486
3.65625
4
# from urllib import urllib2 import urllib.request import json url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&" query = input("What do you want to search for ? >> ") query = urllib.parse.urlencode({'q' : query }) response = urllib.request.urlopen(url + query).read().decode('utf8') data ...
7a23e70d9095909a575ebcad73b29b016b8f4da0
miklo88/cs-algorithms
/single_number/single_number.py
1,612
4.125
4
''' Input: a List of integers where every int except one shows up twice Returns: an integer ''' ''' UPER UPER TIME so this function takes in a list of ints. aka a list[1,2,3,4,5,6] of nums where every int shows up twice except one so like list[1,1,2,2,3,4,4,5,5,6,6] so i need to return the int that is only listed once...
1ff038b9c46c44f5049bc7bb7303a71ab1443081
goutamvenkat/UVA_Solutions
/Blocks_UVA101.py
1,651
3.578125
4
class Node(object): def __init__(self, num): self.num = num self.pile = num self.above = None self.below = None def return_to_initial(block): if not block: return return_to_initial(block.above) block.below.above = None block.below = None block.pile = block.num def main(): n = input() blocks = [Node(i)...
748c936dc2ec2381fd310b2cb5a592ed167c43b1
EADMIK/MyGit
/P5.py
495
3.703125
4
''' 사용자로부터 2~9의 숫자 중 하나를 입력받아 해당 숫자의 구구단을 한 줄로 출력하는 프로그램을 작성하시오. 실행 예) 구구단을 출력할 숫자를 입력하세요(2~9): 2 2 4 6 8 10 12 14 16 18 ''' def table(x): result = [] multi = 1 while multi <= 9: y = int(x) * multi result.append(str(y)) multi += 1 print(" ".join(result)) num = input("구구단을 출력할 숫...
3d6ff24544f404410fdcc0da76a1422dc94ae2dd
nik-o-o/tic-tac-toe
/Tic-tac-toe_PROJECT.py
2,896
3.703125
4
import random #GLOBAL board = [' ']*10 available = [str(num) for num in range(10)] players = [0, 'X', 'O'] # player[1] == 'X' and player[-1] == 'O' def display_board(a,b): print("AVAILABLE TIC_TAC_TOE\n" + " MOVES\n\n" + a[7] + '|' + a[8] + '|' + a[9] + ' ' + b[7] + '|' + ...
fce43b52fc65544b51e3b6f3d4ab271b698658f5
agmezr/exercises
/integer.py
361
4.0625
4
def count_words(text): dic = {} for word in text.strip().split(" "): word_length = len(word) if word_length == 0 or word_length == " ": continue if word_length in dic: dic[word_length].append(word) else: dic[word_length] = [word] return dic if __name__ == '__main__': text = "the brown fox jump...
4fc4b0c4d17222acd6e6e7c346d7bfd6a288c419
agmezr/exercises
/vietasformulas.py
924
3.6875
4
""" Note: there is a much more mathematical and efficient way to do this, I DO NOT know maths For roots = [2, -3, 4], the output should be vietasFormulas(roots) = [1, -3, -10, 24]. The polynomial would thus be (x - 2)(x + 3)(x - 4) = x3 - 3x2 - 10x + 24. """ def vietasFormulas(r): r = map(lambda x: x*-1,r) ...
235df1baba7c9ffe9222dfee29da356e2a1762fa
timlax/PythonSnippets
/Create Class v2.py
1,369
4.21875
4
class Animal(object): """All animals""" alive = "" # Define the initialisation function to define the self attributes (mandatory in a class creation) def __init__(self, name, age): # Each animal will have a name and an age self.name = name self.age = age # The description...
8bd24a78cd6c0e4d0ef6eb8ff72b3a0b45c0b2d9
xs-520/shuang_sele
/apiproject/case/test_duanyan_assert.py
834
3.71875
4
import unittest class Test(unittest.TestCase): def test_01(self): a = "hi" b = "hi" self.assertEqual(a, b) # 判断a和b相等 # self.assertNotEqual(a, b) # 不相等 #所有的判断都可以用assertTrue()来进行判断 self.assertTrue(a == b) # 判断a和b相等 self.assertTrue(a != b) # 判断a和b不相等 ...