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
e516f72d59516fa7c4b19e4e54f8db01d7427ab1
wh2per/Programmers-Algorithm
/Programmers/Lv3/Lv3_타일장식물.py
170
3.625
4
def solution(N): d = [0]*(N*2) d[1] = 1 d[2] = 1 for i in range(3,N+2): d[i] = d[i-2] + d[i-1] return d[N]*2 + d[N+1]*2 print(solution(5))
fc9b0f8e4e162b7194deac8834064c76458555d2
wh2per/Programmers-Algorithm
/Programmers/Lv1/Lv1_자연수뒤집어배열로만들기.py
124
3.546875
4
def solution(n): answer = [] s = reversed(str(n)) for i in s: answer.append(int(i)) return answer
9000f77994c2cb607a822d4bf3980a9c4d4a0200
gchriswill/METCS521-HW3
/chriswgm_hw_3_4_2.py
714
4.09375
4
""" Student: Christopher W Gonzalez Melendez Class: CS 521 - Summer 2 Date: 07/27/2020 Homework Problem: #2 Description: A program to demonstrate the usage of method that ease string manipulation. """ # Constants for the odd string and the relevant message ODD_STR = "Christopher" RELEVANT_MSG = "This odd string is n...
8ae9e4c2915d771cf5f3a4802153ccc4b9ba3f4a
sainihimanshu1999/Arrays-LeetCode
/MaximumProductSubarray.py
361
3.71875
4
''' In this question we hav to find the contigous subarray with maxproduct, we just take product forward and backwards then combine those array to get the maximum product out of them ''' def maxProductsubarray(self,nums): a = nums[::-1] for i in range(1,len(nums)): nums[i] *= nums[i-1] or 1 a[...
651a036ce80c3f728e8bdcb28d3c94c644f5e5ca
sainihimanshu1999/Arrays-LeetCode
/SetMatrixtoZero.py
794
3.96875
4
''' In this question we have to set the matrix element(boht row and col zero) where zero is originally present we make two list rl and cl and same row and col coordinate where zero appears, and then remove duplicates from them and make every element of row and col zero there ''' def setmatrixzero(self,matrix): m =...
beaece7dfc9fedf95354e3362827b805ac1a0dc1
sainihimanshu1999/Arrays-LeetCode
/LongestConsecutiveSubsequence.py
343
3.796875
4
''' In this question we have to find the longest consecutive subsequence of numbers from the given numbers. ''' def LCS(self,nums): nums = set(nums) length = 0 for x in nums: if x-1 not in nums: y = x+1 while y in nums: y+=1 length = max(length,...
e86f62f6229d5166113d3dcfe8456e456f3ef610
sainihimanshu1999/Arrays-LeetCode
/MergeTwoSortedArrays.py
270
3.859375
4
''' This is an easy question, just remember you can in place edit the array if you know the index and all ''' def mergeTwoSortedArrays(self,nums1,m,nums2,n): if n == 0: return nums1 for num in nums2: nums1[m] = num m+=1 nums1.sort()
310310bfeacd00c2af7a6a0bc315f0832f17e3ca
sainihimanshu1999/Arrays-LeetCode
/ValidTriangle.py
429
3.953125
4
''' A triangle i said to be valid when the sum of any two sides is greated than third side ''' def validTriangle(self,nums): count = 0 nums.sort() n = len(nums) for i in range(n-1,1,-1): low = 0 high = i-1 while low<high: if nums[low]+nums[high]>nums[i]: ...
7f6593cacf560b64b556593943ff5bcf9415c20b
sainihimanshu1999/Arrays-LeetCode
/JumpGame2.py
598
3.640625
4
''' In thid question we take two variable, curr_cover and last_jump_index, curr_cover maintains the distance we travelled and last_jump_index maintains the current index we are on. ''' def jumpGame(self,nums): n = len(nums) if n ==1: return 0 destination = n-1 curr_cover = 0 last_jump_in...
dd83fa66ba7d7d8cb42d37725ceed62d4c5a22a5
sainihimanshu1999/Arrays-LeetCode
/ContainerwithMostWater.py
473
3.859375
4
''' In this question two pointer approach is used, and always remember that in two pointer approach, both pointers does not move simultaneously, rather there is a condition to move them ''' def maxArea(self,height): start = 0 end = len(height)-1 water = 0 while start<=end: water = max(water, ...
489bcc0cd405e007cde01bc22c15dffbc82fdb8b
Manish9718/Python
/Function file till Loop.py
35,036
4.46875
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 13 20:28:37 2020 @author: yamanish """ '''Starting of function:''' ========================= We have 3 type of function: 1) Build in Function: Len(), Print(), Count(), shuffle, randint, enumerate, min max, zip 2) User defined Function: Which are de...
be045bc27bf57fdebf319266babaacb851387e46
anupbharade09/Algorithms-Data_Structures
/CS_6114/linked_list.py
646
3.921875
4
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) cur = self.head while cur.next != None: cur = cur.next cur.next =...
05ac42b6a7ad86bed47988f4fc004a332c805800
JenteOttie/Avian_tRNAs
/tRNA_Clusters.py
6,497
3.765625
4
# Python script to check the distribution of tRNAs across the genome # The genomic locations for each tRNA are extracted from a overview file # To check whether the tRNAs cluster in the genome, the user is asked to provide a threshold of distance between tRNAs (in this case the genome-wide median - see R-script) impor...
3c564afb5b2ffd328e44cca9a36f929ab63c7edf
DeepakM2001/python_intern
/d7/Ex2.py
352
3.96875
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 18 22:11:07 2021 @author: Deepak Murugesan """ def covid(name,btemp): print("patient name is :",name,"\tbody temperature:",btemp) name = input("enter patients name:\n") btemp = input("enter temperature :") if btemp.isalpha() == True: weight = 98 el...
769c3e591bd78805c7b3799d4ce876d91bc23877
DeepakM2001/python_intern
/d14/try_except.py
323
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 27 18:05:23 2021 @author: Deepak Murugesan """ try: a = 123 if a==123: print(b) raise NameError("Name error") if a >0: raise ValueError("Value error") except NameError as ne: print(ne) except ValueError as ve: ...
49a165df2abe6456b1d37ae472814ed0c6a1eeeb
DeepakM2001/python_intern
/d9/Ex5.py
242
3.828125
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 21 21:57:39 2021 @author: Deepak Murugesan """ n_156 = int(9) mul_2 = 0 print("multiplication table of : 9",) for p in range(1,10+1): mul_2 = n_156*p print(n_156 ,"x", p ,"=", mul_2 )
d4da079c380e87ca07ddbc542294584baea9b9a5
DeepakM2001/python_intern
/d8/Ex8.py
774
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 20 21:29:08 2021 @author: Deepak Murugesan """ from collections import Counter def MMM(n_num): n = len(n_num) get_sum = sum(n_num) mean = get_sum / n print("Mean / Average is: " + str(mean)) n_num.sort() if n % 2 == 0: med...
22c783941ab9c04aa44de1d1cc9f2a5ca6c371ba
DeepakM2001/python_intern
/d21/Ex1_1.py
271
3.984375
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 6 21:33:24 2021 @author: Deepak Murugesan """ def merge(list1, list2): merged_list = list(zip(list1, list2)) return merged_list list1 = [1, 2, 3] list2 = ['a', 'b', 'c'] print(merge(list1, list2))
5eceee81798a9b02229cfda471037eb023c35c31
DeepakM2001/python_intern
/d5/Ex2.py
174
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 14 17:06:19 2021 @author: Deepak Murugesan """ my_tuple = ("I am kapeeD") my_tuple = tuple(reversed(my_tuple)) print(my_tuple)
33b02513df20dd4cbe00720afbf3886781875d66
KKraan/Mailbox
/mimp.py
1,933
3.671875
4
# -*- coding: utf-8 -*- """This file contains functions to import the data. With "readdata", the data is imported and a dataframe is returned. @author: Kraan """ import pandas as pd Maildata = 'Mailgegevens.xlsx' textfilename = 'mailtekst.txt' # DEFINE FUNCTIONS def definenumber(textpart): """Based on "checklis...
613b47f563a9143c8cb1a3a2469228ae45bc1f4a
sagard21/descriptive_statistics_project
/q02_plot/build.py
690
3.75
4
# Default Imports import pandas as pd import matplotlib.pyplot as plt from greyatomlib.descriptive_stats.q01_calculate_statistics.build import calculate_statistics dataframe = pd.read_csv('data/house_prices_multivariate.csv') sale_price = dataframe.loc[:, 'SalePrice'] # Draw the plot for the mean, median and mode fo...
fb9b299eff93179ac097d797c7e5ce59bc20f63a
yugin96/cpy5python
/practical04/q5_count_letter.py
796
4.1875
4
#name: q5_count_letter.py #author: YuGin, 5C23 #created: 26/02/13 #modified: 26/02/13 #objective: Write a recursive function count_letter(str, ch) that finds the # number of occurences of a specified leter, ch, in a string, str. #main #function def count_letter(str, ch): #terminating case when string is...
599df5c53d26902da3f2f16cb892a0ae6501be78
yugin96/cpy5python
/practical04/q6_sum_digits.py
482
4.28125
4
#name: q6_sum_digits.py #author: YuGin, 5C23 #created: 26/02/13 #modified: 26/02/13 #objective: Write a recursive function sum_digits(n) that computes the sum of # the digits in an integer n. #main #function def sum_digits(n): #terminating case when integer is 0 if len(str(n)) == 0: return 0...
f0d3f474dfb9c4c893a79b8f7d6c3d8ccbc29078
yugin96/cpy5python
/practical02/q08_top2_scores.py
6,220
4.25
4
#filename: q08_top2_scores.py #author: YuGin, 5C23 #created: 29/01/13 #modified: 30/01/13 #objective: Take as input a number of students' names and their scores, and return the names of the students with the two highest scores. #additional objective: If multiple students have either the top or second-from-top score, re...
7315634187176a683570d3abfa829d47f483cf3d
yugin96/cpy5python
/practical02/q07_miles_to_kilometres.py
635
3.84375
4
#filename: q07_miles_to_kilometres.py #author: YuGin, 5C23 #created: 29/01/13 #modified: 29/01/13 #objective: Display two tables side by side: One shows values of 1-10 miles and their corresponding values in kilometres; the other shows values of 20-65 kilometres # in intervals of 5 km and their corresponding ...
78baf00a600d84297b1f2abac7d09470fce0638f
hechtermach/ML
/untitled2.py
218
4.3125
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 22 01:27:35 2019 @author: mach0 """ import itertools list_step=['R','L','U','D'] list_all=[] for item in itertools.product(list_step,repeat=3): print (item)
17ba89a7ead84c24761240540961cc4559e31ab7
Silverutm/Concursos-Algoritmia
/XV Semana 0ct 2016/alreves/SolutionLittle.py
312
3.5625
4
def es_palindromo(m): for i in list(range(len(m))): if m[i] != m[len(m)-i-1] : return False return True n = int(input()) for x in range(n): a, b = [int(x) for x in input().split()] tot = 0 for i in list(range(a, b+1)): #print(i, end = ' ') tot += es_palindromo(str(i)) #print(tot) print(tot)
ed4d02e186bbd711f970ae29fd5a3a5828b4dbdb
1997priyam/Data-Structures
/arrays&mix/pyramid_number.py
260
4.03125
4
#!/usr/bin/python3 num = int(input("Enter a number: ")) for i in range(num,-1,-1): for j in range(i): print("", end=" ") for k in range(num-i+1): print(k, end="") for l in range(num-i-1,-1,-1): print(l, end="") print("")
105f437782b818e66122b84088377d775b1b04a8
1997priyam/Data-Structures
/arrays&mix/countandsay.py
633
3.953125
4
""" The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... """ def countAndSay(A): num = "1" for i in range(A-1): count = 0 prev = num[0] new_num = "" for j in range(len(num)): if num[j] == prev: count...
0d6af4582b3165cf5947c4ba1fc539fc96322677
vpythonfcfm/Coordenadas
/coordenadas.py
1,695
3.75
4
from vpython import * from math import * def es_numero(valor): """ Indica si un valor es numérico o no. """ return isinstance(valor, (int, float, long, complex) ) class Punto(object): def __init__(self, x=0, y=0, z=0): """ Constructor de Punto, x e y deben ser numéricos, de no ser así, se levanta una...
595fdebab1b1dc92ba2f123073b5e42bf258e309
qdev-dk/qdev-wrappers
/qdev_wrappers/configreader.py
2,629
3.53125
4
# Module containing the config file reader class from configparser import ConfigParser class Config: """ Object to be used for interacting with the config file. The ConfigFile is constantly synced with the config file on disk (provided that only this object was used to change the file). Args: ...
e6a09452aa1308100af09ea215edb35fb88368a3
Adriskk/FakeIDGeneratorApp
/random_identity/identity.py
2,890
3.515625
4
from random import randrange from random import choice from faker import Faker import datetime # - FILES from random_identity.data.data import * fake = Faker() minimum_age = 19 now = datetime.datetime.now() current_year = now.year - minimum_age years = [] year = 1940 for i in range(0, (current_year - ...
e8761af386686f370f8f828e018ff1daf757e072
league-python-student/level0-module1-danatheprincess
/_03_if_else/_3_secret_message_box/secret message box.py
410
3.875
4
from tkinter import messagebox, simpledialog, Tk window=Tk() window.withdraw() secret= "birthday" message=simpledialog.askstring("","Enter SECRET MESSAGE") messagebox.showinfo("","if you want to see the secret message you should guess the password first") password=simpledialog.askstring("","Enter password") if password...
ab4ed3e4cf03888fb88f478170102e9d67b7d351
holdeelocks/Sorting
/src/recursive_sorting/recursive_sorting.py
1,297
4.0625
4
def merge(arrA, arrB): merged_arr = [] while (len(arrA) and len(arrB)): if (arrA[0] < arrB[0]): merged_arr.append(arrA.pop(0)) else: merged_arr.append(arrB.pop(0)) merged_arr.extend(arrA + arrB) return merged_arr def merge_sort(arr): if len(arr) <= 1: ...
998d801f7de31fa23c006bd082c33a9474236cf7
Monsieurvishal/Peers-learning-python-3
/programs/list_sum.py
195
4.1875
4
# Program to find the sum of all numbers stored in a list sum=0 numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11] for val in numbers: sum = sum+val print("The sum is", sum) #output: The sum is 48.
fbd7624f47d4e14b47722923fd568c31e082d91d
Monsieurvishal/Peers-learning-python-3
/programs/for loop.py
236
4.59375
5
>>for Loops #The for loop is commonly used to repeat some code a certain number of times. This is done by combining for loops with range objects. for i in range(5): print("hello!") Output: hello! hello! hello! hello! hello!
c56cc5a285093da9ca9cc2265e344bfdbf03f929
Monsieurvishal/Peers-learning-python-3
/programs/for loop_p3.py
282
4.3125
4
>>Write a python script to take input from the user and print till that number. #Ex: if input is 10 print from 1 till 10. n=int(input("enter the number:")) i=0 for i in range(n): print(i) i=i+1 print("finished") #output: enter the number: 0 1 2 3 4 5 6 7 8 9 finished
02d08829f1f1b03c3db9bdfe4d9d696ab4afca7c
joao-conde/advents-of-code
/2017/src/day01.py
1,017
3.59375
4
input_file = open("input/day01") puzzle_input = input_file.read() input_file.close() puzzle_len = len(puzzle_input) # PART1 captcha1 = 0 for i in range(0, puzzle_len): # last element has to check the first (circular list) if i == puzzle_len - 1: if puzzle_input[i] == puzzle_input[0]: ...
220c81cc277241645a50b8ac92eec106563e6cdf
kaitlavs/REDCap_Data_Transformation
/version2.py
21,734
3.75
4
import pandas as pd # import sys def create_df(file_name): """ Returns a DataFrame from a cvs file """ return pd.read_csv(file_name) def return_matches_between_data_and_metadata(data_list, metadata_list): """ Returns a list of all items common to both metadata lists and data lists. data_list i...
bfb3f73a402bf3d98775a80bcbe7cbde8875826d
RSAkidinUSA/ctf
/guess_sha256/flag_guess.py
656
3.625
4
#!/usr/bin/python3 # This script is used to generate random guess from the charset and check # if they are the flag of the ctf competition import random from flag_vars import charset, flaglen from flag_test import test def gen_guess(): guess = '' for i in range(flaglen): c = charset[random.randint(0, len(charset...
4c9ffe29f4245e08e5128fb4cabe35f7b2b8d101
Nita-Boni/my-first-blog
/prueba.py
189
3.71875
4
# Miralo bien name = 'Ana' if name == 'Ola': print('Hey Ola!') elif name == 'Sonja': print('Hey Sonja!') elif name == 'Ana': print('yessss!') else: print('Hey anonymous!')
5cfa6e114552a027ba32243fecaeb69ac3242402
dell-ai-engineering/BigDL4CDSW
/2_deeplearning/autoencoder_mnist.py
5,225
3.625
4
# Using an auto encoder on MNIST handwritten digits. # In this tutorial, we are going to learn how to compress handwritten digit images from MNIST dataset # and reconstruct them by using [autoencoder](https://en.wikipedia.org/wiki/Autoencoder) algorithm. # The autoencoder model is mainly composed of an ***enco...
24b146a3e423fd413124b988150d4e1ee01b4204
dell-ai-engineering/BigDL4CDSW
/1_sparkbasics/1_rdd.py
1,467
4.25
4
# In this tutorial, we are going to introduce the resilient distributed datasets (RDDs) # which is Spark's core abstraction when working with data. An RDD is a distributed collection # of elements which can be operated on in parallel. Users can create RDD in two ways: # parallelizing an existing collection in you...
9fe4fba829899ac04b1366c8425db8f3c46dc8f1
PavelSlepushkin/fizzbuzz
/fizzbuzz.py
367
3.84375
4
#!/usr/bin/env python3 # Standard boilerplate to call the main() function to begin # the program. def main(): for i in range(1,101): if 0 == i%15 : print ('FizzBuzz') elif 0 == i%5 : print ('Buzz') elif 0 == i%3 : print ('Fizz') else: p...
c1f5e291411edf4edac9addaeee960c0dcc7d371
uyennguyen87/python
/metaprogramming/MyList.py
265
3.640625
4
# Metaprograming/MyList.py def howdy(self, you): print "Howdy, " + you MyList = type('MyList', (list, ), dict(x=42, howdy=howdy)) myList = MyList() myList.append("Camembert") print myList print myList.x myList.howdy("Uyen") print(myList.__class__.__class__)
e084db566617188aaf2e46123e4ff2debd444e95
uyennguyen87/python
/network/1_1_local_machine_info.py
427
3.5
4
# python3 import socket def get_machine_info(): host_name = socket.gethostname() ip_address = socket.gethostbyname(host_name) return { 'host_name': host_name, 'ip_address': ip_address } def print_machine_info(): info = get_machine_info() print("Host name: %s" % info['host_nam...
8438dc1c4416d68bf54b351503c13fc56bf0b90e
nguyenla/Sugar-spelling-activity
/Speak.py
632
3.625
4
# @author: Angel Shiwakoti # @createdOn: 02/06/2017 # This class uses threading to spell the word # using Espeak Library. It prevents the UI Blocking # while Espeak is spelling a word. import threading import gobject import os import espeak gobject.threads_init() class Speak(threading.Thread): def __init__(self...
c53d3807f4b997baf6033cc1c54be0038b593a23
Vladimir-82/code_wars
/Does_my_number_look_big_in_this.py
543
4.09375
4
def narcissistic(value): ''' A Narcissistic Number is a positive number which is the sum of its own digits, each raised to the power of the number of digits in a given base. In this Kata, we will restrict ourselves to decimal (base 10). 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 1^4 + 6^4 + 5^4 + 2^4 ...
0431501bbf49d95208fb0df853a83ce3f8aa3ad9
Vladimir-82/code_wars
/Recreation_One.py
1,645
3.65625
4
def list_squared(m, n): '''1, 246, 2, 123, 3, 82, 6, 41 - делители числа 246.Возводя эти делители в квадрат, получаем: 1, 60516, 4, 15129, 9, 6724, 36, 1681. Сумма этих квадратов равна 84100, чтосоставляет 290 * 290. Задача Найдите все целые числа от m до n (m и n целые числа, такие как 1 <= m <= n)...
d6a6c132a0c34e2cec3f26a4f72c984843b24143
isrusin/lab-tools
/make_site_list.py
2,660
3.515625
4
#! /usr/bin/env python2 """Site list generator. The tool generates a list of all sites of the given length or all sites matching the specified template. """ import argparse from itertools import product import re import signal import sys def mask_type(value): """Site template type.""" length = value.count(...
cd127e3a4d0a4d1413c118abb1170a07c7358567
hoangqwe159/DoVietHoang-C4T5
/Homework 2/Turtle ex2.py
228
3.75
4
from turtle import * speed(0) n = 3 while n < 7: if n % 2 == 1: color("blue") else: color("red") for i in range (n): forward(100) left(180 - 180 * (n - 2) / n) n = n + 1 mainloop()
c767555ee9c73ae671ed7d37c5951dbe943c3635
hoangqwe159/DoVietHoang-C4T5
/Homework 2/session 2.py
258
4.21875
4
from turtle import * shape("turtle") speed(0) # draw circles circle(50) for i in range(4): for i in range (360): forward(2) left(1) left(90) #draw triangle # = ctrl + / for i in range (3): forward(100) left(120) mainloop()
f9e6948812fefcfd9aba9a25a7479f06ad779e75
NoemiFlores/TestingSistemas
/ene-jun-2019/NoemiEstherFloresPardo/Practica7/Mascotas.py
2,118
3.5
4
import sqlite3 class Mascota(): def __init__(self, nombre, especie, edad): self.nombre = nombre self.especie = especie self.edad = edad def __str__(self): return "Nombre de la mascota: {} Especie: {} Edad: {}".format(self.nombre, self.especie, self.edad) def __eq__(self, t...
a072f2d30088a42a3a3098806d0e9884e9840d77
adamantiumaurora/MLExcercises
/ml_exercises/supervised_learning/cost_functions.py
1,747
3.890625
4
def mean_absolute_error(predictions, observations): ''' Mean absolute error expressing the arithmetic average of the absolute errors. All individual deviations have even importance. Parameters: predictions (array): array of double values representing predicted values observations (array...
810b58cdc7bd68bc54369515bfb0d5390b910ede
abhishekkolli/assignment-4
/problem8.py
1,523
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 26 11:54:59 2021 @author: kolliabhishek """ """play hangman""" import random #def hangman(): if __name__=="__main__": f=open("common_words.txt","r") entirefile=f.read() f.close() common_words=entirefile.split() #print(common_arr...
9db3cfe54657040160ba8fedb87b7eb3beb4a9ef
frank217/Summer-Coding-2018
/CODEChef June Challenge 2018/ Sheokand and String.py
3,908
3.609375
4
""" Sheokand and String Problem Code: SHKSTR https://www.codechef.com/JUNE18B/problems/SHKSTR """ """ Naive version : for each querie run through all the possible string and find the word with longest common prefix that is lexicographically smallest. Runtime : O(q * n * 10) = O(10^11) This only passes on the saml...
464fd20db57c94a62710ba9697a9d64abfe7f323
frank217/Summer-Coding-2018
/CODEChef June Challenge 2018/NAICHEF.py
8,348
3.625
4
# Conquer and divide """ Naive Chef https://www.codechef.com/JUNE18B/problems/NAICHEF Input : """ def naichef(dice ,a,b): countA = 0 countB = 0 for i in dice: if a == i: countA+=1 if b == i: countB+=1 return (countA/len(dice))*(countB/len(dice)) #...
a64975b07f4e72045250ce1bc94a801e62967094
anuvazhayil/Python-Programs
/RotationCipher.py
533
3.59375
4
class RotationCipher(object): def __init__(self): self.plain = '' def rot_cipher(self, rot, cipher): for elem in cipher: if elem.isalpha(): if elem.isupper(): if ord(elem) + rot > 90: self.plain += chr(ord(elem) + rot - 26) else: self.plain += chr(ord(elem) +...
bbbacf8c3dc58f10eec1b4904bf2267ce6f61554
ryankynor/Final-Project
/Finalproject.py
1,220
4.09375
4
""" Ryan Kynor Geostationary orbit calculator """ import math deltav = 0 #parameters of rocket staticmass = int(input("What is the dry mass of the rocket in kg? ")) fuelmass = int(input("What is the mass of the fuel in the rocket in kg? ")) thrustvelocity = int(input("What is the thrust velocity of the engine used i...
682abfb3f19fe60bde02a455a448110bfe5b5073
joachimds/raspberry
/square_fixer.py
804
3.859375
4
from sys import exit from math import sqrt # Read A variable try: getal1 = float(input('A ')) except ValueError: print ("Het is geen getalletje") exit() # Read B variable try: getal2 = float(input('B ')) except ValueError: print ("Het is geen getalletje") exit() # Rea...
fe892de04ecbf1e806c4669f14b582fd1a801564
qodzero/icsv
/icsv/csv
578
4.15625
4
#!/usr/bin/env python3 import csv class reader(obj): ''' A simple class used to perform read operations on a csv file. ''' def read(self, csv_file): ''' simply read a csv file and return its contents ''' with open(csv_file, 'r') as f: cs = csv.reader(f) ...
58c8bf3e951488c0cf961ab4b4aadead3f204cd4
Dmitri00/hackerrank_problems
/week 1/swop.py
1,506
3.96875
4
def swap(arr,i,j): t = arr[i] arr[i] = arr[j] arr[j] = t return arr def bubble_sort(arr, foutput): if n < 2: foutput.write('No more swaps needed.\n') #return ['No more swaps needed.\n'] return left = 0 strs = [] while left < len(arr) : minim = arr[left] ...
dad76c97b4d6171816b64e56021b15c562dfad5b
anand004/hackerrank
/Python/Introduction to Sets.py
333
3.859375
4
def average(array): new_array=set(array) count=0 sum1=0 for i in new_array: sum1+=i count+=1 average=sum1/count return average # your code goes here if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) result = average(arr) ...
9c5588b50f93ef2de4605638cab3e829c621ca3b
anand004/hackerrank
/Python/String Split and Join.py
183
3.609375
4
def split_and_join(line): x= line.split(" ") y= "-".join(x) return y if __name__ == '__main__': line = input() result = split_and_join(line) print(result)
f26dcd75d3de055c2cd65d3c6c54e04c899714ba
akhawaja98/RobotPython
/GUI.py
634
3.671875
4
from tkinter import * class gui: def __init__(self, master): self.master = master master.title("Virtual simulator") self.label = Label(master, text="Welcome to our virtual simulator") self.label.pack() self.greet_button = Button(master, text="Start", command=self...
c29b3d17cf6ccafb9c6f22b26057824745eb1ea1
Arko-p-Moitra/TicTacToe
/Tic tac Toe.py
4,418
4.34375
4
#This function will display the board def display_board(board): i=0 while i < len(board): print ('{} | {} | {}'.format(board[i],board[i+1],board[i+2])) print('---------') i = i +3 #This function will take input from user regarding the mark def player_input(): marker='' while...
95bab4811ba29854a3b44d32a2aee725866cdce7
mrmittag/Introduction-to-Programing
/Projects/project_6/rock_paper_scissors_0.py
1,092
4.0625
4
from random import randint play = True moves = ["rock","paper","scissors"] while play == True: user_choice = input("What is your choice: rock, paper or scissor") random_number = randint(0,2) computer_choice = moves[random_number] if user_choice == "rock": if computer_choice == "rock": win = False tie = T...
2f10aa6c85ff0c353531e1c965c41b140a1e7a51
mrmittag/Introduction-to-Programing
/Projects/project_2/snake_4b.py
1,665
3.890625
4
import curses import time screen = curses.initscr() screen.border() screen.nodelay(1) screen.keypad(1) direction =0 game_over =False head=[1,1] def processInput(direction): """This function processes any user input""" userinput = screen.getch() if userinput == curses.KEY_UP: direction = 3 ...
32a16495f550cabcab3ce799921e458b7d0e939f
manishadhakal/manu
/if_statement.py
101
4
4
age=input("enter your name:") age=int(age) if age>=18: print("your are eligible for dance party")
b81f9f1046ed75b5f84f8578913b48fd08fe77e4
stickhero23/CS313E
/Triangle.py
2,499
3.8125
4
# returns the greatest path sum using exhaustive search def exhaustive_search (triangle, index, i, b, c): if i == (len(triangle)): b.append(c) else: c += triangle[i][index] return exhaustive_search(triangle, index, i + 1, b, c) or exhaustive_search(triangle, index + 1, i + 1, b, c) # returns t...
fb923903d9aadc71cb40c9200c3ca0dafdd066c1
stickhero23/CS313E
/Nim.py
1,204
3.734375
4
#helper functions in order to get nim_sum def nim_sum(list_nums): exclusive_sum = 0 for i in list_nums: exclusive_sum = exclusive_sum^i return exclusive_sum def nim_sum_heaps(nim_sum, list_nums): for i in list_nums: num_sum_heaps = nim_sum^i if num_sum_heaps< i: move = i - num_sum_...
a549bd64dc0b726d9aa8b8e0f08e7411700fa9fa
aha1464/lpthw
/ex19.py
1,537
4
4
# LPTHW EX19 # comment out 1 line """ comment out multiple lines""" """ Variables in the function are not connected to the variables in the script defined variables below """ def cheese_and_crackers(cheese_count, boxes_of_crackers): print(">>> cheese_count=", cheese_count, "boxes_of_crackers=", boxes_of_crackers)...
8b9059649cbaad48bb6b53fa8a4624eb9b5819a9
aha1464/lpthw
/ex21.py
2,137
4.15625
4
# LPTHW EX21 # defining the function of add with 2 arguments. I add a and b then return them def add(a, b): print(f"ADDING {a} + {b}") return a + b # defining the function of subtract def subtract(a, b): print(f"SUBTRACKTING {a} - {b}") return a - b # defining the function of multiply def multiply(a,...
6345bac40a37f7811ffd2cf6b011e339bdd072f7
aha1464/lpthw
/ex16.py
1,371
4.25
4
# import = the feature argv = argument variables sys = package from sys import argv # script, filename = argv # printed text that is shown to the user when running the program print(f"We're going to erase (filename).") print("If you don't want that, hit CTRL-C (^c).") print("If you do want that, hit RETURN.") # input =...
992a1523de805e2fd0d0716cfb9fe02d8edc5cfc
Sindhu1024/python_28
/Activity_05.py
139
4.1875
4
num = input("Enter 5 numbers") num1 = num.split(' ') sum = 0 for i in num1: sum = sum + int(i) print("The sum of the numbers:",sum)
abe3bad19c62b4a46629664b4b6ced60284e0b7e
taskj/JPyDemo
/Python基础/函数/闭包的概念.py
465
3.75
4
def outer(): x = 10 #在外部函数里定义了一个变量x,是一个局部变量 def inner(): #在函数内部如何修改外部函数的局部变量 #x = 20 不是修改外部的x变量,而是在inner函数内部又创建了一个新的变量x nonlocal x #此时,这里的x不再是新增的变量,而是外部的局部变量x y = x + 1 print('inner里的y=',y) x = 20 return inner() outer()()
516131674444caac28a69e3fef0e891e6dbf4467
taskj/JPyDemo
/Python基础/列表/删除列表中空字符串.py
385
3.890625
4
# 删除列表中的空字符串 words = ['hello','good','','','yes','ok',''] ''' 在用for...in遍历列表时,最好不要进行增加和删除操作,删掉元素后会漏掉 for word in words: if word == '': words.remove(word) print(words) ''' i = 0 while i < len(words): if words[i] == "": words.remove(words[i]) i -= 1 i += 1 print(words)
c8b1f88c16a239d2053e66fb2ede3dd65a3fe141
taskj/JPyDemo
/Python基础/函数/sort方法的使用.py
912
4
4
#有几个内置函数和内置类,用到了匿名函数 nums = [4,8,2,1,7,6] # nums.sort() # print(nums) ints = (5,9,2,1,3,8,7,4) #sorted内置函数,不会改变原有数据,而是生成一个新的结果 x = sorted(ints) print(ints) students = [ {'name':'zhangsan','age':14,'score':98,'height':198}, {'name':'lisi','age':13,'score':38,'height':23}, {'name':'wangwu','age':12,'score'...
5e8ef378032daa50cb181e7bbc60f8dfe45578b0
taskj/JPyDemo
/Python基础/字典/集合运算符的使用.py
462
3.5625
4
first = {'李白','白居易','李清照','杜甫','王昌龄','王维','孟浩然','王安石'} second = {'李商隐','杜甫','李白','白居易','岑参','王昌龄'} third = {'李清照','刘禹锡','岑参','王昌龄','苏轼','王维','李白'} ''' set 支持多数运算符 ''' print(first - second) #求 a-b 的差集 print(first & second) #求 a和b 的交集 print(first | second) #求 a和b 的并集 print(first ^ second) #求 a和b差集的并集
b1fbb0504fca2758d7b7f6db9b5b4f4687543fb8
taskj/JPyDemo
/学生教师管理系统GUI/fileoperator.py
1,771
3.75
4
class Files: def __init__(self): #记录学生信息的文件路径 self.student_path = "student.txt" #记录教师信息的文件路径 self.teacher_path = "teacher.txt" #定义学生存储所用的List self.list_student_all = [] #定义老师存储所用的List = [] self.list_teacher_all = [] self.read_from_file() ...
1f625f7f2db037ae82f776445e49792cd8afc2ff
jonbugge4/Numpy
/MyArrays2.py
1,703
3.65625
4
import numpy as np #Rows - Each Student (Student0, Student1, Student2, Student3) #Columns - Each Test (Test0, Test1, Test 2) grades = np.array([[87,96,70], [100,87,90], [94,77,90],[100,81,82]]) student1 = grades[1] #row, column student0_Test1 = grades[0,1] #Upper bound is not included so we do 2 instead of 1 student...
9305b966fab8a9168824705a1ec00ebe02734b84
cabudies/Python-8-September-2018
/Python/sample_module_addition.py
93
3.5
4
def add(a,b): result = a+b print("Addition result of ", a, " & ", b, " is: ", result)
eedb176bbeb1f4e21c7e4906bff3dd56b51cc3e9
gauravdargan66/Portfolio
/pycrypto/pymysql/main.py
773
3.734375
4
import sqlite3 con = sqlite3.connect("mycompany.db") cObj = con.cursor() cObj.execute("CREATE TABLE IF NOT EXISTS employees(id INTEGER PRIMARY KEY, name TEXT, salary REAL, department TEXT, pposition TEXT)") con.commit() def insert_value(id, name, salary, department, position): cObj.execute("INSERT INTO ...
a354c2e85f0b0e053b84709a7d587fdc466bf723
gauravdubey7/ATM
/ATM_code.py
1,011
3.9375
4
input("Welcome to 'AXIS BANK ATM'. Press 'ENTER' to continue. ") input("Swipe your card. Press 'ENTER'. ") option = ['Balance enquiry','Withdraw money','Quit'] pin_no = 1000 pin_no = input("'ENTER' your pin to proceed:") try: if pin_no = 1000: print('Type your option from the following:') print('1.Balance enq...
7c12d040923e2a69f3dfef2ca28c119369cd6963
sebastianfrasic/Arenas-PIMO
/Bono parcial 1/intercambios.py
1,124
3.671875
4
from sys import stdin def unir(low,high,lista): contador_final = 0 if high > low+1: mid = low + ((high-low)//2) contador_final = unir(low,mid,lista) + unir(mid,high,lista) + Merge_Sort(low,high,mid,lista) return contador_final def Merge_Sort(low,high,mid,lista): contador = 0 i = 0 ...
9554510fb037061639b3f9b8441d3be5bf3d7942
huier522/test
/2-input.py
149
3.609375
4
name = input('請輸入名字:') print('Hi,', name) height = input('請輸入身高: ') weight = input('請輸入體重: ') print(height, weight)
2277df744b6ba8dd5a19cb1456ad0b7fc342cdc8
killedman/PythonPracticeQuestions
/write_city_data_to_excel.py
853
3.5
4
#! /usr/bin/env python # -*- coding: utf8 -*- # author: dreampython # date: 2018-10-23 # 第 0015 题: 纯文本文件 city.txt为城市信息, 里面的内容(包括花括号)如下所示: # 请将上述内容写到 city.xls 文件中 # 步骤1: 读取city.txt中的数据 # 步骤2: 创建excel对象 from openpyxl import Workbook import json def read_txt_file(): with open('./city.txt','r',encoding='utf-8-sig')...
9ac67c124324b7a64f5378305c7ed9a011485571
killedman/PythonPracticeQuestions
/replace_sensitive_word.py
1,309
3.703125
4
#! /usr/bin/env python # -*- coding: utf8 -*- # author: dreampython # date: 2018-10-23 # 第 0012 题: 敏感词文本文件 filtered_words.txt,当用户输入敏感词语,则用 星号 * 替换, # 例如当用户输入「北京是个好城市」,则变成「**是个好城市」。 def read_senstive_word(): words = [] with open('./filtered_words.txt', 'r', encoding='utf8') as file: content = file.read...
466111f9e693b5b225d344cd59dc0386dbf48313
nhaantran/python
/3.Chuoi~2.py
1,080
3.53125
4
'''chuỗi trần''' print('Haizz, mình thích mấy \ngay này') print(r'Haizz, mình thích mấy \ngay này') #toán tử cộng strA = "Nhân Trần\n" strB = "lớp 12a2" strC = strA + "\n"+ strB print(strC) #toán tử nhân strC = strA*2 + strB*2 print(strC) #toán tử in (true hoặc false) a = "abcdef" b = "g" c = b in a p...
19dfc6fe1c4839f0e5828eb46f5535eb071bd5f6
nhaantran/python
/1.Fraction.py
164
3.8125
4
from fractions import* frac=Fraction(1,3) print(frac) print(type(frac)) frac1=Fraction(7,5) frac2=Fraction(6,8) print(frac1 + frac2) a= 3 b= 2 print(a**b)
8744455703ae7e9da09783a887d2c1a82215aa7f
nhaantran/python
/abc.py
608
3.59375
4
waytosucceed= ['learn','relax','enjoy','experience'] print('These are the steps to help you succeed') for steps, advice in enumerate(waytosucceed,1): print(steps,'is', advice) print('------------------------------------------------') List = ['avocado','sweet potato','salmon','chocolate','rice','broccoli'] Lst...
bd0139736354ec0f30ae72ae2b6ebd865ee52fac
abhinav-garg/Developer
/Project Euler/sumPrime.py
200
3.765625
4
def isPrime(n): for i in range(2, n): if n%i == 0: return False return True count = 0 i = 2 s = 0 while i <= 2000000: if isPrime(i): count += 1 s += i print '#', count, i i += 1 print s
4a0469e2370d8e6b762051f6caa1072170f7c9b1
RanaAqib/pythonclass
/main.py
62
3.65625
4
r=3 area=3.14*r**2 print('Area of Cicle is: '+str(area))
c4e61b7613fabe1e1b2412054b2547e850e6357c
svudya/ML_code
/logisticRegGradDesc.py
1,323
3.625
4
import numpy as np import matplotlib.pyplot as plt def step_gradient(thet, points,learning_rate): thet_grad = 0 new_grad = 0 N = float(len(points)) for i in range(len(points)): y = points[i,0] x = points[i,1] if np.isnan(x) or np.isnan(y) : pass else : thet_grad += -1/N * (np.log(1+np.exp((-y)* thet...
a2b20fc074c95160960b3406c6869ff2e33a93d4
smadhuvarsu/Python
/Rock,Paper,Scissors.py
2,104
4.0625
4
import random moves=["r","p","s"] cscore=0 uscore=0 tscore=0 name=input("What is your name:") print() print("Hi",name.title(),"! Are you ready to play rock,paper scissors? Good! If you want to do rock,enter 'r'.If you want to do paper,enter 'p'.If you want to do scissors,enter 's'.Your oppenent will be the c...
113476d2e6849d536db1135fe007102d7fb8a444
happyliang20211013/machine-learning-Andrew
/ex1_linear_regression/linear_regression_with_one_variable.py
1,987
3.59375
4
import matplotlib.pyplot as plt if __name__ == "__main__": # Part1:从txt文件中读取数据,绘制成散点图 f = open("ex1data1.txt", 'r') population = [] profit = [] for line in f.readlines(): col1 = line.split(',')[0] col2 = line.split(',')[1].split('\n')[0] population.append(float(col1)) ...
b49d797270cc2edd022b4304129cbd42f117f692
dreamofwind1014/gloryroad
/练习题/2020.06.19练习题--赵华恬.py
2,726
3.875
4
# 练习176:写一个函数,识别输入字符串是否是符合 python 语法的变量名 # (不能数字开头、只能使用数字和字母以及‘_’) import string # # def check_var(var): # if var[0] in "0123456789": # isdigit() # return False # for v in var: # if not (v in string.ascii_letters or v in string.digits or v == "_"): # not( v.isalnum() or v == "_"): # ...
3e9cb9d8ca2c3f1b238e8709bc2922752e716ccb
dreamofwind1014/gloryroad
/练习题/2020.06.17练习题--赵华恬.py
4,077
4.125
4
# 练习166:检测密码强度 """ c1: 长度 >= 8 c2: 包含数字和字母 c3: 其他可见的特殊字符 强:满足c1, c2, c3 中: 只满足任一2个条件 弱:只满足任一1个或0个条件 """ # # import operator # import string # # # def check_len(s): # if len(s) >= 8: # return True # else: # return False # # # def check_digit_letter(s): # digit_flag = False # letter_flag =...
82cd3bd561827ba6e8988ac7a7ae18c9680a4665
dreamofwind1014/gloryroad
/练习题/2020.06.21练习题--赵华恬.py
2,471
3.984375
4
# 练习186:将"gloryroad"按照如下规则进行加密:字母对应的asscii码值进行加密, # 并且在码值前面加上码值长度,如g对应的码值为ord("g") = 103, # 则字母g加密结果为31033是ascii的长度。“gloryroad”正确输出加密结果为: # "31033108311131143121311431112973100" # def encode_str(s): # result = [] # for v in s: # item = str(len(str(ord(v)))) + str(ord(v)) # result.append(item) ...
fd27267b5ea5cfe6c625d03dcecb10f061179f3f
dreamofwind1014/gloryroad
/练习题/2020.06.14练习题--赵华恬.py
2,798
3.734375
4
# 练习151: 用推导列表求所有数字key的和 # d = {1: 'a', 2: "b", "a": 3} # sum([k for k in d if isinstance(k, (int, float))]) # # 3 # 练习152:"abcdefgh"里面挑出3个字母进行组合,一共有多少种组合, # 要求三个字母中不能有任何重复的字母,三个字母的同时出现次数, # 在所有组合中只能出现一次,例如出现abc了,不能出现cab和bca等 # s = "abcdefgh" # result = [] # temp_list = [] # for k in s: # for v in s: # for ...