blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a6e995b5c2a43fbf7938761143ac76512137afc4
Komal123Singh/notes
/inter.py
641
4
4
#Factorial n=3 def factorial(n): if n==1: return 1 else: return n*factorial(n-1) print(factorial(n)) #armstrong n=153 s=n r=0 while n!=0: d=n%10 n=n//10 r=r+d*d*d if s==r: print("Armstrong") else: print("not armstrong") #Palindrome n=163 p=n r=0 ...
e8b60a3b009ea53f31f9a784856bd44ba4776102
alexandraback/datacollection
/solutions_5738606668808192_0/Python/naruaway/main.py
996
3.53125
4
import random import math def divisor(n): if n == 1: return 1 if n == 2: return 1 if n == 3: return 1 for d in range(2, min(n, 100)): if n % d == 0: return d return 1 def build_number(r, base, n): num = 1 + base ** (n - 1) for i in range(1, n - 1...
948fbf5caf7c9ae51918a0f83c920e05b4ec7f74
MatiasTieranta/OOP
/Exercise 3/CoinToss.py
2,360
4.21875
4
# File: CoinTossingGame # Author: Matias # Description: Flipping coin game import random class Coin: # The__init__ method initializes the sideup data attribute with 'Heads' and 'euros' def __init__(self): self.__sideup = 'Heads' self.__currency = 'Euro' # The toss method generate a rando...
6e8064d61f2ccb2f3b3a1898ccd366d9e2e22a6f
hlatki/coding-dojo
/game_of_life/akiesler/life.py
2,446
3.59375
4
#!/usr/bin/env python import sys DEAD, ALIVE = range(2) # play with these and lets see what happens neighbor_range = (-1,1) stay_alive = (2,3) birth = 3 class Life: def __init__(self, size, board): self._board = board self._size = size def getNeighbors(self, x, y, rng=neighbor_range): ...
23a5fd1a8157397de60046e8396c814f14c2fe83
larsnohle/57
/11/eleven.py
991
3.984375
4
import math def get_positive_number_input(msg, to_float = False): done = False while not done: try: i = -1.0 if to_float == True: i = float(input(msg)) else: i = int(input(msg)) if i < 0: print("Please enter...
fabaecbb957750253b213459bf9b71b8e3f6c6ad
ynrng/leetcode
/done/350_Intersection_of_Two_Arrays_II.py
465
3.640625
4
class Solution(object): @staticmethod def intersect(nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ s = set(nums1).intersection(set(nums2)) inter = [] for i in s: inter.extend([i]*min(list(nums1).c...
90c9e52acb09a2796509a98bb75970aec271e61c
mbuon/Leetcode
/763. Partition Labels.py
980
3.5625
4
# Input: S = "ababcbacadefegdehijhklij" # Output: [9,7,8] # Explanation: # The partition is "ababcbaca", "defegde", "hijhklij". # This is a partition so that each letter appears in at most one part. # A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits S into less parts. # https://leetcode....
fe5473ea4d5e0fcf9d64f412d1ea92e845370636
kszymankiewicz/Python3-basic-to-master
/list/operacjeifunkcjenalistach.py
438
4
4
#len() - długość - length #.append - dodać #.extend - rozszerzyć #.insert(index, co) - wstawić #.index - indeks danego el. #sort(reverse=False) - sortuj rosnąco #max() #min() #.count - ile razy coś wystąpi #.pop - usuń ostatni el. #.remove - usuń pierwsze wystąpienie #.clear - wyczyść liste #.reverse - zamień kolejność...
865318bee8f7809f0ac1deec5ea6bd13aaf2694e
SirMullich/pp2-spring-2020
/pygame-lectures/tanks-draft.py
4,317
3.765625
4
import pygame class Tank: # speed instead of dx, dy def __init__(self, x, y, width, height, speed): self.x = x self.y = y self.width = width self.height = height self.speed = speed self.direction = 1 # 1 - up, 2 - down, 3 - left, 4 - right def update_locatio...
53954916303cf02394d5c6cf09d0a83036a6b278
dhruvparekh008/ES102project
/zombieland1.py
11,185
4.15625
4
#Creating An Introduction print("\nWELCOME to the Text Based Adventure Game-->Zombie Land") print("\nYou are a brave fighter and protector of the magical lands of the Black Village") print("\nI am Jojo the talking dog and I will guide you through the whole game ") print("\nThis game will test your imagination. Keep not...
47f9bff6762f7a38e01e438be8751f9644e8d623
misrashashank/Competitive-Problems
/buy_and_sell_stocks.py
1,741
3.90625
4
''' Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. Example 1: ...
d788e6fefdc13e884e1c4ec31fa9e50369ab5fe6
jerrytnutt/Automate-the-Boring-Stuff-Project-Solutions
/CH13-Working-With-Excel-Spreadsheets/multiplicationTable/multiplicationTable.py
1,194
4.09375
4
# Create a program that takes a number N from the command line # Creates an N×N multiplication table in an Excel spreadsheet. from openpyxl import Workbook from openpyxl.styles import Font import sys def create_table(n): workbook = Workbook() sheet = workbook.active n = int(n) # Add 2 to n on account of fir...
c656e54bb589668b3b9ddb4cadd2735195e9329f
feliperobledo/manatee_escape
/src/utils/colors.py
725
3.71875
4
class Color: def __init__(self, r=0, g=0, b=0, a=0): self.r = r self.g = g self.b = b self.a = a @property def rgb(self): return (self.r, self.g, self.b) @property def rgba(self): return (self.r, self.g, self.b, self.a) def __str__(self): ...
bd7afb02e7659dc92b45a3d2615e7bade6942667
hinbody/python_examples
/namespaces/name_scopes.py
958
4.09375
4
# define global variable my_var = 10 def make_vars(): my_stuff = 20 # print local variable print(my_stuff) # print global variable print(my_var) class Our_vars: def __init__(self, var1, var2): # assign class variable from new obj arg self.var1 = var1 # assign class vari...
dfc3c5da2dfb4394833b73ae4a46e8565003b8f1
SOURADEEP-DONNY/PYTHON-3-PROGRAMMING
/PYTHON FUNCTIONS FILES AND DICTIONARIES/week 4/BREAK & CONTINUE STATEMENTS.py
319
4.09375
4
#BREAK STATEMENT i=0 while i<=10: if i==5: break print(i) i=i+1 #WHEN THE CONDITION MATCHES THE BREAK STATEMENT THE PROGRAM COMES OUT FROM THE LOOP CONDITION. print('\n\n') #CONTINUE STATEMENT i=0 while i<=10: if i==5: continue print(i) i=i+1
ef426a4e507abe2c79d2fbfb1254338170d78417
A8IK/PYthon-3
/class in class.py
520
3.84375
4
#outer class class Student: def __init__(self,name,roll_number): self.name=name self.roll_number=roll_number self.lap=self.Laptop def show(self): print(self.name,self.roll_number) #inner class class Laptop: def __init__(self): self.bra...
f8e63e22a82c9a05672dbefb096f3c4498925183
WhiteRobe/ShuaTi
/leetcode/linklist/两数相加2.py
1,413
3.734375
4
""" 题目来源: LeetCode @See https://leetcode-cn.com/problems/add-two-numbers/ 题目序号 2 题目描述: 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 思路: 注意代码的鲁棒性即可,要防止 5 + 5 这种只算到 5 而忘了进位的情况 样例输入: 输入:(2 -> 4 -> 3) + ...
0339a143eeeaf10360675edce1153213c83979b8
dasherinuk/classwork
/pairs_claaswork_6.4.py
223
3.578125
4
n = int(input()) arr=[] for i in range(n): arr.append(int(input())) arr_pairs = [] for i in range(0, n-n%2, 2): arr_pairs.append([arr[i],arr[i+1]]) if n%2==1: arr_pairs.append([arr[-1],0]) print(arr_pairs)
3e1eadc54e18dc815da5c5eb8bbf9a5986ddacaf
JPWS2013/SoftwareDesign
/chap16/double_day.py
3,229
3.59375
4
import datetime as dt def dayofweek(): days=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] dateToday=dt.date.today() dayofWeek=dateToday.weekday() return days[dayofWeek] def birthday(birthdate): t=birthdate.split('/') bday=dt.date(int(t[2]), int(t[1...
b0522cf36195f6e573d7da25965bda85c38beadf
aannddrree/projaulapython170321
/ex7.py
150
3.640625
4
frutas = ["pera", "morango", "banana","maca", "uva", "amora"] frutas[0] = "Sei la" frutas.sort() for f in frutas: print(f) print("Terminei")
ec7a3ae8111108a6307258d90965f017f1370be7
himanshu98-git/python_notes
/DataStructuure/task.py
363
4.125
4
words=["orange","banana","apple","orange","papaya","apple","banana","orange","papaya","orange","banana","orange","apple","papaya"] str="Hi my name is Himanshu" str1=" " from collections import Counter word_counts =Counter(words) top_three=word_counts.most_common(3) print(top_three) spaces=str.isspace() space=st...
01a3db43411eb16679fc0b4b83f0370ff323b9e1
RaghvendraPateriya/algo
/tree/tree_traversal.py
2,292
4.03125
4
""" Print Tree Level Wise: Given Tree: 1 <= level 0 / \ 2 3 <= level 1 / \ / \ 4 5 6 7 <= level 2 Output: 1 2 3 4 5 6 7 """ class Tree: def __init__(self, data, left=None, right=None) -> None: self.data = data...
80f353fac23277e1e967c04a8a16853dc5ffe5f3
argriffing/xgcode
/DiscreteEndpoint.py
15,598
3.734375
4
""" Condition a Markov chain on its endpoints. The Markov chain is discrete and first order. Find the expected number of transitions. """ import unittest import itertools import math import numpy as np import Util import StatsUtil import TransitionMatrix import HMM import iterutils def get_expected_transitions_br...
c90678d55ee5b9f93592088ff86e0d1f742306b8
jakeTran42/CS-2-Tweet-Generator
/rearrange.py
613
3.640625
4
import random import sys # words = ['time', 'space', 'antimatter', 'universe', 'neutron'] words = sys.argv[1:] def create_random_quote(): word = [] num_already_used = [] counter = 0 while counter < len(words): rand_index = random.randint(0, len(words) - 1) if rand_index not in num_alre...
17a1a2373d96a9af3ba25106819eea54ad4e4b41
andreamena/Girls_Who_Code2
/turtle4.py
608
4.1875
4
from turtle import * import math alex=Turtle() alex.pensize(10) alex.turtlesize(4,4) pendown() def drawShapes(turtle,sides,color): turtle.pencolor(color) drawnSides = 0 sides = sides+1 angle = 360/sides turtle.speed("slow") while drawnSides < sides: turtle.forward(50...
ca53c4e005e8c0b699944da5b46d2512f6216cde
ElizaLo/Practice-Python
/Python 3 Programming/course 2/c_2_ex_4.py
1,437
4.21875
4
''' Write a function called int_return that takes an integer as input and returns the same integer. ''' def int_return(x): return x ''' Write a function called add that takes any number as its input and returns that sum with 2 added. ''' def add(num): return num + 2 ''' Write a function called change that ta...
225492ddd62ba73a80a7b3a45b72e0efcc069a85
MelihCelik00/GEO106E
/geo106e_lab projeler/LabWork4/010180519_labwork4.3.py
284
3.625
4
months1_519 = ("January","February","March","April","May","June") months2_519 = ("July","August","September","October","November","December") all_months_519 = months1_519 + months2_519 print(all_months_519) print(all_months_519.index("June")) print(all_months_519.index("August"))
98166987ddd2c9c7ea30f39450960eecd0c7b52e
Xiankai-Wan/Python-Quiz-Summarize
/Python-语法/Part2/2-15_创建程序段2.py
622
4.15625
4
# 练习:创建帮助函数 sum_of_middle_three # 现在是时候完成 sum_of_middle_three 这个函数了。确保使用打印语句测试该函数。可以根据之前编写的框架开始。你可以使用 max() 和 min() 查找最大值和最小值。max() 返回一组数字中的最大值,min() 返回最小值。例如: # max(1,2,3,4) #returns 4 # min(1,2,3,4) #returns 1 def sum_of_middle_three(score1,score2,score3,score4,score5): return (score1 + score2 + score3 + score4 +...
4b94b2efcada09f4ba4bb55fa089b97dc1fcdb5c
lucastrindadesilva/aulasProgramacao
/Aula 2/selecao_repeticao.py
202
3.609375
4
bruno = 29 sosnierz = 36 lucas = 30 booleano = True if bruno > sosnierz: if bruno > lucas: print("O mais velho é Bruno") else: print("O mais velho é Lucas") #construam o else
d34c980651fb83e0dc8a959191ff72da8dfd21bf
silverdoe23/python-lessons
/binaryNumbers/binaryIteration.py
910
4.125
4
#!/usr/bin/python def isBinary(x): #this function will determine if the number inputed is a binary number for a in x: if a != 0 and a != 1: print('please input a valid binary number. Try again.') return False return True def valueBinary(x):#this function will determine the val...
39d587042b81f1800dee7f42a0a1c7c94bd9841a
Fbocciii/Python-Training
/AdvancedPython-2-Assignment1.py
3,759
4.15625
4
# 1. Create a Python Generators to generate the vowels. This should be a cyclic generators and will generate infinte list of vowels. # ------------- # 2. Let's imagine a scenario where we have a Server instance running different services such as http and ssh on different ports. Some of these services have an active sta...
f9169420d4e112349487da508a8c9b3f138c1552
darrencheng0817/AlgorithmLearning
/Python/sorting/exercise/countInversions.py
755
3.515625
4
''' Created on 2015年12月10日 @author: Darren ''' global count count=0 def mergeSort(nums): if len(nums)<=1: return nums m=len(nums)//2 return merge(mergeSort(nums[:m]),mergeSort(nums[m:])) def merge(nums1,nums2): index1,index2=0,0 res=[] global count while index1<len(nums1) and inde...
2cb59a8eeb377d2e06641d1792292e63d0ab92bd
lishuang1994/-1807
/01day/09-文件备份系统.py
383
3.9375
4
#1.获取用户要复制的文件名 old_file_name = input("请输入要复制的文件名") #2.打开要复制的文件 old_file = open(old_file_name,"r") #3.新建一个文件 new_file = open("新建.txt","w") #4.从旧文件中读取数据,并且写入新的文件中 content = old_file.read() new_file.write(content) #5.关闭两个文件 old_file.close() new_file.close()
7f18652d181d1cd6e325185746b17ced0885ece3
Rad-wane/FreeCodeCamp-certification-projects
/'Data science with Python' certification/Sea-level-predictor/sea_level_predictor.py
1,018
3.78125
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy import stats def draw_plot(): # Read data from file df=pd.read_csv('epa-sea-level.csv') # Create scatter plot plt.plot(df['Year'],df['CSIRO Adjusted Sea Level']) # Create first line of best fit slope, ...
9848dbbca48711584e75370b4fc4f99ce1893362
RitaWxy/PythonBase
/codeExercise/syntaxTree.py
379
3.609375
4
Num = lambda env,n : n Val = lambda env,x : env[x] Add = lambda env,a,b : _eval(env,a)+_eval(env,b) Mul = lambda env,a,b : _eval(env,a)*_eval(env,b) _eval = lambda env,expr : expr[0](env,*expr[1:]) env = {'a':3,'b':6} tree = (Add,(Val,'a'), (Mul,(Num,5),(Val,'b')) ) print(_eval(env,(Val,'a'))) print(_...
5daa73b09c99893a77cc347b27fa1247f28cf3f9
ashermanwmf/test
/ex6.py
989
4.3125
4
# writing a string with a number in it x = 'There are %d types of people.' % 10 # creating a string variable binary = 'binary' # creating a string variable do_not = "don't" # created a string and added two other variable strings y = 'Those who know %s and those who %s.' % (binary, do_not) # printed both x and y variab...
9b22594ed01eacfad1bd1b9d1bbc5818e1d1481e
pocceschi/aprendendo_git
/operadores/exretangulo.py
268
3.78125
4
b = float(input("Base do retangulo: ")) a = float(input("Altura do retangulo: ")) area = float(a*b) perimetro = float(a+a+b+b) diagonal = float((a**2 + b**2) ** 0.5) print(f"Area: {area:.4f}") print(f"Perimetro: {perimetro:.4f}") print(f"Diagonal: {diagonal:.4f}")
8de78b297005e2bdc058c29503fb0f2f88c65807
asariakevin/timetable-comparison-app
/main.py
2,758
3.8125
4
from timetable import TimeTable timetable1 = TimeTable() timetable2 = TimeTable() timetable1.monday = ["7 to 12" , "13 to 15", "16 to 18"] timetable2.monday = ["8 to 10" , "14 to 16" , "17 to 18"] NUMBER_OF_HOURS = 11 hour_taken_array = [] # initialize hour_taken_array to zeros for one_hour_period in range(NUMBER_O...
bfff47c86361065344d66e90c20cbc1262ea0831
brettlod/flicklist-python
/crypto/initials.py
447
4.09375
4
def get_initials(fullname): initial = fullname[0] found = False for letter in fullname: if found is True: initial = initial + letter found = False elif letter == " ": found = True else: initial = initial return initial.upper() def ...
9e405be15c83aa24524158a6fe3fa8d1f3413974
OverCastCN/Python_Learn
/XiaoZzi/Practice100/17StringClassify.py
472
3.921875
4
# -*- coding:utf-8 -*- import string """ 题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。 """ aplha = 0 space = 0 num = 0 other = 0 a = raw_input() for i in a: if i.isalpha(): aplha += 1 elif i.isspace(): space += 1 elif i.isdigit(): num += 1 else: other += 1 print '中英文字母:',aplha pri...
5d9d6fc814a78ec2ed128c42543c39d991683d38
DakotaDecker/cis1415
/Chapter 7: Additional Exercise 5.py
3,869
3.734375
4
user = input('Enter a phone number in the format XXX-XXX-XXXX:\n') print('You entered:', user) user = user.upper() user = user.replace('A', '2') user = user.replace('B', '2') user = user.replace('C', '2') user = user.replace('D', '3') user = user.replace('E', '3') user = user.replace('F', '3') user = user.repl...
902a32bf028b4ee195a1f4ad32d4232aac643c6e
chenxy3791/leetcode
/No0876-middle-of-the-linked-list.py
2,889
3.875
4
""" 876. 链表的中间结点 给定一个带有头结点 head 的非空单链表,返回链表的中间结点。 如果有两个中间结点,则返回第二个中间结点。 示例 1: 输入:[1,2,3,4,5] 输出:此列表中的结点 3 (序列化形式:[3,4,5]) 返回的结点值为 3 。 (测评系统对该结点序列化表述是 [3,4,5])。 注意,我们返回了一个 ListNode 类型的对象 ans,这样: ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, 以及 ans.next.next.next = NULL. 示例 2: 输入:[1,2,3,4,5,6] 输出:此列表中的结点 4 (...
2c709afde8adea6987bb824e3657e3b5e393b8a3
sagar104511/spe
/Calculator.py
223
3.765625
4
def sum(a,b): return a+b def diff(a,b): return a-b def multiply(a,b): return a*b def divide(a,b): return a//b if __name__ == "__main__": print(sum(4,2)) print(diff(4,2)) print(multiply(4,2))
9e47bc6c049a19db25b8faf2999ab10d29beb158
saiakhil0034/cse253
/assignments/hw2/PA2/test.py
385
3.515625
4
class B(object): """docstring for B""" def __init__(self, arg): super(B, self).__init__() self.arg = arg self.c = [1, 2] class A(object): """docstring for A""" def __init__(self, arg): super(A, self).__init__() self.arg = arg self.b = [B(arg), B(arg + ...
d9ce7a58f4f41c39ab0e1bbefb092b71c222ea4b
kangwonlee/15ecab
/wk02/use_sequential.py
181
3.734375
4
# -*- coding: cp949 -*- import root_finding def f2(x): return float(x*x) - 3.0 print root_finding.sequential(f2, 0.01) print root_finding.sequential(root_finding.func, 0.01)
4a7b5d782dbe376fccee9fe230df8aaf2b8fb0de
Priyansh2906/cryptographic-algorithms
/Playfair.py
3,491
3.78125
4
import numpy as np key = input("Enter a key : ") rectified_key_letters = "".join(dict.fromkeys(key)) #removes all duplicate letters alpha=[chr(i) for i in range(97,123)] #Generates a list of all alphabtes key_letters = [] #List of letters included in key so that we can know remaining letters to add into 5x5 matrix ...
c284d3231f39051b27c7db6e856ea8c8fa9de65a
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/b946e078bb904b47bf67863586198872.py
661
3.984375
4
# -*- coding: utf-8 -*- import re """ Bob answers 'Sure.' if you ask him a question. He answers 'Woah, chill out!' if you yell at him. He says 'Fine. Be that way!' if you address him without actually saying anything. He answers 'Whatever.' to anything else. """ def hey(text): # Remove whitespace and check if ...
2dafa8ea5598a172064f3b41178c0b40838f259f
mbebiano/exercicios-python
/exerciciocoursera/MaiorPrimo.py
578
3.671875
4
def maior_primo(num): count = 1 acum = 0 a = 0 b = False while b==False: while count <= num: if num % count == 0: acum += 1 else: a += 1 count += 1 if acum == 2: b = True else: num =...
ac3f65a3b83083f5938a612e64ad528a12eaa497
rohitb2310/python_Programming
/Assingment1.py
500
3.515625
4
f=open("File.txt","r") ## opening the file content = f.read() ## reading the data in a variable print(content) ##printing all the content ##s="I am Rohit I am Rohit" l=content.split() ##Splitting the content dictonary={ } ##creatin the blank dictonary for word in l: if word in dictonary: ## if word is pr...
6731e03f888de7f5fd43578663fae935f513215c
daniel-reich/ubiquitous-fiesta
/5h5uAmaAWY3jSHA7k_7.py
355
3.8125
4
def landscape_type(lst): while lst[0]==lst[1]:lst=lst[1:] while lst[-1]==lst[-2]:lst=lst[:-1] l=[i[1]-i[0] for i in zip(lst,lst[1:])] if 0 in l: return "neither" l=[i>0 for i in l] if all(l) or not any(l): return 'neither' for i in range(1,len(l)-1): if l[i-1]==l[i+1]!=l[i]: return "neither" return...
0093bd5b9d8312844956f4e6ef5967f2ce989a94
Mohamed209/Python_OOP_tutorial
/LogicGate.py
2,536
3.609375
4
class LogicGate: # super class Logic Gate def __init__(self,label):# init function to set label and output self.label=label self.output=None # function to check if input is valid boolean value '''ef check_valid_input(self): assert int(input()) is bool, "0 and 1 are only valid inputs"...
2f12d891c6f56bb927463407996cd327a0b85ae7
lsgos/MPhysPulsars
/src/SemiSupervisedClassifier.py
1,400
3.65625
4
""" A class factory to abstract the creation of a semi-supervised classifier from a novelty detection method """ from sklearn.tree import DecisionTreeClassifier class SemiSupervisedClassifier(object): def __init__(self, novelty_detector, noise_label = 0): self.novelty_clf = novelty_detector self....
a79dd2293cdf8578a35653afbed338f640cd2e61
SiddharthBhawsar/Python-Bootcamp-with-OOPS
/14_FileIO_Basics.py
1,872
4.25
4
# #File IO Basics # # """ # "r" - Open File in Read Mode # "w" - Open File in Write Mode # "x" - Creates File if not exist # "a" - Add more content of file/append # "t" - Text mode # "b" - Binary Mode # "+" - Read and Write both # """ # # # #Here open function returns a file pointer and # # in our case it...
f91acf4428c7cf2467a16846ff5f463e122a90be
aishukanagaraj/exe1
/exe3/firstlast.py
281
3.78125
4
def firstdigit(n): while(n>=10): n=n//10 return (int(n)) def lastdigit(n): return (n%10) def lastfirst(n): flag=True if not(firstdigit(n)==lastdigit(n)): flag=False return flag n=input("Enter the number") print(lastfirst(n))
38e77d814161a799cfe6f61a52a009a45116cd07
AlexBardDev/Project_Euler
/euler_7.py
642
3.96875
4
""" problem: 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 K = 10001 LIST_PRIME_NUMBERS = [2, 3, 5] M = 2 while len(LIST_PRIME_NUMBERS) < K: is_prime = True MAYBE_PRIME = LIST_PRIME_...
3d126a7a28ff5bd642b48b6d2a200c63c6e5e6db
lktolon/Ejercicios-Estructura-Secuencial-Phyton
/ejercicio16.py
284
3.703125
4
v1 = float(input("Velocidad del primer vehículo:")) v2 = float(input("Velocidad del segundo vehículo):")) dist = float(input("Distancia entre ambos vehículos:")) t = dist / abs(v1 - v2) t = t * 60 print("El primer vehículo alcanzará al segundo en ", tiempo,"minutos.")
17815767dd719c5422f258b237363e857ee3723d
jothamsl/Learning_Python
/1.0/Non-Primitives/Lists/Lists.py
628
4.1875
4
# A list contains items separated by commas and enclosed within square brackets # []. Lists are almost similar to arrays in C. One difference is that all the # items belonging to a list can be of different data type. list = [21, 'Hello world!', 23.1, 'f'] list1 = ['What up', 'world'] print(list) # [21, 'Hello world!'...
22cf85f4339057fbbded653f7a95749bf9f9e7a4
Marauderer97/LSI-Internship
/Rahul-code/point_at_dist.py
1,883
3.609375
4
# to find point B on line at distance D from point A on same line import sys from sympy import * from fractions import Fraction def point_at_dist(pt1, pt2, distance): if pt1 == pt2: print 'invalid line' sys.exit() # Check for slop 0 and infinite if pt1[0] == pt2[0]: p1, p2, p3, p...
bef32217407cad77849c4c82eb2221db538bc75a
zenuie/leetcode
/reverse-integer.py
411
3.515625
4
class Solution: def reverse(self, x: int) -> int: y = str(abs(x))[::-1] if int(x) < 0: x = abs(x) x = str(x)[::-1] if 2 ** 31 - 1 > int(x) > -2 ** 31: x = int(x) - 2 * int(x) return x return 0 elif 2 ** 31 - 1 > ...
99c1ab004943351df0250aca750d53b70cd9c796
NikiDimov/SoftUni-Python-Advanced
/modules/snake_game.py
3,451
3.609375
4
import pygame import time import random pygame.init() clock = pygame.time.Clock() orangecolor = (255, 123, 7) blackcolor = (0, 0, 0) redcolor = (213, 50, 80) greencolor = (0, 255, 0) bluecolor = (50, 153, 213) display_width = 600 display_height = 400 dis = pygame.display.set_mode((display_width, display_height)) pyga...
73b86d002bb4bc66513775aa788be41b09a33733
zuobing1995/tiantianguoyuan
/第一阶段/day15/exercise/myfactorial.py
449
3.890625
4
# 练习: # 写一个生成器函数myfactorial(n)此函数用来生成n个从1开始的阶乘 # def myfactorial(n): # ... # L = list(myfactorial(5)) # L = [1, 2, 6, 24, 120] # # 1! 2! 3! 4! 5! def myfactorial(n): s = 1 # 用来保存阶乘 for x in range(1, n + 1): s *= x yield s L = list(myfactoria...
4ba78b4aeaa075137cce343ee60fcb65230be6e7
PMKeene/SoftwareDesign
/SoftwareDesignExplore/GUI_Experimentation/GUI_Hello1.py
245
3.578125
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 2 01:43:45 2014 @author: maire """ #Doesn't Display Text-- #To Fix: Make text #WWWHHHHHHYYYYYY!!! from Tkinter import * root= Tk() w=Label(root, text="Hello, world!") w.pack root.mainloop()
e8f737cbc342616e3f805115c898a560ac6ae949
KocUniversity/comp100-2021f-ps0-nevzatozh1
/main.py
177
3.65625
4
print("Enter number x: 10") print("Enter number y: 4") x=10 y=4 print("x . y=",x**y) import math print("logarithm base 2 of 10 is: ", end="") print(math.log2(10)) print("78987")
94e1cf8d1dbc5a40fce920025424bd33890ec4d3
bitwoman/curso-em-video-python
/Curso de Python 3 - Mundo 1 - Fundamentos/#029.py
396
3.953125
4
# Exercício Python 029: Escreva um programa que leia a velocidade de um carro. # Se ele ultrapassar 80Km/h, mostre uma mensagem dizendo que ele foi multado. # A multa vai custar R$7,00 por cada Km acima do limite. velocity = float(input('Enter a velocity of the car: ')) if velocity > 80: traffic_ticket = (velocity...
519cd45393e228d0f502a7dadee824ba7321a1e2
dudu9999/Exerc-cio_de_casa_01
/Exercicio 01.py
250
3.796875
4
#Ler dois numeros N1 e N2 nesta ordem e #imprimir as variaveis N1 e N2 nesta ordem ordem #de digitação N1, N2 = 0, 0 N1 = int(input("digite um numero: ")) N2 = int(input("digite outro numero: ")) print("Primeiro numero",N1,"segundo numero",N2)
51ebbaf9f347edb7b5405258f60870651f45a312
yutoo89/python_programing
/basic_grammar/indention.py
253
4.0625
4
# 80文字以上になる場合は改行するのがルール s = 'aaaaaaaaa' \ + 'bbbbbbbb' print(s) x = 1 + 1 + 1 + 1 + 1 + 1 + 1 \ + 1 + 1 + 1 + 1 + 1 + 1 + 1 print(x) x = (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1) print(x)
3eded02154416ee8ee73f226fd308056bbf86c07
TheSauceWizard/Team-A1
/arran.py
2,376
4.09375
4
import time as t print (""" I approach the man. "Hey, what brings you to this part of town?" "Please sit Detective Frankestein, we have much to discuss." My curosity compelled me to sit down. "Who are you and how did you know my name?" "My name is Chris Requiredfield. I am working with Special Tactics and Resource Ser...
39a95bcf84c8d28c96f772442811d98e443f03bf
mishu45/lang2sign
/lang2sign/utils/secrets.py
2,009
3.78125
4
""" Utility to access secrets stored in files or to input them on prompt """ # pylint: disable=unexpected-keyword-arg import os from getpass import getpass class Secret(object): """ Secret class to store and retrieve secret """ def __init__(self, name, filepath): self.name = name self....
82643189cda450671431f428882c635cbe5395d0
shuhailshuvo/Learning-Python
/16.Error.py
780
3.5625
4
import sys class Error(Exception): """Base class for other exceptions""" pass class ValueTooSmallError(Error): """Raised when the input value is too small""" pass randomList = ['a', 0, [1, 2], True] for entry in randomList: # Comon exceptions r = None try: print("The entry ...
53af1074bba2776e8cb349efcfac02febd681eab
greenlucid/oeis
/b02.py
1,587
3.65625
4
# Tomas 'Green' Roca Sanchez # b02.1 : F(n) has same number of prime factors than F(n+1), with F(a) being the Fibonacci sequence # b02.2 : The specific Fibonacci numbers # b02.3 : Number of prime factors of F(n) # Instead of having to factor these numbers, I fetched a file with the first 1000 Fibonacci factorizations #...
835aa1645294360680a9630cb9e04dd15a55a06b
eunseo5355/python_school
/lab3_4.py
703
3.9375
4
""" 사용자로부터 연도를 입력받아서, 해당 연도가 몇일로 구성되어 있는지 출력하라. 4로 나누어 떨어지면 윤년이다. 단, 100으로 나누어 떨어지면 윤년이 아니며, 400으로 나누어 떨어지면 윤년이다. 입력예) 연도: 2000 출력예) 366일입니다. """ y = int(input("연도:")) # 입력받기 if y % 4 == 0 and y % 100 != 0: print("366일입니다.") elif y % 400 == 0: print("366일입니다.") else: print("365일입니다.") """ if y%4==0: ...
5926ecdd76558ba15b643a9b10aeb6b3a2239f4d
Henry-the-junior/tictactoe_teaching_resource
/tictactoe_ep5-3.py
2,532
3.921875
4
def drawBoard(board): # This function prints out the board that it was passed. # "board" is a list of 10 strings representing the board (ignore index 0) print(' | |') print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) print(' | |') print('-----------') print(' | |') pr...
3f0fb2c7721708bb915650ed18d81d991bb70894
muskanmahajan37/programming-language-paradigms
/python_examples/heranca_multipla.py
640
3.5
4
class Figura(object): def __init__(self): print ( 'criou Figura' ) def nome( self ): print ( 'Nome da Figura' ) def __str__(self): return "< classe Figura >" class Poligono(object): def __init__(self): print ( 'criou Poligono' ) def nome( self ): print ( ...
d8f084d29799052664b4ee0c02508ade0561a95e
apple2062/algorithm
/programmers/[L2]문자열압축.py
993
3.703125
4
# abcabcdede와 같은 경우, 문자를 2개 단위로 잘라서 압축하면 abcabc2de가 되지만, # #3개 단위로 자른다면 2abcdede가 되어 3개 단위가 가장 짧은 압축 방법 # "ababcdcdababcdcd" -> 9 # "abcabcdede" -> 8 # "abcabcabcabcdededededede"-> 14 def solution(s): # 1부터 length/2 까지가 단위(step) 이 됨 wording = "" size = len(s) // 2 ans = [] for i in range(6, size + 1): ...
a871cea8c59b7468d5f543bf7d285af4eca8fd21
veratsurkis/infa_2020_postnikov
/lab2_1/ex12.py
429
3.5625
4
import turtle as tr import numpy as np tr.shape("turtle") def arc(x,y,r,angle_1,angle_2): tr.penup() tr.goto(x+r*np.cos(angle_1*np.pi/180),y+r*np.sin(angle_1*np.pi/180)) tr.pendown() for i in range(angle_1,angle_2+1,1): tr.goto(x+r*np.cos(i*np.pi/180),y+r*np.sin(i*np.pi/180)) r = 100 x_1 = -3*r...
f2fd66e59c2d9481684b04a84f31b5ab4290a564
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/jason_jenkins/lesson03/list_lab.py
3,230
4.375
4
#!/usr/bin/env python3 """ Lesson 3: List Lab Course: UW PY210 Author: Jason Jenkins """ def series_1(list=[]): """ Practicing using lists """ # Make a copy of list list = list[:] print() print("Starting series_1:") print() display_list(list) # Add to list list.append(i...
c050a38ed6ef14bb1b1a0b1285319fe6261fba7a
kyaing/KDYSample
/kYPython/FluentPython/BasicLearn/MultiProcess/CopyFile.py
1,170
3.578125
4
from multiprocessing import Pool, Manager import os """ 多线程拷贝文件 """ def copyFileTask(name, old_folder_name, new_folder_name): """ 拷贝一个文件 """ fr = open(old_folder_name + '/' + name) fw = open(new_folder_name + '/' + name, 'w') content = fr.read() fw.write(content) fr.close() fw.close() ...
56d4618c988e5b78bbabe6bb2bfa85ccde9e7335
simon7lousky/Stock-Analyzer
/tick_compare.py
3,226
3.75
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 9 00:52:03 2018 @author: simonlousky """ """ Program that receives a start date, a end date,a list of shares and a variable the user wants to compare and analyze. The program will create a graph in the given period, which compares the selected variable for th...
10196dd033199f1f0dd5f20bf5bd181d772ec0a9
loggar/py
/py-dev/best-practice/dont-use-recursion/ex.1.py-closure.py
196
3.984375
4
def outer(): x = 1 def inner(): print(f'x in outer function (before modifying): {x}') x += 1 print(f'x in outer function (after modifying): {x}') return inner
08ef0c68c01bc4b2f113108110ccba0b0b8d0b86
dorabelme/Python-Programming-An-Introduction-to-Computer-Science
/chapter8_programming8.py
270
3.875
4
def main(): print("Euclid's algorithm") m = eval(input("Enter the first integer: ")) n = eval(input("Enter the second integer: ")) m_orig = m n_orig = n while m != 0: n , m = m, n % m print("The GCD of", m_orig, "and", n_orig, "is", str(n) + ".") main()
d9caadcc90f900caf939191acf5a1e028a2bb0e5
isruthi/HighSchoolCamp
/loops_applying_your_knowledge.py
1,512
4.09375
4
""" title: loops_applying_your_knowledge author: isruthi date: 2019-06-13 13:40 """ # part 1 - ex. 1 loop1 = [89, 41, 73, 90] for i in loop1: print(i) # part 1 - ex. 2 for i in range(5, 15): print(i, end=" ") print() # part 1 - ex. 3 for i in range(100, 201, 10): print(i, end=" ") print() # part 1 - ...
6ad9f15e9546644d0f223fced6495f7441453d92
BryCant/IntroToCryptography
/wk6/Project3.py
2,208
3.8125
4
import time # 1) implement the modular exponentiation algorithm to compute a^b mod n for any integer inputs a, b and n. Use your # code to compute a^b mod n for the sets of numbers below. Record the computer run time and iteration count for each. def getBinExpList(num): # function that returns list for all numbers...
6a950e840fbeeebae536b85d9465626bd04b61bd
amcguier/pysc2-protossbot
/zerg/MultiThreadingTest1.py
602
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 29 21:49:11 2018 @author: User """ import threading import queue my_queue = queue.Queue() #function to run in thread def testFunction(imput1, out_queue): #function stuff output = imput1 + 1 #return out_queue.put(output) #c...
0b04451faeae0c2fff14b7c22458db365f78c04d
hmcurt01/Ivy-Plus
/college.py
1,210
3.609375
4
# college class class College: def __init__(self, name, ed, aid, intvw, cadone, casent, fafsa, css, par, ty, choose, accept): self.name = name self.ed = ed self.aid = aid self.intvw = intvw self.cadone = cadone self.casent = casent self.fafsa = fafsa s...
19dc9f8d539bbd7f7c6b266aee1e9aecd8eeb0f5
KaranKendre11/cloudcounselage_intern
/CloudConselage/SOLN/problem5.py
75
3.640625
4
s = input() m = "" for x in s: if x not in m: m += x print(m)
6124935344a4816ae2bf5790f60b2faa27b09066
JanviChitroda24/pythonprogramming
/Hackerrank Practice/left_rotation.py
1,173
4.3125
4
''' A left rotation operation on an array of size shifts each of the array's elements unit to the left. For example, if left rotations are performed on array , then the array would become . Given an array of integers and a number, , perform left rotations on the array. Then print the updated array as a single lin...
5e2db6fc610175252b66022876add0de2705c062
dlefcoe/daily-questions
/directionsValidate.py
4,530
3.9375
4
''' This problem was asked by Uber. A rule looks like this: A NE B This means this means point A is located northeast of point B. A SW C means that point A is southwest of C. Given a list of rules, check if the sum of the rules validate. For example: A N B B NE C C N A does not validate, since A cannot be both n...
c67c6b50af88e4110b96c15576b1aceff4bac8f6
hrz123/algorithm010
/Week10/每日一题/面试题 08.06. 汉诺塔问题.py
1,077
3.890625
4
# 面试题 08.06. 汉诺塔问题.py from typing import List class Solution: def hanota(self, A: List[int], B: List[int], C: List[int]) -> None: """ Do not return anything, modify C in-place instead. """ n = len(A) self.move(n, A, B, C) def move(self, n, A, B, C): if n == 1: ...
89e9a72df08f9d0558796b3e74b9a3cb42830f91
ygberg/labbar
/function 1-6/function1.py
138
3.546875
4
a=22 b=11 c=6 def incomp(num1,num2,num3): lista = [num1,num2,num3] lista.sort() return print(lista[-1]) incomp(a,b,c)
c54c21ae0a7706eec992d3ec1d59065a9960812e
JbrooksGit/python-joins
/data_frame.py
1,328
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 14 16:41:35 2019 @author: jonathanbrooks """ import csv import pandas as pd import numpy as np def drop_y(df): # list comprehension of the cols that end with '_y' to_drop = [x for x in df if x.endswith('_y')] df.drop(to_drop, axis=1, in...
29a79ff8a7b18fad475ed5b961d2df21b2030304
Maryville-SWDV-610-3W18SP2/week-4-stacks-queues-and-lists-GFRAYJO
/DequeUsingLinkedList.py
1,128
3.53125
4
class _Node: __slots__ = '_object', '_prev', '_next' def __init__(self,object,prev,next): self._object = object self._prev = prev self._next = next class Deque: def __init__(self): self._header = self._Node(None,None,None) self._trailer = ...
c2bb72aeb043e9342c8f7248e50048f1a63ed95f
tjsaotome65/sec430-python
/module-06/threadexample1.py
443
4
4
""" File: threadexample1.py First demo of a thread. """ from threading import Thread class MyThread(Thread): """A thread that prints its name.""" def __init__(self, name): Thread.__init__(self, name = name) def run(self): print("Hello, my name is %s" % self.getName()) def main(): ""...
60bc1822965c2a34cbc5934f0d08904f5726d4da
AdamZhouSE/pythonHomework
/Code/CodeRecords/2636/60618/321148.py
61
3.90625
4
str=input() if str=="4 3": print(4) else: print(str)
3e91152381245f43b0b85568fdeb24e242d366cb
soumyadip1188/python
/python programe/KrishnamurtyNumber.py
449
4.15625
4
def factorial(n): fact = 1 while(n!=0): fact=fact*n n=n-1 return fact def Krishnamurty(n): s = 0 temp = n while(temp!=0): rem=temp%10 s=s+factorial(rem) temp=temp//10 return(s==n) n=int(input("enter a numberto check if it's a Krishn...
752f284808f5b65b796707c699e9cf38bab5c705
blankxz/LCOF
/排序、二分等基础算法/桶排序.py
535
3.71875
4
def bucketSort(arr): maximum, minimum = max(arr), min(arr) bucketArr = [[] for i in range(maximum // 10 - minimum // 10 + 1)] # set the map rule and apply for space for i in arr: # map every element in array to the corresponding bucket index = i // 10 - minimum // 10 bucketArr[index].appen...
f52e1d612a1b14314c39a08b0b6eb5020ef199c6
mrichko2705/lab_python
/py_75.py
318
3.84375
4
#!/usr/bin/env python3 # --*-- coding:utf-8 --*-- string = str(input("Введіть слово англійською мовою: ")) alph = ['a', 'o', 'u', 'i', 'e', 'y'] b = [] for i in string: if i.lower() in alph : b.append(1) print("Кількість голосних в слові = {}".format(len(b)))
e8095bbf2b7af3435b272453dd9c986ba3a6b22b
yns01/leetcode
/149-word-search.py
1,930
3.859375
4
from typing import List class Solution: def exist(self, board: List[List[str]], word: str) -> bool: for i in range(len(board)): for j in range(len(board[0])): if board[i][j] == word[0]: if self.dfs(board, (i, j), word, 0, set()): retu...
89434c283d04ea08b3472c73c0941280da125b64
ashcolecarr/Exercism-Python
/prime-factors/prime_factors.py
716
3.96875
4
from math import sqrt def prime_factors(natural_number): prime_factors = [] # Get a list of factors. factors = [2] if natural_number % 2 == 0 else [] factors += [x for x in range(3, int(sqrt(natural_number)) + 1, 2) if natural_number % x == 0] # Using straightforward trial divisi...
1d4242e51797d470826b27d4be32ccedbc52a4ef
MJVL/Python-Projects
/Basic Stuff/list_comprehension.py
164
3.640625
4
evens_to_20 = [i for i in range(21) if i % 2 == 0] print(evens_to_20) cubes_by_four = [x ** 3 for x in range(1,11) if (x ** 3 % 4 == 0)] print(cubes_by_four)
38b88ff73071bde58f0d5e337d8ca5ed4ff12d51
aj-1000/project-euler
/first-50/problem_7.py
852
4.1875
4
# 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 required libraries from itertools import count # Using the prime test from a previous problem def test_if_prime(x): if x == 2: return True elif x%2 == 0...