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
b8b739b6111340efeec7bccddb85655cf7db865f
Guillermoddb/Automate-the-boring-stuff
/Random quiz.py
1,532
3.734375
4
import random from pathlib import Path capitals = {'Spain': 'Madrid', 'Portugal':'Lisbon', 'Italy':'Rome', 'France':'Paris', 'UK':'London'} path_cwd = Path.cwd() #we generate a text file for each element in the list '''for i , j in enumerate(capitals): print(i) a = 'test%s.txt'%(i) f = path_cwd / a ...
6fea9cb7658163ab3b70cb174d5d78575a8fbc98
CarolGonz/daily_coding
/camel_case.py
1,029
4.3125
4
# Complete the method/function so that it converts dash/underscore delimited words into camel casing. # The first word within the output should be capitalized only # if the original word was capitalized (known as Upper Camel Case, also often referred to as Pascal case). import re def to_camel_case(text): #cria um...
ca144fc684403e4c4408ec8041d087dcd0215725
g-alex-dobre/snake-game
/snake.py
1,361
3.734375
4
from turtle import Turtle class Snake(): def __init__(self): self.segments = [] self.starting_position = [(0,0),(-20,0),(-40,0)] for position in self.starting_position: new_segment= Turtle("square") new_segment.color("white") new_segment.penup() new_segment.goto(position) ...
41057b232243f23055a4dc96762d5517ad6fab27
ApoorvaJu08/GFG_problems
/Array/rotate_k.py
1,291
3.828125
4
# Given an array arr[] of positive integers of size N. Reverse every sub-array of K group elements. # Input: # The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of two lines of input. The first line of each test case consists of an i...
0c88b0ec95f661192db3dc4cf75b3d9bd7e4089a
webuildorg/events
/events/spellchecker.py
788
3.5
4
# Adapted from https://www.norvig.com/spell-correct.html import inflect p = inflect.engine() def edits1(word): """All edits that are one edit away from `word`.""" """enterpreneur, entreprenuers will fix to entrepreneur""" end_letters = 's' splits = ((word[:i], word[i:]) for i in range(1, len(word) - 1...
a02414f3b6fc8c45f365de676168935d1c13efa1
shivani171994/python-practice
/Less than.py
297
3.96875
4
# Ask the user for a number and return a list that contains only elements from the original list a that are smaller than that number given by the user in one line. num = int(input('Enter a number : ')) a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] print ([i for i in a if i<num])
5d5d227ac75a215138241449f8cc56fb4b4a1259
Kamar-Folarin/python-classes
/TypicalBanking.py
3,450
3.6875
4
import random import datetime database = {} #dictionary balance = 0 dt = datetime.datetime.now() dt_string = dt.strftime("Date: %d/%m/%Y time: %H:%M:%S") def init(): print(dt_string) print("Welcome to BankAVIA") holdAnAccount = int(input("Do you have account with us: 1 (yes) 2 (no) \n"...
aafc08f19ab42d5f6ca102407c3ebbc3a8fde67d
saikirankondapalli03/HW-05-01
/new/TestTriangle.py
1,353
4.125
4
from Triangle import classify_triangle import unittest class TestCases(unittest.TestCase): """This is a testing class for the classify_triangles method""" def test_equilateral_triangle(self): assert classify_triangle(1, 1, 1) == 'Equilateral triangle' assert classify_triangle(100, 100, 100) == ...
cfa958b79e3d6c3c49356f8d66393d1796c40334
sarathishan/Employee-Chrun---ANN
/Final model/After Testing-model.py
2,147
3.875
4
# Artificial Neural Network # Part 1 - Data Preprocessing #1 Importing the libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #2 Importing the dataset HR_dataset = pd.read_excel("Vee_original_data_v4.xlsx") from sklearn.preprocessing import LabelEncoder, OneHotEncoder labele...
799493c64a266772cee5cc5312ede483748e2545
ashcolecarr/Euler-in-Python
/Problems 1-50/problem029.py
336
3.609375
4
# Project Euler Problem 29 import time startTime = time.clock() MAX = 100 distinctPowers = set([a ** b for a in range(2, MAX + 1) for b in range(2, MAX + 1)]) print("The number of distinct terms generated by a ^ b is {0}.".format(len(distinctPowers))) print("Program execution took {0} seconds.".format(time.clock(...
b5ac25cbe00df82f793bcbcaf599b6aa9d76984f
ashcolecarr/Euler-in-Python
/Problems 1-50/problem041.py
1,037
3.765625
4
# Project Euler Problem 41 import time from math import sqrt startTime = time.clock() # Pandigital numbers are divisible by 3 except for 1234 pandigital and 1234567 pandigital. MAX = 7654321 # The problem already gives this number so it cannot be lower than this. MIN = 2143 def isPandigital(n): number = str(n) ...
e15ba2ba2a953220db92628937e08826a5f0d059
ashcolecarr/Euler-in-Python
/Problems 1-50/problem045.py
874
3.828125
4
# Project Euler Problem 45 import time from math import sqrt startTime = time.clock() # The problem already lists a number, so start here. START = 40755 def getTriangular(): # Start here since the problem already gave a number (n = 285) which satisfies the condition. n = 286 while True: t = (n *...
984ec8c7c3c244095669c2dfbedfdd685bda0739
ashcolecarr/Euler-in-Python
/Problems 1-50/problem015.py
513
3.5
4
# Project Euler Problem 15 import time from math import factorial startTime = time.clock() GRID_LENGTH = 20 # There are n steps in the grid, with n / 2 down and n / 2 right. # So the combination is n! / (n / 2)! / (n / 2)! since it goes only one way. routes = (factorial(GRID_LENGTH + GRID_LENGTH) // factorial(GRID_...
301bbd586687eb40cf5b06116141130c4e8bb83f
ashcolecarr/Euler-in-Python
/Problems 1-50/problem020.py
323
3.5
4
# Project Euler Problem 20 import time from math import factorial startTime = time.clock() NUMBER = 100 digitSum = sum(map(lambda x: int(x), str(factorial(NUMBER)))) print("The sum of the digits of {0}! is {1}.".format(NUMBER, digitSum)) print("Program execution took {0} seconds.".format(time.clock() - startTime...
5e0f82c47764beef6e7438b13ed3fbba99611b11
edson-gonzales/sudoku2015-B
/src/interface/settings_game.py
7,342
3.546875
4
from Tkinter import * import tkFileDialog import os import ttk from read_config_file import ReadConfigFile from save_config_file import SaveConfigFile class SettingsGame(Frame): def __init__(self, parent): """ Main function(constructor) -- create the class attributes, and create the tkinter frame instanc...
b7fb9d3cdb72a210fece6f6928055f6f55e90668
edson-gonzales/sudoku2015-B
/src/interface/Interface.py
2,829
3.828125
4
import sys from Tkinter import * from settings_game import SettingsGame from game_options import GameOptions class Interface(Frame): def __init__(self, main=None): """ Main function, creates a tkinter frame object. this will call to initwindow() function, which will create and invoke a...
87da43b90a31aa74ea14e7752aa69fbf58390ccf
mccloskeybr/pystringevo
/stringevolution.py
1,786
3.703125
4
import string import random target = str(raw_input('enter desired string: ')) strings = [] reward = [] currentGeneration = 0 NUM_PER_GENERATION = 10 MUTATION_RATE = 0.05 def is_done(): return strings[0] == target def sort(): for i in range(len(strings)): biggest = i for j in range(i, len(s...
c6f979b976ebd18476c651b5ab0b31b08b1b8b89
atharvajhawar/ds
/task 1 spark foundation.py
3,688
4
4
#!/usr/bin/env python # coding: utf-8 # # Data Science and Business Analytic # # Name : ATHARVA JHAWAR # # Task 1 : Prediction using Supervised ML # # Objective :- # ### Predict the percentage of an student based on the no. of study hours.</b> # ### Importing all libraries required in this notebook # # In[1]: ...
9467d64a8114c389f05ca2e4ededfcd967d6e5a2
MaxLouis/variables
/Python Basics Math Exercise 2.py
305
4.21875
4
#Max Louis #Python Basics Math: Exercise 2 #14/09/14 int1 = int(input("What is your first integer?")) int2 = int(input("What is your second integer?")) int3 = int(input("What is your third integer?")) multiply = int1 * int2 total = multiply / int3 print("Your Result is: {0}".format(total))
e48341968a27c1fa652c018a5dddc861983022ca
ellisza/Wumpus_World_2.0
/main.py
1,475
3.765625
4
from cave import Cave from room import Room from agent import Agent PRINT_GAME_OUTPUT = True # Change to False if you don't want the textual representation of the game to display NUM_GAMES_TO_PLAY = 1000 # I had my program simulate 1000 games and ouput the statistical results GAMES = [] def run_game():...
c433cdb8afe490d5c9ac66ecfd2c4b8dfe6cf527
arrpitsharrma/Binary-Search-1
/search-sorted-array-unknown-size.py
1,537
3.9375
4
# Time Complexity : O(n), worst case, may be. Not sure, as the array is of unknown size. # Space Complexity : O(1) # Did this code successfully run on Leetcode : yes # Any problem you faced while coding this : No #Approach: #1. We will use binary search. Using two pointers, slow and fast, we try to identify our search...
c292b92e7d84623749c1c4c704cbfa33f0b01017
Roman-Rogers/Wanclouds
/Task - 2.py
522
4.34375
4
names = ['ali Siddiqui', 'hamza Siddiqui', 'hammad ali siDDiqui','ghaffar', 'siddiqui ali', 'Muhammad Siddique ahmed', 'Ahmed Siddiqui'] count = 0 for name in names: # Go through the List lowercase=name.lower() # Lower Case the string so that it can be used easily splitname=lowercase.split() # Split the nam...
4f3fe0aa557680ec073dc58487147a01a814b569
aviv20-meet/meet2018y1lab5
/leap years.py
379
4.03125
4
def main(): year = float(input("What year is it?\n")) leap_year = 4 until_leap = year%4 if(until_leap == 0): year = leap_year print("You are in a leap year") else: leap_year = year-until_leap print("The last leap year was: ",leap_year) main() reset = input("\nAgian? Y...
9f45c02f2ddab9998451eebee8be7779ec9b7694
user178192/Ten-python-projects
/In the News/in_news.py
3,670
3.5625
4
from urllib import urlopen import textwrap import re #reference : Beginning Python: From Novice to Professional - Project 3: In The News # Number of seconds in one day day = 24 * 60 * 60 class NewsAgent: ''' An object that can distribute news items from news sources to news destinations. ...
688e632343b080389a533ad82c802d4ca2b64c43
eric-zhu94/leetcode
/1232. Check If It Is a Straight Line.py
879
3.625
4
https://leetcode.com/problems/check-if-it-is-a-straight-line/ class Solution: def checkStraightLine(self, coordinates: List[List[int]]) -> bool: #y = mx + b if len(coordinates) == 2: return True else: #m = (y1-y0) / (x1-x0) try: m = (coordi...
d3a564a790fd8ddca6e9a4b02c80f0482790732e
eric-zhu94/leetcode
/1290. Convert Binary Number in a Linked List to Integer.py
477
3.53125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getDecimalValue(self, head: ListNode) -> int: bits = [] ans = 0 while head: bits.append(head.val) head = head.ne...
f74ea99df474c0060b30c188fa83e7c6b9f824eb
eric-zhu94/leetcode
/1431. Kids With the Greatest Number of Candies.py
265
3.6875
4
#https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/ class Solution: def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]: hi = max(candies) return [x + extraCandies >= hi for x in candies]
ff2ae3318ec47aefe5035cf1ee4f7ea92bcc3291
Jay168/ECS-project
/swap.py
306
4.125
4
#swapping variables without using temporary variables def swapping(x,y): x=x+y y=x-y x=x-y return x,y a=input("input the first number A:\n") b=input("input the second number B:\n") a,b=swapping(a,b) print "The value of A after swapping is:",a print "The value of B after swapping is:",b
0a40daa3a4daa4e45bdf6d4150bc0e9af25c8946
zedaster/ImaevIntensive
/16/16_4.py
379
3.78125
4
import functools @functools.lru_cache() def F(n): if n < 3: return n + 1 elif n % 2 == 0: return n + 2 * F(n+2) else: return F(n-2) + n - 2 count = 0 for n in range(1, 100): try: val = F(n) print(n, val) if 100 <= val <= 999: count += 1 ...
87e0d04361ea6440e51a2d824d9f352a356bc42f
zedaster/ImaevIntensive
/dosrok-var1/22.py
191
3.625
4
def func(x): L = 0 M = 0 while x > 0: M += 1 if x % 2 != 0: L += 1 x //= 2 return (L, M) n = 0 while func(n) != (5,8): n += 1 print(n)
9000956887f8e14157735b666aa2121fb03b7aa5
zedaster/ImaevIntensive
/25_2/25_10.py
1,724
3.953125
4
import functools @functools.lru_cache() def is_prime(n): if n == 1: return False d = 2 while d * d <= n: if n % d == 0: return False d += 1 return True # Выводит массив из пар различных простых чисел, произведенеие которые даст n @functools.lru_cache() def get_two...
b3741864daa390512a92f7b4edbed0596ffe0cd2
matthaigh27/NMSS-2019
/number-theory/modular-arithmetic/inverse.py
267
3.984375
4
def inverse(x, mod): # den * i = num where 0 <= i < mod # because we take the inverse of x, den is x, and num is one for i in range(mod): if x * i % mod == 1: return i return -1 # if __name__ == '__main__': # print(inverse())
b73c183370fc5e066afffa6524a04f2879d3108c
GayatriDS/RTU-DigitalLibrary
/Python Programs/remkeyfromdict.py
269
3.796875
4
test_dict = {"Arushi" : 22, "Anuradha" : 21, "Mani" : 21, "Haritha" : 21} print ("The dictionary before performing remove is : " + str(test_dict)) del test_dict['Mani'] print ("The dictionary after remove is : " + str(test_dict)) del test_dict['Manjeet']
ed87fab7561269d4e11338e5b23575865b24ee18
digaji/Assignment-Week-6
/Assignment 4/Assignment4.py
2,107
3.921875
4
eren = { "name": "Eren", "homework": [90.0,97.0,75.0,92.0], "quizzes": [88.0,40.0,94.0], "tests": [75.0,90.0] } mikasa = { "name": "Mikasa", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.0, 97.0] } armin = { "name": "Armin", "homework": [0.0, 87.0, 75.0, 22.0], "quizzes...
b4aa45847f756d89a362fc82d1f6c3badea2c383
jadudm/pytbl
/tbl/util.py
406
3.6875
4
RIGHT = 0 LEFT = 1 CENTER = 2 def pad (in_string, limit=20, side=RIGHT): current = len(in_string) + 1 padding = ' ' * (limit - current) half_padding = ' ' * ((limit - current) // 2) padded = in_string if side == RIGHT: padded = padded + padding elif side == LEFT: padded = padding + padded else...
1a3da0ecab33a2bd161f77249c67e9207b9c0170
dvp236/Coding-Challenges-Python
/AnagramCheck.py
759
3.78125
4
print "Start.." def isAnagram(s1,s2): s1 = s1.replace(" ","").lower() s2 = s2.replace(" ","").lower() return sorted(s1) == sorted(s2) def isAnagram2(s1,s2): s1 = s1.replace(" ","").lower() s2 = s2.replace(" ","").lower() if len(s1) != len(s2): return False count = {} for let...
5a033f3eb4f068746d953ea955696f1eabe01d96
dvp236/Coding-Challenges-Python
/Permutation.py
724
3.875
4
'''Swaminarayan!!!''' # get all anagrams of the string # get permutation of String # permuteHelper(r,"",abc) -> permuteHelper(r,a,bc),permuteHelper(r,b,ac),permuteHelper(r,c,ab) # permuteHelper(r,a,bc) -> permuteHelper(r,ab,c), permuteHelper(r,ac,b) # permuteHelper(r,ab,c) -> permuteHelper(r,abc,"")-> base case. # ...
e97059ad61f6cb16969ceb4f7a4da83e9ba74ae0
bre-widner/PetRecommendations
/main.py
1,179
3.828125
4
# # Given height and weight range and max reps to train give dog reccomendation # data from: https://data.world/len/dog-size-intelligence-linked # import pandas as pd from sklearn.tree import DecisionTreeClassifier #read file intelligence_data = pd.read_csv("dog_intelligence.csv") breed_data = pd.read_csv("AKC Breed ...
f10bbe460e2d36d4406bf6c8ba14810aabf1f90f
masonmcbride/mcts
/tictactoe.py
3,141
3.5
4
import numpy as np class TicTacToeMove: def __init__(self, row, col, value): self.row = row self.col = col self.value = value def __repr__(self): return f"row:{self.row} col:{self.col} v:{self.value}" class TicTacToeGameState(): X = 1 O = -1 ...
59ea622c100bfa6b54c6341dcf6b835678f90772
meryll/DailyCoding
/src/20.py
1,401
3.953125
4
''' This problem was asked by Google. Given two singly linked lists that intersect at some point, find the intersecting node. The lists are non-cyclical. For example, given A = 3 -> 7 -> 8 -> 10 and B = 99 -> 1 -> 8 -> 10, return the node with value 8. In this example, assume nodes with the same value are the exact sam...
1da8142a389f6afd16141f13d8f6b6c5f5c98360
Phimc/Pyleaner
/Graph.py
2,193
3.6875
4
#定义一个图中点的类 class Point: def __init__(self,num): # 初始化一个点,需要传入点的号码作为参数 self.num = num self.adjacent = [] def __eq__(self,obj): # 重载 __eq__函数 # 判断两个点是否相等,依据是两个点的号码是否相等 return self.num==obj.num def __str__(self): # 重载 __str__函数 # 可以把一个 Point对象转换为一...
ebba3285d1a3fe2871b55aac182449122acfcc69
ruozhiertong/pythonDemo
/soundDemo/demo/data.py
1,401
3.5625
4
import csv import random import time # 3个属性下的初始值 x_value = 0 total_1 = 1000 total_2 = 1000 # 生成的csv数据的头部标签 fieldnames = ["x_value", "total_1", "total_2"] # 写入文件头部标签, 因文件打开方式是w, 故而会覆盖掉前面的内容从头开始写 with open('data_6.csv', 'w') as csv_file: # 以字典的方式写入文件 csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames)...
e09e237f0c045b65faab5874a9026e1badddbad5
anurag3753/courses
/david_course/Lesson-07-Classes_and_Objects/holding_v2.py
2,470
3.765625
4
""" Using the get, set machinery """ class Holding: def __init__(self, name, date, shares, price): self.name = name self.date = date self.shares = shares self.price = price def cost(self): return self.shares * self.price def sell(self, nshares): self.shares...
922e6fb578173e2823d17db814ceaa7c944d9775
anurag3753/courses
/david_course/Lesson-04/try_except_v1.py
1,090
3.890625
4
"""In this we are going to see the use of try/except block """ import csv filename = "StudentsPerformance.csv" def operate_on_file(filename): """ - Files could have missing values for some columns - Use try/except block to handle such scanerios - We should always use the specific errors ...
1a233003afdf53e979e155a2c8122012183de4c5
anurag3753/courses
/david_course/Lesson-03/file_processing_v2.py
850
4.3125
4
"""In this new version, we have used the with statement, as with stmt automatically takes care of closing the file once we are done with the file. """ filename = "StudentsPerformance.csv" def read_file_at_once(filename): """This function reads the complete file in a single go and put it into a text string ...
b3aa675fa2988d91535f44230b846070414b367e
DanielRosasT/PythonForMgrs
/ThirdWeekCode/Function_FizzBuzz.py
839
4.09375
4
# FizzBuzz Challenge # by Daniel Rosas T # if counter % 3 == 0 and counter % 5 != 0: # print ("Fizz") # elif counter % 5 == 0 and counter % 3 != 0: # print ("Buzz") # elif counter % 3 == 0 and counter % 5 == 0: # print ("FizzBuzz") # # elif counter % 3 != 0 and counter % 5 != ...
17d2ea81d61115a016776aec34fbab3106fbf122
DanielRosasT/PythonForMgrs
/SecondWeekCode/FizzBuzz.py
363
3.796875
4
# FizzBuzz Challenge # by Daniel Rosas T for counter in range (1,101): if counter % 3 == 0 and counter % 5 != 0: print ("Fizz") elif counter % 5 == 0 and counter % 3 != 0: print ("Buzz") elif counter % 3 == 0 and counter % 5 == 0: print ("FizzBuzz") # elif counter % 3 != 0 and ...
13bfa44ff2f215e1552a59633897be0a25e71e83
DanielRosasT/PythonForMgrs
/ThirdWeekCode/Functions.py
576
3.921875
4
# functions # address = ["3022 Broadway, New York, NY 10027, USA", "47 W 13th St, New York, NY 10011, USA", "70 Washington Square South, New York, NY 10012, United States", "777 Brockton Avenue, Abington, MA 2351, USA", "70 Pleasant Valley Street, Methuen, MA 1844, USA"] ...
d06049022b648f284b233afa7096826091e23052
pankajiitg/EE524
/Assignment1/Sanjeev kumar 204102309/7.py
386
3.546875
4
import numpy as np arr = input('enter 15 numbers separated by space:') a=list(map(int, arr.split())) arr = np.asarray(a) n = len(arr) b=arr t=[] for x in np.arange(n - 1): for y in np.arange(n - x - 1): if b[y] > b[y + 1]: b[y], b[y + 1] = b[y + 1], b[y] print('sorted list:',b) for x...
57855bbd38a3eab7930a43cb9fac875a20efa2ac
pankajiitg/EE524
/Assignment1/KManivas_204102304/Q14.py
1,382
3.78125
4
# Program to scatter points within an ellipse import numpy as np import matplotlib.pyplot as plt import math # a & b values of ellipse where a=len of Major axis/2 & b=len of Minor axis/2 a, b = 5.0, 2.5 # Centre of Ellipse p, q = 5.0, -5.0 # Creating a set of 100 values of x between 0 and 10 x1 = np.linspace(10,0...
414bf88e07d3f19b3f29f6012eb29398f72a9f5b
pankajiitg/EE524
/Assignment1/Yogesh Dewangan_204102319/Q2.py
219
3.875
4
a,b= input("Please enter number a and b \n").split() print(f" a+b= {int(a)+int(b)}") print(f" a-b= {int(a)-int(b)}") print(f" a*b= {int(a)*int(b)}") print(f" a/b= {int(a)/int(b)}") print(f" a%b= {int(a)%int(b)}")
60ab3330aa3d976a54850f6b673d7075c6a3c0d5
pankajiitg/EE524
/Assignment1/dk/8_print_matrix.py
293
4.0625
4
import numpy as np import random print("enter number of row") m=int(input()) print("enter number of column") n=int(input()) matrix_element=[] i=0 while(i<m*n): matrix_element.append(random.randrange(-2,5)) i=i+1 matrix = np.array(matrix_element).reshape(m, n) print(matrix)
eef9c9cc10ec1a976afecd13ec1400852a1bb94a
pankajiitg/EE524
/Assignment1/204102311_SatyakiGhosh/(3)_factorial.py
198
4.1875
4
def fact(n): #recursive funtion to find factorial of a number if n==1: return 1 return n*fact(n-1) print('Enter the number:') a=int(input()) print(f'Factorial of {a} = {fact(a)}')
266001198aa2f1309b3443e868324f19647404e9
pankajiitg/EE524
/Assignment1/dk/2.Agebric_operation.py
332
3.84375
4
print("enter two number a and b") a=int(input()) b=int(input()) # summation c=a+b print(a,"+",b,"=",c) #substraction d=a-b print(a,"-",b,"=",d) #multiplication e=a*b print(a,"*",b,"=",e) #division if b!=0: f=a/b print(a, "/", b, "=", f) #remainder if b!=0: g = a % b print(a, "%", ...
87d56acc0698f18fb5c82752bf29fc1a4481f1d6
pankajiitg/EE524
/Assignment1/Sanjeev kumar 204102309/3fact.py
91
4.03125
4
a = int(input('number:')) fact = 1 for x in range(1,a+1): fact = fact*x print(fact)
5e47597b9e62c93354ce2dd36c22e0f6c1d110ed
pankajiitg/EE524
/Assignment1/dk/4.prime_number.py
331
4
4
print("enter the interval of number") a=int(input()) b=int(input()) count=0 for i in range(a,b+1): if i>1: for j in range(2,i): if i%j==0: break else: print(i,end=",") count=count+1 print("between",a,"and",b,"total",count,"prime numbe...
ca9f27843c8dd606097931adad722688d36d060a
pankajiitg/EE524
/Assignment1/KManivas_204102304/Q09.py
676
4.40625
4
## Program to multiply two matrices import numpy as np print("Enter the values of m, n & p for the matrices M1(mxn) and M2(nxp) and click enter after entering each element:") m = int(input()) n = int(input()) p = int(input()) M1 = np.random.randint(1,5,(m,n)) M2 = np.random.randint(1,5,(n,p)) M = np.zeros((m,p),dtyp...
36174d72bd2183978993f6aec9f48f8dc4d69d64
pankajiitg/EE524
/Assignment1/204102310 Satya Prakash Singh/Q6.py
745
3.953125
4
def createList(): List = [] print('Enter element no.:') for i in range(1, 16): print(i,'.',end = ' ') elem = int(input()) List.append(elem) return List def BubbleSort(arr): n = len(arr) for i in range(n-1): for j in range(n-i-1): if arr[j] > arr[j+1]:...
181cdf23e2d00695a5b9904c40b36fd4191691ff
pankajiitg/EE524
/untitled7.py
736
3.546875
4
#Q12 import cmath class complex_: def __init__(self,z1,z2): self.z1=z1 self.z2=z2 def add(self): return self.z1+self.z2 def sub(self): return self.z1-self.z2 def multi(self): return self.z1*self.z2 def divide(self): return...
50e26426d5913ff0252d1e05fd3d4a26afd04ed1
pankajiitg/EE524
/Assignment1/KManivas_204102304/Q03.py
294
4.46875
4
##Program to print factorial of a given Number def factorial(num): fact = 1 for i in range(1,num+1): fact = fact * i return fact print("Enter a number to calculate factorial:") num1 = int(input()) print("The factorial of ", num1, "is ", factorial(num1))
bf02bc540c0b95e58f81e3c5a90877549a1d3854
pmargani/pmarganiGameLib
/pmarganiGameLib/Shapes/Object2D.py
1,489
3.828125
4
from math import cos, sin, sqrt, pi class Object2D: def __init__(self, name = None, x0 = 0, y0 = 0): self.name = name self.x = x0 self.y = y0 self.vX = 0 self.vY = 0 self.aX = 0 self.aY = 0 self.dt = 0.1 self.theta = 0. def __str__...
653a5e0d8afd8645a72eb422b81b74be2e445e65
ciarabautista/wwcode-python
/Basic Concepts/arithmetic_operations.py
289
3.5
4
#It would be best if you try using the Python shell for the following codes #Addition a = 20 b = 10 sum = a + b print(sum) 20 + 10 #Subtraction 20 - 10 #Multiplication 20 * 10 #Division 20 / 10 #Floor Division 9 // 2 10 // 3 #Exponent 4 ** 2 #Modulo 10 % 3 99 % 33
8fffb23c572946418e7695c366d462f1d4df4e27
andyknaebel/Ethereum
/Straightpy/employee.py
904
3.875
4
# This is a great simple example of a class file. # # The calss statement defines this as the Employee Class. Class names are typically capitalized # the class has 4 elements, the default sef, then first, last and pay # # good example of a propery being defined, email for example returns the email address of the # em...
506931b6e46d5a09c8cdad20dd1d635734ae5538
claudia-hershen/mortgage
/validators/mortgage_validator.py
10,485
3.75
4
""".""" from utility.validator_utility import is_number from utility.validator_utility import number_bigger_than from utility.validator_utility import number_smaller_than from utility.validator_utility import is_negative_number SECRET_KEY = 'any secret string' EXPENSIVE_HOUSE_PRICE = 1000000 MEDIUM_HOUSE_PRICE = 50000...
306b699ab00f8cb1e5688cab5cc90034f6c16c7b
AlvaroBejar/AMLAssignment-new-
/helper_functions.py
5,815
3.75
4
import matplotlib.pyplot as plt import numpy as np import itertools from sklearn.model_selection import learning_curve import pandas as pd import constants import pickle # Plots learning curve for model def plot_learning_curve(estimator, title, X, y, ylim=None, cv=None, n_jobs=None, train_sizes...
0019327835d2b23b367b64aafdf072c22354a021
CourtneyBritney/myCrashCourse-Python
/Chapter10/pg262.py
500
4.0625
4
#10-1 filename = 'learning_python.txt' with open (filename) as file_object: lines = file_object.read() print(lines) with open (filename) as file_object: for line in file_object: print(line) filename = 'learning_python.txt' with open(filename) as file_object: lines = file_object.readlines() for line in lines: ...
fb8f699ec7c16462d23e6d2cafa45c763f19ccea
CourtneyBritney/myCrashCourse-Python
/Chapter10/file_reader.py
527
3.921875
4
with open ('info.txt') as file_object: contents = file_object.read() print(contents) filename = 'info.txt' with open ('info.txt') as file_object: for line in file_object: print(line) filename = 'info.txt' with open ('info.txt') as file_object: for line in file_object: print(line.rstrip()) filename = 'in...
dd08a2f9f13e0fd6603dbb61116d5a5ed41dcb86
CourtneyBritney/myCrashCourse-Python
/Chapter9/pg234.py
1,430
3.96875
4
#9-4 class Restaurant: def __init__(cafe, restaurant_name, cuisine_type): #initialize attributes to a restaurant cafe.restaurant_name = restaurant_name cafe.cuisine_type = cuisine_type cafe.number_served = 0 cafe.number_served += 1 cafe.number_served cafe.number_served = int(cafe.number_served) d...
2076d1b66af92faf085df640bd5236a461ce6b17
CourtneyBritney/myCrashCourse-Python
/Chapter8/pg193.TIY.py
359
3.609375
4
#8-1 def display_message(): """Display a simple message.""" print("Learnt to write functions, which are named blocks of code that are designed to do one specific job.") display_message() #8-2 def favorite_books(books): '''Display a your favorite_book''' print(f"One of my favorite_books is {books.title()}.") ...
a1e0a66a58a5e0d96ddbd2a07424b9b313912a23
nova-script/Py-Check-IO
/01_Elementary/08.py
1,247
4.46875
4
""" # Remove All Before ## Not all of the elements are important. ## What you need to do here is to remove from the list all of the elements before the given one. ## For the illustration we have a list [1, 2, 3, 4, 5] and we need to remove all elements ## that go before 3 - which is 1 and 2. #...
4549fc31bf18b85ed830a8c41408e7c80245b9f0
halghm4/SoftwareCarpentryWC3
/mundaneMath.py
153
3.734375
4
def sum_even(a, b): count = 0 for i in range(a, b, 1): if(i % 2 == 0): count += i return count print(sum_even(1, 100))
0f882f1f2a162f6fac61d29a40ae0a44b7c6b771
Tarunmadhav/Python1
/GuessingGame.py
419
4.25
4
import random number=random.randint(1,9) chances=0 print("Guess A Number Between 1-9") while chances<5: guess=int(input("Guess A Number 1-9")) if(guess==number): print("Congratulations") break elif(guess<number): print("Guess Higher Number") else: print("Gue...
3c3182c02d122f69bc1aecb800ceb778ccaa6968
sr-murthy/inttools
/arithmetic/combinatorics.py
1,277
4.15625
4
from .digits import generalised_product def factorial(n): return generalised_product(range(1, n + 1)) def multinomial(n, *ks): """ Returns the multinomial coefficient ``(n; k_1, k_2, ... k_m)``, where ``k_1, k_2, ..., k_m`` are non-negative integers such that :: k_1 + k_2 + ... + k_m = ...
705d1fc60dd30ac084f3f54f199faac7e677953d
Yuiyjg09/Introduktion-til-Python-og-SageMath
/examples.py
2,015
3.734375
4
# Comments: dette er en kommentar ''' Multi- line comment ''' # Initialisering af Variable: myNum = 1 myDouble = 2.87 myString = "Hej!" myBool = True # Print til konsolen: print(myString) # Operationer (Numbers): print("5 + 2 = ", 5 + 2) print("5 - 2 = ", 5 - 2) print("5 * 2 = ", 5 * 2) print("5 / 2 = ", 5 / 2) pri...
b460a62be8a528c310b8df4cb5adfc94ea2573ab
nawachte/DataStructures
/huffman.py
5,487
4.0625
4
# #Name: Nicholas Wachter #Student ID: 016170774 #Date (last modified): 5/14/19 # # Lab 11 # Section 12 # Purpose of Lab: encode a text document with a huffman tree import sys class HuffmanNode: def __init__(self, char, freq): self.char = char # stored as an integer - the ASCII character code value ...
c792ac43c9186532606d16867012d4a491ec9b50
mishavetl/hackerrank_sources
/flipbits/main.py
269
3.8125
4
#!/usr/bin/python def flipbits(num): nums = list(bin(num)[2:].zfill(32)) num = ['1' if d == '0' else '0' for d in nums] return int(''.join(num), 2) if __name__ == '__main__': for _ in range(int(raw_input())): print flipbits(int(raw_input()))
4678e63a0071007bb2dd6418bdf3675ceee18f1b
land-boards/RasPi
/RPIO-TINY-3/blinkLEDs-RPIO-TINY-3.py
1,958
3.796875
4
#!/usr/bin/env python '''blinkLEDs.py Code to blink all of the LEDs on the RPIO-TINY-3 card for a Raspberry Pi. This code must be run as Superuser on the Raspberry Pi. ============ Dependencies ============ Need to: * sudo apt-get install python-dev * sudo apt-get install python-pip python2.7-dev * sudo apt-get ...
7805f08c0d94b8e75b7c15a55486f76b5ce214a2
Logar18/IntroProgramming-Labs
/guessing-game.py
524
3.875
4
#Logan Farmer #CMPT 120 #Guessing Game Lab 5 print("Thinking of an animal") while True: guess = input("What animal am I thinking of?: ").lower() if guess == "pig": print("You guessed it!") answer = input("Did you like htis animal (Y/N)").lower() if answer[0] == "y": print("...
34d99891a436b442ff4c8e6c704cd3335cb83baa
heyRahull/Python-
/beginner/RemoveCharactersFromString.py
495
4.09375
4
# Question 4: Given a string and an integer number n, # remove characters from a string starting from zero up to n and return a new string # For example, removeChars("pynative", 4) so output must be tive. # Note: n must be less than the length of the string. str1 =input("Enter a string") num1 = int(input("Ente...
c160971a035acac1d5e39cd31d132e566961a02e
gavieira/playful_python
/guess/solution.py
3,347
3.71875
4
#!/usr/bin/env python3 import argparse import random import re import sys from dire import die # -------------------------------------------------- def get_args(): """get args""" parser = argparse.ArgumentParser( description='Guessing game', formatter_class=argparse.ArgumentDefaultsHelpFormat...
d28cea9e56a427adcbdc335ad21fe76a5afcc7ea
nobin50/Python-Projects
/baby_name_generator/baby_name.py
2,219
3.890625
4
import string import random letter_input_1 = input("Write (v) for vowel, (c) for consonant, & (l) for random") letter_input_2 = input("Write (v) for vowel, (c) for consonant, & (l) for random") letter_input_3 = input("Write (v) for vowel, (c) for consonant, & (l) for random") letter_input_4 = input("Write (v) fo...
b767ae3eb4eecf525b8fccdfe722ac4f1d260c2a
nobin50/Python-Projects
/Coin Toss/coin_flip.py
780
3.8125
4
import random print('I will flip a coin 1000 times.'+'\n' +'Lets see how many times head will come..') print('Enter your guess') guess = input() toss = 0 head = 0 while( toss < 1000 ): if random.randint(0, 1) == 1: head = head + 1 toss = toss+1 if( toss == 100): print('After 1...
21f94b6d02fe87d9414a54b4a2157bce43986f5e
gmrabbi/calculator
/calculator.py
5,022
4
4
from tkinter import * root = Tk() root.wm_title("Calculator") root.wm_maxsize(width=0, height=0) # Display display = Entry(root, font="arial 15 bold", bd=5) display.grid(row=0, column=0, columnspan=3, padx=10, pady=10) # adding data to the display first_value = "" temp = "" D_fst_val = "" second_value = "" symbol =...
120db75cf67bb0111573e039d4aaf275588fea43
Ojooh/SANS-SURVEY-WITH-tkinter
/survey.py
9,774
3.5625
4
import tkinter from tkinter import * #import Question import time #import Image import random #create the questions #bcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc #ssssssssssssssssssssssssssssssssss' question_prompts = [ "1. What is your position within the company?", "2. Does your compa...
720296e31d7849678f886fe0ca73f6552a2d8c6e
xgfone/PythonInAction
/source/examples/chapter2/operator_override.py
1,168
3.875
4
class Person(object): def __init__(self, defaults=None): self.__defaults = defaults or {} def __setattr__(self, name, value): if name != '_Person__defaults': print("set the attribute '%s' to '%s'" % (name, value)) object.__setattr__(self, name, value) def __delattr__(se...
00825bd30a656dfb2e79728a7c5c29fb6040d642
ZakariaHadi/PythonPmn
/Jour2/fonction3.py
228
3.84375
4
a = int(input("please insert the first value :\n")) b = int(input("please insert the second value :\n")) def air(a,b): return a*b def perim(a,b): return 2*(a+b) print("aire => ",air(a,b),"\nperimetre => ",perim(a,b))
e530e70c27d4a4b74720461a13df2f382373e035
sakilahmmad71/handson-python-learning
/Library/libraries.py
3,046
3.5
4
import random from datetime import date students = [] # ? Creating a profile for specific student def createStudentProfile(name, email): id = len(students) + 1 borrowed = [] returned = [] profile = {"id": id, "name": name, "email": email, "borrowed": borrowed, "returned": returned, "c...
1ecb8775dd4972ef98b1759c63d593655306e6e4
nguyenhoangminhkhoi/nguyenhoangminhkhoi.github.io
/a1_Nguyen_Hoang_Minh_Khoi_s3759804_p2.py
5,060
4.40625
4
# RMIT University Vietnam # Course: COSC2429 Introduction to Programming # Semester: 2020C # Assignment: 1 # Author: Nguyen Hoang Minh Khoi (s3759804) # Created date: 06/12/2020 # Last modified date: 13/12/2020 #Problem 2 - Clock drawing and New Year count down import turtle import turtle import random import math imp...
4e39eb65f44e423d9695653291c6c15b95920df2
rocket7/python
/S8_udemy_Sets.py
695
4.1875
4
############### # SETS - UNORDERED AND CONTAINS NO DUPLICATES ############### # MUST BE IMMUTABLE # CAN USE UNION AND INTERSECTION OPERATIONS # CAN BE USED TO CLEAN UP DATA animals = {"dog", "cat", "lion", "elephant", "tiger", "kangaroo"} print(animals) birds = set(["eagle", "falcon", "pigeon", "bluejay", "flaming...
88682a9bfd3563da964e1e285630b39e18acb239
rocket7/python
/S11_udemy_Functions1.py
1,572
3.828125
4
#!/usr/bin/env python def python_food(): print("spam and eggs") #ALL FUNCTIONS RETURN A RESULT - if NOthing Specified it returns NONE print(python_food()) def center_text(*args, sep=' ', end='\n', file=None, flush=False): #PARAMETER text = "" for arg in args: text += str(arg) + sep #text = s...
11eeebd4aea4657ce03cf7ee00631187654dd356
rocket7/python
/JSON_Example1.py
1,405
3.625
4
import json #import request # # Conversion Table # Always converts Key:Value pairs of DICT to STRINGS # https://docs.python.org/3/library/json.html#py-to-json-table # # fix this function, so it adds the given name # and salary pair to salaries_json, and return it def add_employee(json_salaries, name, salary): s...
e9fad0ffd8779dd3488cfb9d355db060022b5323
rocket7/python
/S5_udemy_PythonBasics.py
2,007
4.0625
4
#test hello="Hello" world="World" print(hello + world) myInt = 1 print(myInt) myFloat = 1.1 print(myFloat) myString = 'singleQuoteString' print(myString) myStringDbl = "doubleQuoteString" print(myStringDbl) myStringApos = "Adam's" print(myStringApos) one = 1 two = 2 three = one + two print(three) a, b = 3, 4 pri...
acf2de01e405c3640572c7a2d82aa5ca785bb8dc
lrf2019/numerical_recipies
/assignment2/netversie/some_routines.py
3,726
3.765625
4
import numpy as np """ This program contains routines of which I am not sure we can use a library function for. Thus, I coded them up below I assume very elementary math such as summing (np.sum) and raising to a power (np.pow) can just be used. We also put the romberg integrator we wrote for assignment 1 here sinc...
830e3054acd45a9e0de7e7515e11b8db5c0d3702
longtranthanh19/TranThanhLong-Fundamental_c4e24
/hw ss3/ex2.py
345
3.734375
4
while True: i = int(input("Guess my number (1-100): ")) if i < 10: print("Oopss it's too small. Try again...") elif i < 19: print("You almost there. Try again...") elif i == 19: print("You got the number. Congrat...") break else: print("Oopss it's too large. T...
029b2d0e82fa278c2cabac2c0258eb4cbc5685a9
longtranthanh19/TranThanhLong-Fundamental_c4e24
/hw ss2/ex4bb.py
98
3.5
4
import sys n = int(input("Enter a number: ")) for col in range(n): sys.stdout.write("*") print
5e0ded1a8be6475547909bbe294ae1095ebea0f8
longtranthanh19/TranThanhLong-Fundamental_c4e24
/hw ss1/ex2.py
114
4.09375
4
r = float(input(" What is the radius of circle ? ")) S = r * 3.14 print (" The area of circle is" + " " + str(S))
4dee556c720d23d7d7c66a8b0e9aeadcdb6cc5a8
longtranthanh19/TranThanhLong-Fundamental_c4e24
/hw ss1/turtleex4.py
162
3.8125
4
from turtle import * shape("turtle") speed(0) color("green") for i in range(100): for j in range(4): circle(100) right(10) mainloop()
666ae00413c242b5a2586ee779a97f7cd3573387
matheusmatos221/SASTest
/SASTest_PythonFiles/ex4.py
182
4
4
myList = [1, 5, 5, 5, 5, 1] max = myList[0] indexOfMax = 0 for i in range(1, len(myList)): if myList[i] > max: max = myList[i] indexOfMax = i print(indexOfMax)
f9db007477678fb1112332858924de29bb41ff6d
Kevin-Rau/artificial-intelligence
/Assignment3/Assignment3.py
6,617
3.71875
4
#code inspired from http://www.bogotobogo.com/python/python_Dijkstras_Shortest_Path_Algorithm.php #worked with Ryan & Conner on this homework assignment import sys import time def fileInput(): file_data = open("Assignment3.txt") content = file_data.readlines() diction = {} testGraph = Graph() ...
3f3c4d8c4a7530b182cf618d5020b120600b6561
uwcalgo/sessions
/2/HristoZA/DNA_PROBLEM/DNA.py
2,079
3.53125
4
from collections import Counter def populateMatrix(fileName): #File name as a string .txt included matrixData = open(fileName,"r") matrix = [] for i in matrixData: toAppend = ''.join(i.split()) matrix.append(toAppend) return matrix def getPartialProfile(fileName): ##returns the profile...