blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
a47e31222de348822fbde57861341ea68a4fa5fb
Ph0tonic/TP2_IA
/connection.py
927
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class Connection: """ Class connection which allow to link two cities, contains the length of this connection """ def __init__(self, city1, city2, distance): """ Constructor :param city1: City n°1 :param city2: City n°2...
4f87bbe6f76985ef685e27c875d07c606c2c70ee
Sairam-Yeluri/DCA
/Inbuild Functions/Strings/isupper().py
108
3.96875
4
str1 = 'SAIRAM' str2 = 'SAI RAM' str3 = 'sAI RAM' #F print(str1.isupper(),str2.isupper(),str3.isupper())
2a0983a97e80de6a050a0c93b7605268058a6ccc
Sairam-Yeluri/DCA
/Min and Max in list.py
236
3.9375
4
lst = [5,20,-6,-4,1,3] temp1 = lst[0] for i in lst: if i < temp1: temp1 = i temp2 = lst[0] for j in lst: if j > temp2: temp2 = j print("Smallest number is {} and Largest number is {}".format(temp1,temp2))
e32186f4565cac5b1d451a3363503ec9c41b5cd9
Sairam-Yeluri/DCA
/IMP/Armstrong Number.py
158
3.546875
4
n = int(input("Enter Number: ")) #153 , 154 lst = list(str(n)) k = 0 for i in lst: k = k+pow(int(i),3) if k == n: print("Yes") else: print("No")
c9cbf5e1efbad21468e3d78508e7da1151ed122b
reillydj/ProjectEuler
/problem_seven.py
797
3.90625
4
__author__ = "David Reilly" """ Project Euler Problem: 7 'By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number?' """ import math def is_prime(integer): if integer == 2: return True for candidate in xra...
67e085ffc5b6c37dda9edf27a527cb5e79980f96
wawiesel/BootsOnTheGround
/external/TriBITS/common_tools/test/hhmmss_math.py
4,153
3.890625
4
#!/usr/bin/env python # # This simple set of python functions makes it easy to do simple math with # times formatted as <hr>h<min>m<sec>s. This makes it easier to analyze # timing data that is spit out in that form. # import sys import os def hms2s(hms): #print "mmss =", mmss hms_len = len(hms) h_idx = hms.fin...
238fda6498cb428fc796671fa6e34beb6bd9f1a6
wuziwei1994/project_learn
/api/task/Task_007/animalGame.py
1,782
3.625
4
from random import randint import time class Tiger: animalName = '老虎' def __init__(self,weight): self.weight = weight def call(self): print('WOW !!,体重减少5') self.weight -= 5 def eat(self,food): if food == 'meat': self.weight += 10 print('喂食正确,体重增加10...
f8bc0b4541d4569cb5f54b8d6397f343370da5aa
wuziwei1994/project_learn
/api/task/Task_004/mySort.py
175
3.78125
4
def mySort(List): newList=[] for i in range(len(List)): newList.append(min(List)) List.remove(min(List)) return newList print(mySort([1,0,2,5,7]))
052e2989a10ab674395e4a11ecab1e2560109af4
charlenellll/LeetCodeSolution
/61 Rotate List/rotateRight.py
1,148
3.703125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if head ==...
319aeabc01e1be75da2f1ecee9129c360a5414b1
KNTU-Algorithm-Design-Spring-2021/individual-project-3-sadeghi-aa
/Code/main.py
1,105
3.765625
4
def parse(sentence, previous=None): if not previous: sentence = sentence.lower() if sentence is '': return previous else: length = len(sentence) for i in list(range(2, length + 1)) + [1]: nextWord = sentence[0:i] if nextWord in wordSet: ...
c2b6d92e28284d84dfc525b3bf5f9c33596f46ad
LokeshKD/DSPython
/stk/dec_to_num.py
265
3.875
4
from stack import Stack def convert_int_to_bin(dec_num): rem = Stack() bin_num = "" while dec_num > 0: rem.push(dec_num % 2) dec_num //= 2 while not rem.is_empty(): bin_num += str(rem.pop()) return bin_num print(convert_int_to_bin(4))
01898fb8344e604758c78eeda505f7638b7aa911
Rybalchenko4/homework_func
/homework_func.py
2,264
3.5
4
documents = [ {"type": "passport", "number": "2207 876234", "name": "Василий Гупкин"}, {"type": "invoice", "number": "11-2", "name": "Геннадий Покемонов"}, {"type": "insurance", "number": "10006", "name": "Аристарх Павлов"} ] directories = { '1': ['2207 876234', '11-2'], '2': ['10006'], '3': [] } def get_name()...
7c0908716adc48d86db77b8cb630243d5a6c2772
dbirman/cs375
/assignment2/autoencoder_pooled_bottleneck_imagenet.py
12,214
3.671875
4
""" Welcome to the second part of the assignment 1! In this section, we will learn how to analyze our trained model and evaluate its performance on predicting neural data. Mainly, you will first learn how to load your trained model from the database and then how to use tfutils to evaluate your model on neural data usin...
9ea53752081cd9e803b5bf01739a69b1da21b100
Anubhav27/DataWeave_Programming_Test
/dataweave_DataStore.py
1,707
4.03125
4
""" This is Question 1 of the assignment I have created a Key Value Data Store which can perform following operation: Add(key,value) Get(key) delete(key) Solution: Here in the solution i tried to create a DataStore class and where the number of versions for a key is taken from "datastore_configuration" file and ba...
4aa7b57b017eff732c2b6e045ff29db48b0f4b5f
jmhuang1995/Tetris_Ai
/halgo.py
2,184
3.515625
4
def empty_(cell): return cell == 0 def blocked_(cell): return cell != 0 def blocks_amount(board): i = 0 for row in board: for cell in row: if blocked_(cell): i += 1 return i def max_board_height(board): for idx, row in enumerate(board):...
740a5ab1bd4ac800c9857c436760ff6320eeca29
viveshy/python-sandbox
/12-py_json.py
385
3.71875
4
# JSON is commonly used with data APIS. Here how we can parse JSON into a Python dictionary import json # Sample JSON userJSON = '{"first_name": "vivesh", "last_name": "yadav", "age": 21}' # Parse to dict user = json.loads(userJSON) print(user) print(user['first_name']) car = {'brand': 'Tesla', 'model': 'X', 'body...
09dbe3b7a0b697c209e0cc22676dd79d1f7b94dc
SunilPadikarManjunatha/K-Similar-Strings
/ksimilar.py
1,098
3.53125
4
class Solution: def kSimilarity(self, A: str, B: str) -> int: a = list(A) b = list(B) k = 0 queue = [] queue.append(A) result = {A:0} i=0 while queue: string = queue.pop() items = self.get_poss_swaps(list(string),b) ...
5f9f2f322497acb5f6986fa9c87f1a343edf5955
Toan211/CS112_AlgorithmAnalyse
/IP.py
941
3.546875
4
def check(ip): ip = ip.split(".") for i in ip: if(len(i) > 3 or int(i) > 255 or int(i) < 0): return False if(len(i) > 1 and int(i) == 0): return False if(len(i) > 1 and int(i) != 0 and i[0] == '0'): return False return True def convert(ip): si...
99329e63248a8692b819b066bf92392efd3f831a
Toan211/CS112_AlgorithmAnalyse
/goldbachConjecture.py
799
3.75
4
def primess(n): lis = [True] * n for i in range(3,int(n**0.5)+1,2): if lis[i]: lis[i*i::2*i]=[False]*int((n-i*i-1)/(2*i)+1) return [2] + [i for i in range(3,n,2) if lis[i]] def binarySearch (arr, l, r, x): if r >= l: mid = l + (r - l) // 2 if arr[mid] == x: ...
4e7759522af8b94701fc4a9116fea845bb09f4c7
elsandkls/SNHU_IT140_itty_bitties
/grocery_list.py
13,180
3.984375
4
# Grocery List Project # example of a function: def printCategory(category_list): i = int(1) stop = len(category_list) -1 # i. Identify: Item-based for loops while i <= stop: #iii. Identify: Accessing values in a list print(i, str.capitalize(category_list[i])) i= i+1; ...
23e0c28459fd418f5e56ba9ae742bd5b0329447d
elsandkls/SNHU_IT140_itty_bitties
/x10.py
675
4.03125
4
# Get our input from the command line import sys M= int(sys.argv[2]) N= int(sys.argv[3]) # convert strings to integers numbers= sys.argv[1].split(',') for i in range(0, len(numbers)): numbers[i]= int(numbers[i]) # Your code goes here # numbers now contains the list of integers # You should multiply every Nth eleme...
c3a30ed49821b8d9bbce40e9cc70d9b54e3100dc
elsandkls/SNHU_IT140_itty_bitties
/email_regex_example.py
305
3.5
4
# email validation emailList = ['cersei.lannister@got.eu', 'j.a.m.i.eLan@goteu', 'nedstark_got.eu'] emailValidation = re.compile(r'''([a-zA-Z0-9._&=-]+@[a-zA-Z0-9.-]+(\.[a-zA-Z] (2,4)))''', re.VERBOSE) for email in emailList: if re.match(emailValidation, email): print(email, "is valid") else: print(email, "...
92e296b5132802978932b62ddab03030d636785d
elsandkls/SNHU_IT140_itty_bitties
/example_1_list.py
1,593
4.34375
4
# Get our lists from the command line # It's okay if you don't understand this right now import sys list1 = sys.argv[1].split(',') list2 = sys.argv[2].split(',') # # Print the lists. # # Python puts '[]' around the list and seperates the items # by commas. print(list1) print(list2) # # Note that this list has thre...
b16d624f650ddfffc987202f1a51c15a0e98224b
elsandkls/SNHU_IT140_itty_bitties
/experiment.py
406
3.90625
4
# Write experimental code below print ("Your experiemental code") # Get N from the command line import sys N = int(sys.argv[1]) # Your code goes here # We will pass in a value, N. # You should write a program that outputs all values from 0 up to an including N. start = int(0) stop = int(N + 1) print 'Start: ', star...
2bc8716889789123086992553fd8501964bb993d
andressequeda/ejercicio3
/ejercicio3.py
450
4.0625
4
numero1 = int ( input ( "Ingrese el primer número:" )) numero2 = int ( input ( "Ingrese el segundo número:" )) print ( "La suma de los números es:" , numero1 + numero2 ) print ( "La resta de los números es:" , numero1 - numero2 ) print ( "La multiplicacion de los números es:" , numero2 * numero2 ) print ...
cf679751430149abfea0f8f11c6bb2cffaa218bf
aazhbd/numerical
/primesdb/saveprimesinsqlite.py
1,914
3.96875
4
import random import sys import sqlite3 def is_probable_prime(n, k = 7): """use Rabin-Miller algorithm to return True (n is probably prime) or False (n is definitely composite)""" #print "Starting to check whether " + str(n) + " is prime" if n < 6: # assuming n >= 0 in all cases... shortcut small cases he...
c9f45554809231162d7dc7cf5b921ed427ffa944
sacherjj/dailyprogrammer
/20170710_challenge_323_easy_3sum/three_sum_python/three_sum.py
1,873
3.765625
4
import time from random import choice from itertools import combinations def zero_optimal(num_list): """ Quadratic algorithm from https://en.wikipedia.org/wiki/3SUM """ output = set() num_list.sort() length = len(num_list) for i in range(length-2): a = num_list[i] star...
215518cfa49b03d077917126f678839990deccc1
MasudHaider/Think-Python-2e
/chap8.py
1,558
3.9375
4
# fruit = 'banana' # index = 0 # while index < len(fruit): # letter = fruit[index] # print(letter) # index += 1 # def backward_letter(str): # length = len(str)-1 # while length >= 0: # print(str[length]) # length -= 1 # # # def ducklings(): # prefix = 'JKLMNOPQ' # suffix = ...
ceb29241ace6c0a9b6c6b35bea9ec8d931e59402
MasudHaider/Think-Python-2e
/Exer-6-2.py
248
3.6875
4
def ack(m, n): if m < 0 or n < 0: print("Ackermann is not defined for negative integers") elif m == 0: return n+1 elif n == 0: return ack(m-1, 1) else: return ack(m-1, ack(m, n-1)) print(ack(3, 4))
7add89c47bb6e5b3a49504244acc952a91040d31
MasudHaider/Think-Python-2e
/Exer-5-3(1).py
555
4.21875
4
def is_triangle(length1, length2, length3): case1 = length1 + length2 case2 = length1 + length3 case3 = length2 + length3 if length1 > case3 or length2 > case2 or length3 > case1: print("No") elif length1 == case3 or length2 == case2 or length3 == case1: print("Degenerate triangle") ...
cf94aefd27b4487ee51ca035bc8e7a848d905163
MasudHaider/Think-Python-2e
/Exer-9-3.py
671
3.65625
4
def avoids(words, forbw): for letter in forbw: if letter in words: return False return True def permutations_with_repetition(permutable): base = len(permutable) for n in range(base ** base): yield "".join(permutable[n // base ** (base - d - 1) % base] for d in range(base)) ...
5a32c8dce11d4809a1abf94a0373c4fff7bebef3
MasudHaider/Think-Python-2e
/chp6.py
1,408
4
4
import math def area(radius): a = math.pi * radius**2 return a def absolute_value(x): if x < 0: return -x else: return x def compare(x, y): if x > y: return 1 elif x == y: return 0 else: return -1 def distance(x1, y1, x2, y2): dx = x2 - x1 ...
f364bf7ee163bf21f658ab8653dd53da0ea34fb2
MasudHaider/Think-Python-2e
/Exer-7-2.py
263
3.765625
4
import math def eval_loop(): while True: ein = input() if not ein == 'done': eval_result = eval(ein) print(eval_result) else: return eval_result if __name__ == '__main__': print(eval_loop())
1749c9210031638cf34bcf1b8524166a5cd21d6d
MasudHaider/Think-Python-2e
/Exer-10-2.py
213
3.71875
4
def cumsum(seq): new_list = [] for i in range(0, len(seq)): new_list.append(sum(seq[0:i+1])) return new_list if __name__ == '__main__': my_list = [1, 2, 3, 67] print(cumsum(my_list))
b6baad438e3ddeaa39089ce83a2cd2cdf233b6ce
AdityaVashista30/Pet-Classifier-Using-CNN
/Pet Classifier.py
3,351
3.546875
4
import tensorflow from keras_preprocessing.image import ImageDataGenerator #PART 1: IMAGE PREPROCESSING train_datagen = ImageDataGenerator(rescale = 1./255, shear_range = 0.2, zoom_range = 0.2, horizon...
afc0ab954176bdcbbb49b4415431c49278c9628c
kchow95/MIS-304
/CreditCardValidaiton.py
2,340
4.15625
4
# Charlene Shu, Omar Olivarez, Kenneth Chow #Program to check card validation #Define main function def main(): input_user = input("Please input a valid credit card number: ") #Checks if the card is valid and prints accordingly if isValid(input_user): print(getTypeCard(input_user[0])) print("The number is valid"...
ddba8ae517ee2e4620f25b8fdc227fc3369c60d9
cadracks-project/quaternions
/examples/quaternion_example.py
222
3.84375
4
#!/usr/bin/env python # coding: utf-8 r"""quaternion use example""" from quaternions.quaternion import Quaternion q = Quaternion() print(q) print(q.normalize()) print(q.conjugate()) q = Quaternion(a=2, b=3) print(q)
d057be1139247fd438e9d8bfb7fff8721ec8efb3
mxizhang/ScrapyCounty
/ScrapyCountyFlip/hunterdon_save.py
3,133
3.5625
4
import urllib2 import requests from openpyxl import load_workbook import csv FILENAME_PDF = "sale.pdf" FILENAME_CSV = "sale.xlsx" def hunterdon_save(): download_file("http://www.co.hunterdon.nj.us/sheriff/SALES/sales.pdf") convert_to_xlsx() csv_read() def download_file(download_url): response = urllib...
dd7b7315ee7d3cfd75af1a924c0fa5f2d0ab731d
syeutyu/Day_Python
/01_Type/String.py
1,380
4.125
4
# 문자열 문자, 단어 등으로 구성된 문자들의 집합을 나타냅니다. # 파이썬에는 4개의 문자열 표현 방법이 존재합니다. a = "Hello Wolrd" #1 a = 'Hello Python' #2 a = """Python Hello""" #3 a = '''Python String''' #4 # 1. 문자열에 작은 따옴표를 포함시킬경우를 위해 제작 # Python's very good 을문자열로 하기위해서는? a = "Python's very good" # 2. 위와 같이 문자열에 큰 따옴표를 표함하기위해서 제작되었다 # I want Study "Python" =...
ef63dbd450a1f14f64ba393d9f02637f31ef742e
MGarrod1/rgg_ensemble_analysis
/rgg_ensemble_analysis/sql_utils.py
9,520
3.6875
4
""" Functions to be used for reading and writing data to SQL databases """ import sqlite3 import sys import pdb import pickle """If importing MySQLdb doesn't work then we must isntead import the connector""" try : import MySQLdb except : print("Importing mysql as MySQLdb") import mysql.connector as MySQLdb de...
7ba0531979d8aed9f9af85d74a83cd2b5120426f
PythonTriCities/file_parse
/four.py
637
4.3125
4
#!/usr/bin/env python3 ''' Open a file, count the number of words in that file using a space as a delimeter between character groups. ''' file_name = 'input-files/one.txt' num_lines = 0 num_words = 0 words = [] with open(file_name, 'r') as f: for line in f: print(f'A line looks like this: \n{line}') ...
3dedca2b831eb13b40642a06b8284c039a463a37
ICHI18/flask-web
/instance/create_booktable.py
343
3.640625
4
import sqlite3 DROP_BOOKS = "DROP TABLE IF EXISTS books" CREATE_BOOKS = '''CREATE TABLE books( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, author TEXT, cover TEXT DEFAULT 'book.png' )''' conn = sqlite3.connect('bookdb.sqlite3') c = conn.cursor() c.execute(DROP_BOOKS) c.execute(CREATE_BOOKS) conn...
bf14268ceecf09e75939e019e52643814a47dd3e
running-on-sunshine/guess-the-number
/random-num.py
852
4.03125
4
from random import randint def replay(): # For Python 3: change line below to try_again = input("Try again? (y/n) ") try_again = raw_input("Try again? (y/n) ") if try_again == "y": play_game() elif try_again == "n": print("Thanks for playing!") else: ...
07cab18133c3063ca543a93eef35ddfd0aaff741
YasinMahdizadeh/Codeforces
/1325/C.py
984
3.5625
4
#!/usr/bin/env python # coding: utf-8 # In[83]: n = int(input()) edges = [] degrees = [0] for i in range(n): degrees.append(0) # In[84]: output = [] for i in range(n-1): output.append(-1) # In[85]: def d3(): d3_vertex = 0 for i in range(n+1): if ( degrees[i] > 2 ): d3...
3ac5d4343cc341bc6c517d08fcff1ae5012f58ea
cmpmohan/python
/forloop/for.py
233
3.6875
4
Write a Python program to construct the following pattern `*` `* *` `* * *` `* * * *` `* * * * *` `* * * *` `* * *` `* *` `*` Solution: for i in range(1,6): print('*' * i) for l in range(1,6): print('*' * (5-l) )
231bdad8f20bbdf5df6096884b58e388bc66d641
michelleweii/DataStructure-Algorithms
/5-1.排序与搜索.py
5,339
3.765625
4
# 冒泡排序 # 外层循环控制走多少次 # 内层循环控制从头走到尾 def bubble_sort(alist): """冒泡排序""" n = len(alist) for j in range(n-1): # j是[0,1,2,3,...,n-2] count = 0 for i in range(0,n-1-j): # 班长从头走到尾 if alist[i]>alist[i+1]: # 升序 alist[i],alist[i+1]=alist[i+1],alist[i] ...
aa47260420ce65f1e5b618416186ae42611c3466
HangLuis/machine_learning
/E2_LinearRegression.py
1,239
3.6875
4
#分别用最小二乘法和Sklearn包实现线性回归 import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression A = 2 B = 3 #生成两个100行1列的矩阵 xArr = np.random.randint(100, size=(100, 1)) eArr = np.random.randint(200, size=(100, 1)) #定义yArr yArr = A + B * xArr + eArr #保存为Excel文件,分别保存为X_dat...
46aeda1658a8c9463e6f9e369e4c6cadcbff4c1f
Yukiya025/legendary-octo-waddle
/20180926IR.py
466
3.953125
4
# -*- coding: utf-8 -*- # ↑ This is for recognising Japanese letters in .py file. """ Puzzle 21 id 76 """ def ping(i): if i > 0: return pong(i - 1) return "0" def pong(i): if i > 0: return ping(i - 1) return "1" print(ping(29)) # 1 print(ping(10)) # 0 print(pong(29)) # 0 print(pong(10)...
e1c9220ec6a8131ccc49023b2c1ba1e5b8d7eb7b
ilyes42/Python-3-DES-algorithm
/test.py
537
4
4
from des64v1 import cipher, reverse_cipher, tobits, frombits text = 'BONJOUR!' key = 'aa00df8' print('encryption key: ', key) print('text before encryption: ', text) bin_text = tobits(text) bin_key = tobits(key) print('#### CIPHERING ####') bin_result = cipher(bin_text, bin_key) result = frombits(bin_r...
a448f85c1c93a99ea4487e9d0a2285d712fed13f
benmichener14/MCLA_Python
/Exam_6/Clue.py
2,215
3.953125
4
#************************************************ # Ben Michener # 4/30/2017 # Intro to Python # Exam 6 (Clue.py) #************************************************ import Epic #************************************************ # Removes a selected term from the appropriate # list. Returns altered list. #**...
51ee45dc106e02bc975a25dde40fb7962b857e33
benmichener14/MCLA_Python
/RubiksCube.py
2,540
4
4
#************************************************ # Ben Michener # 2/16/2017 # Intro to Python # Exam 2 (RubiksCube.py) #************************************************ import Epic #************************************************ # Reads the specified file (filename) and returns a dictionary # whose keys a...
8b94964cfebbe218e6e048fb10fe8723fb42f856
mossytreesandferns/PythonPrograms
/PythonGenerateRandNum.py
566
3.71875
4
import random # .random() for x in range(5): print(random.random()) #.random() returns float betw 0 and 1 # .randint() for x in range(5): print(random.randint(10,30)) # Choosing from random list pets = ['turtle','frog','mantis','cat','bees'] first_feed = random.choice(pets) print(first_feed) # Crea...
dd5332cdf05ca677a9514d6c6c0d5f125492c79d
mossytreesandferns/PythonPrograms
/PythonLinkedLists.py
4,456
4.15625
4
"""Linked Lists""" # data structures of linked lists are called nodes class node: def __init__(self, data=None): self.data = data self.next = None class linked_list: def __init__(self): self.head = node() def append(self, data): new_node = node(data) current = sel...
0c79eb09eecb757788919268ba1c70b28f32542c
mossytreesandferns/PythonPrograms
/PythonBinarySearchTree.py
2,535
3.96875
4
"""Binary Search Tree and Binary Search Tree""" # space O(n), time avg worst O(nlogn) O(n) class node: def __init__(self, data=None): self.data = data self.left = None self.right = None class binary_search_tree: def __init__(self): self.root = None def insert(self, data)...
5d67e1df54ee08cb037dc74bc2cc993057c1eb69
mossytreesandferns/PythonPrograms
/CrawlerWikipedia.py
1,987
3.546875
4
import csv import os import requests import bs4 from bs4 import BeautifulSoup """Get Prominent Cajun Fiddlers""" def result_page_spider(): url = 'https://en.wikipedia.org/wiki/Cajun_fiddle' source_code = requests.get(url) source_text = source_code.text soup = BeautifulSoup(source_text,"lxml") ...
2e5e29bf9bbfa97839fcad012628cd8e06659311
JowitaKK/python
/function_if_statement.py
747
4.0625
4
def say_hi(name, age): print("Hello " + name + " you are " + str(age)) print("Top") say_hi("Jov", 35) print("Button ") #=========return function ============= def cube(num): return num*num*num result = cube(4) print(result) #============if statement============= is_male = True is_tall = True if is_mal...
5cf02b1cba3f8924ad3e40440a13f0d09d455d9e
JowitaKK/python
/loops.py
1,331
4.03125
4
# for loop # for x in range (1,10): # print(x) # print(x*x) for letter in "coffee": # for in - const, letter- any varriable name print(letter) for num in range (10,20,2): # its exclusive does not print 20 print(num) for num in range(0,100,5): print(num) #=========Exercises================= #...
45eea610ac318a73b71a21132ef3213fe9185666
eviss/ChangeAndCode
/python_intro.py
282
3.953125
4
""" name = 'onja' if name == 'ola': print('Hey, ola') elif name == 'onja': print('Hey, onja') else: print('Hey, anything') def hi(name): print('hi ' + name + '!') girls = ['ra', 'liliy', 'You'] for name in girls: hi(name) print('next') """ for i in range(1,7): print(i)
b236f90cf61d11b343c31e2c0ee3b0b900c98dfa
ezequielpilcsuk/Paradigmas
/python/atividade2/Organismo.py
1,420
3.796875
4
class Organismo: def __init__(self, position, size): self.position = position self.size = size class Parede_celular: def __init__(self, gram): self.gram = gram class Despesa: def __init__(self, upkeep): self.upkeep = upkeep class Cachorro(Organismo, Despesa): def __in...
a28cd468d0a50cd0cb34459672512a51625e3e17
jamwal-sahil/MOJO_Work
/MOJO_CLI/MojoSwitch.py
1,579
4.09375
4
a=str(input("Enter the Client MAC Address: ")) x='Y' while x.upper()=='Y': b=int(input(''' Select operation 1) Display SSID 2) Dispaly User Session Duration 3) Display Smart Device Type 4) Dispaly Local Time Zone 5) Privacy ALert! Users Domain Accesse...
5f99abdca68c86b2581b0718a4a6742d38fb2a8c
DaphneKeys/Python-Projects-
/fantasygameinventory.py
933
4
4
#!Python3 #This program display the list of keys and values of stuff, inv and dragonLoot #and sum the total number of items #Output:- # Inventory: # gold coin 45 # rope 1 # dagger 1 # ruby 1 # Total number of items: 48 stuff = {'rope' : 1, 'torch' : 6,'gold coin':42, 'dagger' : 1, 'arrow' : 12} inv = {'g...
86197f1e8ce174dca9be4a07d41bdadb38d2efbd
DaphneKeys/Python-Projects-
/guessthenumber.py
932
4.09375
4
import random print('Hello. what is your name') name = input() secretnumber = random.randint(1,20) print('Well, '+ name + ' ,I am thinking of a number between 1 to 20') for guesses in range(1,7): #guess 6 times print('Take a guess') number = int(input()) if secretnumber < number: print(...
35ad52319d07ff1cb2f22e56d682eba934bf6680
DaphneKeys/Python-Projects-
/looping.py
1,641
3.984375
4
# while Loop spam = 0 while spam < 5: print('Hello world!') spam = spam + 1 print('Example 1') print('-'*13) #Repeats until user type in 'your name' name = '' while name != 'your name': print('Please type your name.') name = input() print('Thank you!') print('Example 2') print('-'*13) ...
f120b6ad66ce4ca0c1a621eab1badd981673c3ac
DaphneKeys/Python-Projects-
/madlibs.py
1,099
3.984375
4
#!python3 #madlibs.py #Automate the boring stuff with python (Page 195) file = open('MadLibs.txt') content = file.read() print(content) file.close() #with open('MadLibs.txt') as text: # user_input = text.read() wordssplit = content.split() #['The', 'ADJECTIVE', 'panda', 'walked', 'to', 'the', 'NOUN', ...
042f8b369d088176061e6466a9ce63966526d2d9
DaphneKeys/Python-Projects-
/madlibs2.py
623
4.03125
4
content = "The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffected by these events." wordssplit = content.split() wordsDictionary = {k:v for k,v in enumerate(content)} #same thing as below #wordsDictionary = {k:v for k,v in k,v in content.items()} check = ["ADJECTIVE", 'NOUN', 'ADVERB', ...
4b07473939e5c43965a9a97184fa6432516501c8
hujialiang2020/mycode
/python/16.py
100
3.6875
4
n=10 sum=0 while n>0: print(sum,n) sum=sum+n n=n-1 print('计算结果为:',sum)
112ea8a8d75d2825a3c2d98aea44dd1c03ce5ba5
hujialiang2020/mycode
/python2/13.py
144
3.734375
4
# while 循环 # 循环变量的初始化 n=100 while n>=0: if n%2==0: print(n) # 控制循环变量变化的语句 n=n-1
c57e7eccb38e49f9c7dba68ded38a4bc0bbcc19d
hujialiang2020/mycode
/python/38.py
322
3.703125
4
a=int(input('请输入a:')) b=int(input('请输入b:')) c=int(input('请输入c:')) if a<1: a=1 if a>10: a=10 if b<1: b=1 if b>10: b=10 if c<2: c=2 if c>5: c=5 for x in range(a): print('我爱爸爸') for x in range(b): print('我爱妈妈') for x in range(c): print('我是胡嘉亮')
e010b2b8375146066b096ec4881a79a638076514
hujialiang2020/mycode
/python2/27.py
133
3.875
4
a=int(input('请输入一个数字:')) if a>10: print('大于10') elif a<10: print('小于10') else: print('等于10')
13d4a11e0e6a2ea3b2675e1e7e6ddfa4e3ce4600
patranun/bread
/function.py
227
3.90625
4
x = int(input()) y = int(input()) def addnumber(x,y): print(x+y) def minus(x,y): print(x-y) def multiplier(x,y): print(x*y) def division(x,y): print(x/y) addnumber(x,y) minus(x,y) multiplier(x,y) division(x,y)
d2fd477b8c9df119bccb17f80aceda00c61cd82d
Sai-Sumanth-D/MyProjects
/GuessNumber.py
877
4.15625
4
# first importing random from lib import random as r # to set a random number range num = r.randrange(100) # no of chances for the player to guess the number guess_attempts = 5 # setting the conditions while guess_attempts >= 0: player_guess = int(input('Enter your guess : ')) # for checking ...
7e144bbcfd54941dc83968dd89635b11df61aca4
Ciro1690/Code-in-Place
/nimm.py
1,157
4.03125
4
""" File: nimm.py ------------------------- Add your comments here. """ def main(): stones = 20 player = 1 while stones > 0: if player == 1: print("There are " + str(stones) + " stones left") choice = int(input("Player " + str(player) + " Would you like to remove 1 or 2 ston...
13df5ddbfa73e69d1063d2055d28fd5d448a5509
ydebaz/python-assignment-2
/list2/count_evens.py
102
3.546875
4
def count_evens(nums): q=0 for i in range(len(nums)): if nums[i]%2==0: q=q+1 return q
34bd11929e6344b5206b63f631d3f5f9cbbac14f
ydebaz/python-assignment-2
/logic1/caught_speeding.py
259
3.625
4
def caught_speeding(speed, is_birthday): if is_birthday==True: if speed <66: return 0 elif speed<86: return 1 else : return 2 else : if speed <61: return 0 elif speed<81: return 1 else : return 2
00e7da3547ed1d65e56f5491737ff0e534035227
Articate/CodingProblems
/DCP_108.py
639
4
4
''' Daily Coding Problem #108: Given two strings A and B, return whether or not A can be shifted some number of times to get B. For example, if A is abcde and B is cdeab, return true. If A is abc and B is acb, return false. ''' def can_shift(arg1, arg2): for i in range(len(arg1)): # Make all iterations he...
04878674015c392d7aa3b1d663ce9a031850fa58
dipin24/create-a-small-function-of-python
/cube.py
148
4.03125
4
def cube(num): return num * num * num num = int(input("Enter an any number: ")) cub = cube(num) print("Cube of {0} is {1}".format(num, cub))
66c2f836f47ef7d71aed9d1acfbb87cdb14c2c40
scxr/foobar-sols.py
/3a.py
621
3.828125
4
import json import math """ https://en.wikipedia.org/wiki/Partition_(number_theory) """ def solution(n): # pad size sizearr = n + 1 # create zero-filled multi_arr multi_arr = [[0 for x in xrange(sizearr)] for n in xrange(sizearr)] # base value is always skipped after being padded multi_arr[0]...
9969b290d6177312b7d4ea4513cdd0571490e3ac
Angeloquim/EXP6-Hangaroo
/hangaroo.py
1,798
4.09375
4
def isWordGuessed(secretWord, lettersGuessed): for x in secretWord: if x not in lettersGuessed: return False def getGuessedWord(secretWord, lettersGuessed): word = '' for x in secretWord: if x in lettersGuessed: word += x else: ...
d541bf1761124b3aa573557912fd40664afde72f
Diogueira/CursoEmVideoPyton
/desafio 7.py
174
3.90625
4
nota1 = float(input('Digite a primeira nota: ')) nota2 = float(input('Digite a segunda nota: ')) media = (nota1+nota2)/2 print('A media do aluno foi {:.1f}.'.format(media))
54d89873ce83e0bbb946f4f54446db5d08dd5af0
the-isf-academy/lab-trivia-2021
/player.py
694
3.96875
4
# player.py # Author: Emma Brown # ================== class Player: """ Creates a Player object for use in the TriviaGame. Player includes a name, score, and buzzer, and button. """ def __init__(self, name, button, buzzer,led): self.name = name self.score = 0 self.buz...
6513977254d7ef8c8f23a151cea24bfc5ef64de6
alien19/Classical-Ciphers
/hill.py
1,743
3.9375
4
import numpy as np def encrypt_hill(plainText, key): """ encrypts plaintext with hill cipher method and writes the output in hill_cipher.txt Args: plainText(list): list of plaintext in hill_plain.txt file [each line in the file is a list element] key(list): h...
3221e23e7a757591ed65cd062d9a98e4b680f081
mhoamedbayoumi/detecting-Fake-News-with-Python
/learn.py
1,568
3.546875
4
#importing important modules that we will need import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score import itertools from sklearn.metrics import confusion_matrix from sklearn.feature_extraction.text import TfidfVectorizer from skl...
dc2468b63209b7c02b3555e9b39ee58b960dca36
webclinic017/quant-framework
/quant_framework/data_providers/data_provider.py
592
3.734375
4
from abc import ABC, abstractmethod class DataProvider(ABC): ''' An abstract class that all data providers must inherit from Data Providers are intended to be wrappers around vendors that provide daily stock market data ''' @property @abstractmethod def name(self): pass @p...
8b824f5acd7443f794419c74369f89dcdae6d407
Yemeen/Kindling
/foldercount.py
628
4
4
import os def numfold(path): # path='/home/' + os.getlogin() + '/Code/Kindling/images/' # path = "./images/" files = folders = 0 for _, dirnames, filenames in os.walk(path): # ^ this idiom means "we won't be using this value" folders += len(dirnames) return folders def numfile(path): # path='/home/' + o...
dbef91a7ddfd4100180f9208c3880d9311e2c94c
Arlisha2019/HelloPython
/hello.py
1,319
4.34375
4
#snake case = first_number #camel case =firstNumber print("Hello") #input function ALWAYS returns a String data type #a = 10 # integer #b = "hello" # String #c = 10.45 # float #d = True # boolean #convert the input from string to int #first_number = float(input("Enter first number: ")) #second_number = float(input("En...
9246e299a1f1aa0ba8328fa2b7ab5a5047a70f90
mokkeee/tddbc5th_python
/grid_points.py
2,263
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from grid_point import GridPoint __author__ = 'mokkeee' class GridPoints(object): def __init__(self, *args): if not self.__is_valid_grids(args): raise ValueError self.__grids = args def __contains__(self, item): if not isinsta...
c04adc6f367b080a1001447a8186ae0434430735
wqmeepo/practice-project
/IDLE 学生管理系统/do.py
4,790
3.6875
4
def save(student): with open('./student.txt', 'a+') as f: for info in student: f.write(str(info) + '\n') def insert(): studentList = [] mark = True while mark: init = input('即将开始录入学生信息,输入0回到主界面') if init == '0': break id = input('请输入6位ID(例如000001...
2afb37f1e237b6bf7fd1d3eb9e2ed9386b8299ac
thulanimbatha/python_turtle-day-18
/challenge4.py
479
3.5625
4
import turtle import random directions = [0, 90, 180, 270, 360] tmnt = turtle.Turtle() tmnt.shape("turtle") tmnt.pensize(13) tmnt.speed("fastest") turtle.colormode(255) def random_colour(): r = random.randint(0, 255) g = random.randint(0, 255) b = random.randint(0, 255) return (r, g, b) for _ in ra...
72562cee1e41dc97927abe5c23ff63f950caae91
unitogi/20x20DaysOfPython
/Input_output/console.py
345
3.9375
4
"""Typecasting and input from console""" def oddeven(num): if num%2==0: print("Even") else: print("Odd") return def main(): print("running") n = int(input("Enter a number to check even or odd : ")) print("THIS IS MAIN FUCNTION") oddeven(num) if __name__ == '...
8661f7bd1b892e82d69446da6e5fca81eaca79fa
GaganDureja/Algorithm-practice
/Fibonacci.py
257
3.953125
4
#Problem: Implement the function fib(n),\ # which returns the nth number in the Fibonacci sequence, using only O(1) space. def fib(n): return 0 if not n else 1 if n==1 else fib(n-1) + fib(n-2) print(fib(0)) print(fib(5)) print(fib(8))
06297a13292f55c548d902be0d153dfebaaa0b68
GaganDureja/Algorithm-practice
/sum odd,even.py
205
3.828125
4
#Link: https://edabit.com/challenge/5XXXppAdfcGaootD9 def sum_odd_and_even(lst): return [sum(x for x in lst if x%2==0) ,sum(x for x in lst if x%2)] print(sum_odd_and_even([1, 2, 3, 4, 5, 6]))
c091a35ca580e22cd3afdb473422a3832957cdeb
GaganDureja/Algorithm-practice
/recaman sequence.py
273
3.640625
4
#Link: https://edabit.com/challenge/fW52x9Gh5iMKNfWMt def recaman_index(n): lst = [0] while n not in lst: num1 = lst[-1]-len(lst) num2 = lst[-1]+len(lst) lst.append(num1 if num1>=0 and num1 not in lst else num2) return len(lst)-1 print(recaman_index(7))
1c608c7fea6d75023c0533d888e2346f5439d674
GaganDureja/Algorithm-practice
/Collatz Conjecture.py
195
3.796875
4
#Link: https://edabit.com/challenge/X8fNb5EouWxrMMjZL def collatz(num): count = 0 while num!=1: if num%2:num= num*3 +1 else:num/=2 count+=1 return count print(collatz(10))
30ab7d4ef238c8f6002a85e286e011a4edb2fa23
GaganDureja/Algorithm-practice
/words to sentence.py
293
3.875
4
#Link: https://edabit.com/challenge/GP6CEr9a5CMqPHY7C def words_to_sentence(words): if not words: return '' words = [x for x in words if x] l = len(words) return ''.join(words[x] +(' and ' if x==l-2 else '' if x==l-1 else ', ') for x in range(l)) print(words_to_sentence(None))
14b39d2d299b845a4c72dac97f0a2c43f096c6bc
GaganDureja/Algorithm-practice
/find unique.py
157
3.53125
4
#Link: https://edabit.com/challenge/GaXXfmpM72yCHag9T def unique(lst): return [x for x in lst if lst.count(x)==1][0] print(unique([3, 3, 3, 7, 3, 3]))
8e87f3cbe94c2da7ea76be728727036a07d1311e
GaganDureja/Algorithm-practice
/sum two num.py
486
3.890625
4
#Given a list of numbers and a number k, return whether any two numbers from the list add up to k. #For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. #Bonus: Can you do this in one pass? from itertools import combinations as cb def sum_of_two(lst,k): return any(sum(x)==k for x in c...
0b70fa9835857ad1361413bbb6bf73716cbc5ab5
GaganDureja/Algorithm-practice
/binary search.py
326
3.921875
4
#Link: https://edabit.com/challenge/kKFuf9hfo2qnu7pBe primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def is_prime(primes, num, left=0, right=None): for x in range(left,len(primes)): if primes[x]==num: return 'yes' return 'no' print(is_prime(prime...
ec80b2382b81b8dd75f638e4f9fe59fc98424c12
GaganDureja/Algorithm-practice
/mystery challenge.py
338
3.609375
4
#Link: https://edabit.com/challenge/uCKJi6X3KTH9zuSc3 def mystery_func(n): n=str(n) res = [n[0]] for x in range(1,len(n)): if n[x]==n[x-1]: res[-1]+=n[x] else: res.append(n[x]) return ''.join([''.join([str(len(x)),x[0]]) for x in res]) print(myst...
c0883b467fa9ac0cfce8973582431382784e8958
GaganDureja/Algorithm-practice
/Unique char.py
149
3.5
4
Link: https://edabit.com/challenge/oTJaJ895ubqqpRPMh def count_unique(s1, s2): return len(set(s1+s2)) print(count_unique("apple", "play"))
b8a0ee1bbac2ab2947ea33c4d03ec457fe575feb
GaganDureja/Algorithm-practice
/Unique char map.py
215
3.953125
4
#Link: https://edabit.com/challenge/yPsS82tug9a8CoLaP def character_mapping(txt): lst = '' for x in txt: if x not in lst: lst+=x return [lst.index(x) for x in txt] print(character_mapping("babbcb"))