blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e08823d01c100ab7697dd5a3c5ca6064f8704f54
pombredanne/Rusthon
/regtests/go/map_comprehension.py
171
3.859375
4
''' map comprehensions ''' def main(): m = map[int]string{ key:'xxx' for key in range(10) } assert m[0]=='xxx' assert m[9]=='xxx' print m print m[0] print m[1]
57bea64b67a95243bbf2067014887c4b2f4bf08c
Jamunashree/Experimenting
/ExperimentingIf.py
1,394
3.796875
4
x= "Analyse Survey Data with the scripts on ***link***" y= "Meet us in the lobby at 8.30" print("Do you analyze survey data for work?") ans1=input() if ans1=='yes': print("Do you speak any R?") ans2=input() if ans2=="yes": print(x) elif ans2=="no": print("Do you analyze survey ...
15b1d2ade8b254c240485470ed1c3ee6d2031538
marcusorefice/-studying-python3
/Exe041.py
808
4.28125
4
'''A confederação Naciona de Natação precisa de um programa que leia o ano de nascimento de um atleta e mostre mostre sua categoria, de acordo com a idade: Até 9 anos:MIRIM Até 14 anos:INFANTIL Até 19 anos:Junior Até 25 anos:Sênior Acima:MASTER''' from datetime import date ano = int(input('Informe o ano de na...
863f27ae0745b09eecf25d60ee2484a8b64dce2b
anilkumar0470/git_practice
/mysqlpracfull.py
10,455
3.640625
4
""" sql = "select * from employee where income >= %d " %(2000) try: #excute the sql command print "==>",sql cursor.execute(sql) #fetch all the rows in alist of lists results = cursor.fetchall() print "===",results for row in results: print "---",row first_name = ro...
cccbf3dac8a8a109370593dd35e1ed8398e7d3c6
wangxiao4/programming
/Num6/6.2_PrintGradeFunction.py
255
3.96875
4
def printGrade(score): if score<60: print("F") elif score<70: print("D") elif score<80: print("C") elif score<90: print("B") else: print("A") score=eval(input("enter score\n")) printGrade(score)
7a9d382a3f902973ad48761c18cba24db2408197
teoim/learnPython
/c2_s3_strings.py
2,143
4.21875
4
# help(str) # string manual # print(dir(str)) # available functions for string # format method num1 = 100 num2 = 200 print("Num1 is {0} and num2 is {1}".format(num1,num2)) print("Num1 is {val1} and num2 is {val2}".format(val1=num1,val2=num2)) s1 = "make me capital one more time" print(id(s1)) s1 = s1.capita...
2aad76d109125e5a2ecf4a6894172bc9a0a7bf2a
juselius/python-tutorials
/Debugging/list_bug.py
265
4
4
def lists(): empty_list = [] list_of_lists = [] for x in range(0, 5): list_of_lists.append(empty_list) for index, list in enumerate(list_of_lists): list.append(index) print list_of_lists if __name__ == '__main__': lists()
f25c395e089bc0a60673cf19e8bf292885e79031
sonkadak/coding-practice
/Hackerrank/Interview-preparation-kit/Arrays/2D-Array-DS.py
787
3.5
4
#!/bin/python3 # Complete the hourglassSum function below. def hourglassSum(arr): sums = [] for i in range(0, 16): sums.append(0) # for sum of 1st line each glasshour n = 0 for i in range(0, len(arr)-2): for j in range(0, len(arr[i])-2): for k in range(j, j+3): ...
7e0f49461272144753c1688587160c9c58941c2e
sainihimanshu1999/Leetcode-Interview-Questions
/word-break2.py
501
3.671875
4
''' simple recurssion ''' class Solution: def wordBreak(self,s,wordDict): if s == '': return [[]] ans = [] for word in wordDict: if s[:len(word)]==word: if len(s)==len(word): ans.append(word) else: ...
9493cd6863c1f260827bb2020e3a104c2f025fa7
ErikSteLarsen/Gruppe2EiT
/simulator/AdvancedSimulator.py
858
3.796875
4
import numpy as np class AdvancedSimulator: def __init__(self,truck): self.truck = truck def calculateWeights(self,valgfri=None): weights = [] axleCapacitiesTruck = self.truck.getMaxAxleWeights() axleCapacitiesTrailer = self.truck.trailer.getWeightDistribution() allC...
ba7959983789faa6782953ddacfa8949c45bed93
JoachimIsaac/Interview-Preparation
/arrays_and_strings/integer_to_string.py
854
4.28125
4
""" Problem 2: Write a method that takes an integer as input and returns its string representation. For example: Input: 123 Output: "123" Input: -6714 Ouput: "-6714" UMPIRE: Understand: --> Can we use the built in str() method to change the entire integer? --> Can we get negative numbers ? yes --> can we get ...
90da10cd0b9f4431e56dd9e911ed410c3272b555
Xuchaoqiang/Luffycity
/第二模块/第三章/局部变量.py
1,675
3.859375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Irving # 局部变量 # 不加global修改names其实是在内存里重新创建了一个names变量,指向另外一块内存地址,id不一样, 加了global就是直接引用了names # names = ['alex', 'irving', 'eric'] # def change_name(): # global names # names = ['alex', 'irving'] # print(names) # # change_name() # print(names) # 在函数里面...
665860acd0f1d47eea0694852d94397864251d6b
bsdharshini/Python-exercise
/task reverse.py
784
4.34375
4
''' Reverse array For a given array reverse order of its elements. Input The first line of input contains integer t,the number of test cases. In the next t lines t test cases follow. Each test case cosists of numbers separated by spaces. In each line, the first number ni is the length of an array. Next ni n...
6bb34f64c553a589207ad28a9d63c1351750b33b
lizerd123/github
/game compalation/Game compalation.py
16,455
3.578125
4
game_chosen=0 begin_game=0 running=0 while True: while begin_game!=1: print("play (1) motorman(one player) (2) Dungeon(one player) (3) Shop'n'Stab(one player) (4)Duel(two player)") game_chosen=input("what to play... ") if game_chosen==1 or 2: begin_game=1 running=1 if game_chosen==1: import s...
db1628e56fc0e723a08fa43c52d9aca5ad03c338
detcitty/100DaysOfCode
/python/unfinshed/largeprodsum.py
494
3.625
4
# https://www.codewars.com/kata/5c4cb8fc3cf185147a5bdd02/train/python import numpy as np def sum_or_product(array, n): a = np.array(array) a_sorted = np.argsort(a) potential_prod = a[a_sorted][:n] potenial_sum = a[a_sorted][-n:] prod = np.prod(potential_prod) sums = np.sum(potenial_s...
48e04ebd079b65be5597e4e537327e215564c97d
vladvlad23/UBBComputerScienceBachelor
/FundamentalsOfProgramming/Assignment_05_07_refactored/Assignment_05_07_refactored/domain/Movie.py
839
3.5
4
class Movie: def __init__(self,movieId,movieTitle,movieDescription,movieGenre): self.__movieId = movieId self.__movieTitle = movieTitle self.__movieDescription = movieDescription self.__movieGenre = movieGenre def getMovieId(self): return self.__movieId def getMovi...
07ee18617da727499b7640f2d0de7da612bd0f50
kimurakousuke/MeiKaiPython
/chap07/list0701.py
506
3.8125
4
# 读取5个人的分数并输出总分以及平均分 print('计算5个人分数的总分以及平均分。') tensu1 = int(input('第1名分数:')) tensu2 = int(input('第2名分数:')) tensu3 = int(input('第3名分数:')) tensu4 = int(input('第4名分数:')) tensu5 = int(input('第5名分数:')) total = 0 total += tensu1 total += tensu2 total += tensu3 total += tensu4 total += tensu5 print('总分是{}分。'.f...
6744d0bdb06ba5c605ae6d2c319c228f203bdbf4
Gobika25/py
/paranthesis.py
304
3.703125
4
a=input() c=0 for i in a: if i=='{': c+=1 elif i=='(': c+=1 elif i=='[': c+=1 elif i==']': c-=1 elif i==')': c-=1 elif i=='}': c-=1 if c==0 : print("Balanced") else: print("Un Balanced") i/p:{([])} o/p:Balanced
f17812aa89d3a25f9809dcd866e531c98b5719b8
thuurzz/Python
/curso_em_video/mundo_02/repetições_em_python_(while)/ex061.py
636
4
4
# Exercício Python 51: Desenvolva um programa que leia o # primeiro termo e a razão de uma PA. No final, # mostre os 10 primeiros termos dessa progressão. # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # a1 = int(input('Digite o primeiro termo da PA: ')) r = int(input('Digite a razão da PA: ')) n = 10 # ...
92c94da6496e53a8b3cfe9a1a1c1fe319208b8e3
allankeiiti/Python_Studying
/CursoDePythonUdemy_DiegoMendes/Exercicios/Exercicios_O_Arquivo/Exercicio_O2.py
464
3.671875
4
carro = str(input('Digite o nome de um carro | Digite nada para parar: ')) arq = open('carros.txt','w') if carro != "": arq.write(carro+'\n') while carro != "": carro = str(input('Digite o nome de um carro | Digite nada para parar: ')) arq.write(carro + '\n') arq.close() #Realizando leitura do ...
6a91e093619795ccde23a4cfe8dc487a2e23b3fa
Haut-Stone/study_Python
/base_test/my_json.py
798
3.796875
4
# -*- coding: utf-8 -*- # @Author: Haut-Stone # @Date: 2017-07-05 18:21:08 # @Last Modified by: Haut-Stone # @Last Modified time: 2017-07-05 20:59:34 import json # 读写json文件 numbers = [2,3,5,7,11,13] filename = 'numbers.json' with open(filename, 'w') as f_obj: json.dump(numbers, f_obj) tests = [] filename = 'nu...
b86acf81921914ef59936210ab0c1ece1324a666
Vitmambro/Python9
/Exercicios/ex013.py
178
3.546875
4
salario = float(input('Salario do funcionario: ')) aum = salario + (salario * 15 / 100) print('O salario era R${:.2f}, com aumento de 15% ficaria R${:.2f}'.format(salario, aum))
b0bca9757d93155e8fd404a2901aa253bdb0e1e5
AdamBrauns/CompletePythonUdemyCourse
/section_13/generator.py
1,756
4.5625
5
''' Generators allow us to generate a sequence of values over time The main difference in syntax will be the use of a yield statement The advantage is that instead of having to compute an entire series of values up front, the generator computes one value, waits until the next value is called for An example is the range...
939dfc7402d80f7dfef028715de0f6febc07bcf4
apterek/python_lesson_TMS
/lesson_09/solution_home_02.py
414
3.96875
4
from solution_home_01 import Car def main(): new_car = Car('Mercedes', 'E500', 2000, 0) if new_car.speed < 100: while new_car.speed < 100: new_car.speed_up() elif new_car.speed > 100: while new_car.speed > 100: new_car.speed_down() return print(f'the ...
6695598c3c7529b6c4034e51b8190216c01d3bcb
RookieZhang/LearnPython
/print.py
197
3.90625
4
print "Hello, welcome to Python world" print "hello" + "Python" #without any space between the two string str1 = "Python" print "hello" + str1 #even if with a variable there is still no space
01e1daa27d67c71e868a1feecfd28643421c2ac6
Parth731/Python-Tutorial
/Durga Software/Datatype/5_str_datatype.py
283
3.796875
4
''' char datatype is not available long data type available in python2 but not in python3 ''' s1 = "durga soft" print(s1) s1 = 'durga soft' print(s1) s1 = '''durga soft''' print(s1) print(s1[0]) print(s1[1]) print(s1[-1]) print(s1[1:40]) print(s1[1:]) print(s1[:4]) print(s1[:])
d71b006c9d2428ef8e2b82dbc35e7e92a30798f4
speyermr/primes
/primes/v5_sieve.py
865
3.71875
4
# Fastest: The Sieve of Eratosthenes # # https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes # # Invented around 2200 years ago! # def upto(limit): # Fill our sieve with "True", meaning a number at index=N will be prime if # sieve[n] == True. sieve = [True] * limit # 0 and 1 are not prime, so poke th...
8a8acda9971f4a899bb67dcba701a1027c878ffe
Aakancha/Python-Workshop
/Jan13/Classwork/Classwork.py
1,287
3.546875
4
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> print('hello world!') hello world! >>> print('hello'*10) hellohellohellohellohellohellohellohellohellohello >>> name= input('enter your nam...
365d5c1b57e9bc68c883f390361956483d3be7dd
jhidding/talk-python-typing
/examples/generic.py
379
3.5
4
# ~\~ language=Python filename=examples/generic.py # ~\~ begin <<README.md|examples/generic.py>>[0] from typing import (Iterable) def word_lengths(words: Iterable[str]) -> Iterable[int]: return (len(w) for w in words) words = "The quick brown fox jumps over the lazy dog".split() print(word_lengths(words)) print(w...
6bdb3ada958c92f5acaf77d2a499b8ab462268e3
CrouzetC/Mon_GitHub_Public
/Python/Misc/Jeu_de_bataille.py
2,923
3.53125
4
import random as rnd ### def melange(L) : N = len(L) for i in range(N-1) : echange = rnd.randint(i,N-1) tmp = L[i] L[i] = L[echange] L[echange] = tmp ### ### deck1 = [] for couleur in [" <3", " <>", " -8o", " -8>"] : deck1.append("AS"+couleur) deck1.append("Roi"+co...
3b798711863796cf974928626d02cf45d9246402
hktamzid/Python-Mosh
/numerical.py
92
3.546875
4
a = 2 b = 4 print(a+b) print(a-b) print(a*b) print(a/b) print(a//b) print(a**b) print(3**3)
32fcfb37f061fbdadcae67e620a0d5d2b1ed41cd
michelmedeiros/udacity-python
/aula_procedures.py
573
3.8125
4
#Soma de dois numeros def sum(a, b): a = a+ b return a a =5 b = 2 print(sum(a,b)) print (a) a = sum(a,b) print(a) #Quiz 1 - Calculo de um quadrado def square(a): b = a*a return b print(square(5)) # Define a procedure, abbaize, that takes # two strings as its inputs, and returns # a string that is the...
abadd7d589958ac07f0e66c973961d8326edc489
jfalkowska/pyladies-start
/Day_1/Task4.py
514
3.671875
4
import math r = float(input('Podaj promień podstawy w centymetrach ')) l = float(input('Podaj tworzącą stożka w centymetrach ')) h = float(input('Podaj wysokość stożka w centymatrach ')) pole_podstawy = math.pi * r ** 2 pole_powierzchni_bocznej = math.pi * r * l objetosc = 1/3 * math.pi * r ** 2 * h print() print('P...
14b267de0c16bacb7f82055fc7273f9492e2ce47
rpnpackers/database
/database.py
3,148
4.125
4
import csv import sqlite3 import sys import inp import db def main(): # While loop so that multiple operations can be performed. while True: # Gets input from the user about what they want to do options = ["j", "m", "o", "q"] text = ["Import Jobs", "Import Montly Data", "Import Origi...
362d2aa8f3bbaf538b7c1bb7a6442c7d245c669d
ElAntagonista/progress-devops
/Lectures/Python-Intro/python_basics_4.py
380
3.828125
4
""" File I/O Using python for File I/O is a relatievly straight-forward """ # Write to file # Let's make simple list groceries = ["beer", "pasta", "bread"] with open("sample.txt", 'w+') as file_: for item in groceries: file_.writelines(item + "\n") # Read from a file with open("sample.txt", 'r') as fi...
49eaa6eb95e0b4f0e3cd44a0cd16e5e37f478c99
nyhyang/Info206-Python
/HW3_Binary/hw3_starter_pack/hw3test.py
500
3.5
4
#--------------------------------------------------------- # Nancy Yang # nancy_yang@berkeley.edu # Homework #3 # September 20, 2016 # hw3test.py # Test #--------------------------------------------------------- from BST import * from hw3 import * T = BSTree() T.add("4") T.add("2") T.add("3") T.add("5") T.add("1") T....
7e30b00c505084c53c236b1133dc10fd845d2234
a31415926/geekhub
/HT_4/2.py
1,532
3.984375
4
"""Створіть функцію для валідації пари ім'я/пароль за наступними правилами: - ім'я повинно бути не меншим за 3 символа і не більшим за 50; - пароль повинен бути не меншим за 8 символів і повинен мати хоча б одну цифру; - щось своє :) Якщо якийсь із параментів не відповідає вимогам - породити виключення із в...
47d8e447b710866ab457a6bfe88305950c2cffa8
jaychsu/algorithm
/lintcode/450_reverse_nodes_in_k_group.py
1,155
3.640625
4
""" Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None """ class Solution: """ @param: head: a ListNode @param: k: An integer @return: a ListNode """ def reverseKGroup(self, head, k): if not head: retu...
1935a55d7baa0c6323c1b21d823c1dac54f0342b
Murali1125/Fellowship_programs
/DataStructurePrograms/calender_weakday_obj.py
2,429
4.25
4
"""----------------------------------------------------------------------------- -->Create the Week Object having a list of WeekDay objects each storing the day --(i.e S,M,T,W,Th,..) and the Date (1,2,3..) . The WeekDay objects are stored in --a Queue implemented using Linked List. Further maintain also a Week Object i...
b7d767c0e2865ae21696af7454f37b089868daf2
lr154lrose/Project-Euler
/python solutions/problem_18.py
1,573
3.984375
4
# Program finding the path with the biggest sum in a triangle. It works by # starting at the top of the triangle and moving to adjacent numbers of the # row below. def maximum_sum(matrix): M = len(matrix) for i in range( M - 2, -1, -1 ): # from the penultimate row until the first one, at positio...
d2d18f1ec3e4aedcddeb229df9e8e535b5fe066b
ank26it/python_biginner
/CSV/CSVModule.py
1,289
3.609375
4
import csv import os os.chdir('/Users/User/Desktop/hi/CSV') # # Read CSV file: # with open('names.csv', 'r') as csv_file: # csv_reader = csv.reader(csv_file) # next(csv_reader) # for line in csv_reader: # print(line[2]) # # Write new CSV file: # with open('names.csv', 'r') as csv_file: # csv_r...
60a06c78595e4c57632e8ccb7b50ae812703b0c4
GloriaAnholt/PythonProjects
/Algorithms-DataStructures/test_BinaryTreeClass.py
2,356
3.921875
4
# Algorithms and Data Structures: Quick Sort # 07.20.2016 # @totallygloria import unittest from BinaryTreeClass import BinaryTree class BinaryTreeTester(unittest.TestCase): def test_BinaryTree(self): # Check if you can make a new node of different types, or change types t1 = BinaryTree("maple") ...
9254499cea5fcdaa4a6872741b1b0e38601caa9e
Jugveer-Sandher/PythonProjects
/Dictionaries/main.py
3,867
3.84375
4
import utilities_set import utilities_dict def main(): """ Main Program """ # PART A set1 = {'apple', 'banana', 'orange', 'peach'} set2 = {'banana', 'pineapple', 'peach', 'watermelon'} set1_count = utilities_set.get_total_items(set1) print("The total number of items in set1 is:", set1_count...
26c9c4342e83cd84a233052dc541ccda80ce2a6a
andrefalken/CV_Python
/08 - Utilizando módulos/desafio017.py
604
4.1875
4
# Desafio 017 # Faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triângulo retângulo e # calcule e mostre o comprimento da hipotenusa # Importando toda a biblioteca de matemática import math # Declarando a variável para receber o comprimento do cateto oposto e do cateto adjacente ...
86594b2d4267e79d699f872711a742b1aecea526
igarciru/per19ejerciciofiguras1
/Ejercicio_figuras.py
1,073
3.546875
4
class figura: def __init__(self): pass def dame_area(self): return print("Esta figura no tiene area") def dame_perimetro(self): return print("Esta figura no tiene perímetro") class cuadrado(figura): def __init__(self,lado): self.lado=lado super().__init__() ...
b63a4228151fd96a622524c2afab2da4194bab39
djbrown31/webscraper
/Week_Two_Challenges/linked-list-sum.py
1,190
3.859375
4
class Node: def __init__(self, value, next): self.value = value self.next = next def linked_list_sum_iterative(list1, list2): res = Node() p1 = list1 p2 = list2 curr = res carry = 0 while p1 is not None or p2 in not None or carry != 0: ...
759929f2a09dd4e71e4934c64f00a66015d079b9
pmaywad/DataStructure-Algo
/Trees/BinayTree/level_order_insertion.py
1,077
3.875
4
""" Insertion in binary tree in level order in Python """ from queue import Queue class Node: def __init__(self, key): self.data = key self.left = None self.right = None def inorder(root): if not root: return None inorder(root.left) print(root.data, end=' ') inord...
1ed8501fb777b0591909c8fb810f525a63a2a06d
krithika-srinivasan/data-structures-and-algorithms
/linked lists/concatenation.py
1,434
4.09375
4
class LinkedList: class _Node: __slots__ = '_element', '_next' def __init__(self, element, next): self._element = element self._next = next def __init__(self): self._head = self._Node(None, None) self._tail = self._Node(None, None) sel...
f43b17d7347cb4e1ea8f1b69cb0e561e4e621b6d
iadel93/MachineLearning
/KNN/KNN_sklrn_2.py
1,671
3.796875
4
# this is a more advanced implementation of KNN using Numpy # import neccesary libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.preprocessing import LabelEncoder from sklearn.utils import shuffle from sklearn.model_selection import train_test_split #import dataset data...
e04becb568fb432004b232b2763beace27b1cd2f
xiaole0310/leetcode
/352. Data Stream as Disjoint Intervals/Python/Solution.py
2,456
3.765625
4
# Definition for an interval. # class Interval(object): # def __init__(self, s=0, e=0): # self.start = s # self.end = e class SummaryRanges(object): def __init__(self): """ Initialize your data structure here. """ self.intervals = [] def addNum(self, val): ...
b89ac1d8e0c302bdf36b13d02b96b6d816de1c63
mafdezmoreno/HackerRank_Callenges
/Practice/ProblemSolving/QueueUsingTwoStacks.py
1,179
4.34375
4
#https://www.hackerrank.com/challenges/queue-using-two-stacks/problem ''' A basic queue has the following operations: Enqueue: add a new element to the end of the queue. Dequeue: remove the element from the front of the queue and return it. In this challenge, you must first implement a queue using two stacks. Then pro...
7bfe6b6a5e440120022e8e0486072cebd3d4d33e
ShehrozeEhsan086/ICT
/Exercise/Calculator.py
1,227
4.46875
4
# Basic Calculator with 2 or 3 operands (INCOMPLETE) operands = input("Enter the numbers of operands you want to use(2 OR 3): ") print("Use + , - , x , / when asked for which operation to perform") if(operands=="2"): num1,num2= eval(input("Enters numbers seperated by ',' : ")) operation = input("Enter whic...
15291112e4d78facf787445583d1bec1fe535fa3
AZICO/lambdata-azico
/lambdata_azico2/helper_functions.py
1,064
3.75
4
def null_count(df): return df.isnull().sum().sum() # Split addresses into three columns (df['city'], df['state'], and df['zip']) # def addy_split(add_series): # df[len_str] = df['owner city state zip'].str.split(',').apply(len) # df['num_commas'] = df['Owner City State Zip'].str.count(',') # return df ...
c191eb28cb62febcbb39d878bf786d4f5fc90888
oknono/Project_Euler
/Problem01.py
634
4.0625
4
# Update using PDF from Euler Website 28 September # This works with larger numbers as well! # Two importan steps: # 1. sum of all numbers divisible by x or y is equal to # ( sum of all numbers divisible by x + # sum of all numbers divisible by x ) - # sum of all numbers divisible by x * y # 2. The sum of all multipl...
b375c7a2d9d5b33986e31a190d6ce7d0d04052db
abriggs914/Coding_Practice
/Python/Codecademy_machine_learning/Tennis Aces/tennis_aces.py
12,835
3.6875
4
# Tennis Ace # Overview # This project is slightly different than others you have encountered thus far on Codecademy. Instead of a step-by-step tutorial, this project contains a series of open-ended requirements which describe the project you’ll be building. There are many possible ways to correctly fulfill all of thes...
e845aeca37bd0f7c64dcb3c4730fc135cda66c5a
kaharkapil/Python-Programs
/wrtefile1.py
443
3.90625
4
import csv name=input("enter name") email=input("enter eamil") with open('wrtefile.csv','w') as csvfile: fieldnames=['first_name','email'] writer=csv.DictWriter(csvfile,fieldnames=fieldnames) writer.writeheader() writer.writerow({'first_name':'kapil','email':'a@aa.com'}) writer.writerow({'first_name':'rana','email...
f4d65439c6ff9fc1da80e09b7cb0ca0800182503
Bobbybushe/HW
/task_4_1.py
260
3.734375
4
spis_1=[1,2,3,4,5] spis_n=[] i=0 for i in range(len(spis_1)): spis_n.append(spis_1[i] * -2) print(spis_n) #Все тоже с while spis_2=[2,3,4,5,6] spis_n_2=[] i_2=0 while i_2<len(spis_2): spis_n_2.append(spis_2[i_2] * -2) i_2+=1 print(spis_n_2)
931242546c6e2efb57a73f6784777bebf5bfda57
LazarusCoder/Problem_Solving_with_Python
/LAB3/prac31.py
332
3.640625
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 6 10:00:00 2020 @author: Admin """ from random import * ran=randint(1,52) rank=ran%13 category=ran//13 if(rank==0): s="ACE" elif(rank==10): s="Jack" elif(rank==11): s="Queen" elif(rank==12): s="King" else: s=str(rank+1) print("The Card you Picked i...
7db9ae02aa4a656aa95957e99bbf54cd9253af7e
saurabhm3hra/pyFolder
/ticTacToe.py
2,812
3.5625
4
import sys class Board: # TicTacToe Board board = {"TL": ' ', "TM": ' ', "TR": ' ', "ML": ' ', "MM": ' ', "MR": ' ', "LL": ' ', "LM": ' ', "LR": ' '} def __str__(self): # Print Board contents return self.board['TL'] + '|' + self.board['TM'] + '|' + self.board['TR'] + '\n' + \ '-+-+-' + ...
4ca10c7c9d43240774db9ca34f715bed7ea1ea6d
nikitasyrtsov/DZ
/dz3/Домашка 3/#9.py
285
3.609375
4
'''Упражнение 9 Напечатать числа Фибоначчи от 1 до 50. Числа напечатать в одну строку. ''' fib1 = 1 fib2 = 1 for i in range(1,50): fib_sum = fib1 + fib2 fib1 = fib2 fib2 = fib_sum print(fib_sum, end = ' ')
ec6881c45a38763368eea0312612cb16d5244f96
yavaralikhan/proj
/25FebC.py
331
3.9375
4
import matplotlib.pyplot as plt """ Y = [0, 1, 2, 3, 4, 5] plt.plot(Y) plt.show() """ X = list(range(1, 11)) Y1 = [n for n in X] Y2 = [n*n for n in X] Y3 = [n*n*n for n in X] print(Y1) print(Y2) print(Y3) plt.plot(X, Y1, label="Y1") plt.plot(X, Y2, label="Y2") plt.plot(X, Y3, label="Y3") plt.grid(True) plt.legend() ...
fa26f98ea19e5e07c603a82bee4ae98608736995
tyao117/AlgorithmPractice
/randomizeList.py
265
3.859375
4
import random array = [1,2,3,4,5,6,7,8,9] def randomizeList(lst): b = len(lst) -1 for d in range(b,0,-1): e = random.randint(0,d) if e == d: continue lst[d], lst[e] = lst[e], lst[d] randomizeList(array) print(array)
9cac58b35c1a9cc9b97c9bc6fc85564f8ade9311
isleong/python_finance
/myscript.py
855
3.734375
4
import numpy as np import pandas as pd from pandas import Series, DataFrame series_obj = Series(np.arange(8), index=['row 1', 'row 2', 'row 3', 'row 4', 'row 5', 'row 6', 'row 7', 'row 8']) print(series_obj) print(series_obj['row 7']) print(series_obj[[0,7]]) np.random.seed(25) df_obj = DataFrame(np.random.rand(36...
f30e565d8ec99b696cf2d16ec84ab27eb4fd0ab5
thomps51/ProjectEulerSolutions
/problem47.py
975
3.53125
4
import math import sys def primeTest(N): if N==1: return False for i in xrange(2,int(math.sqrt(N))+1): if N % i == 0: return False return True def findPrimeFactors(N): primeFactors = [] for i in xrange(2,int(math.sqrt(N))+1): if N % i == 0: if primeT...
dfbcd7782b8264567bed14a62117b0e6b7e1dbe8
K021/search_bible
/search_bible_2.0/functions.py
5,871
3.609375
4
def search_scripture(scripture_path, sub_scripture_path=None, is_lower=True, number_of_lines_to_print=1): """ file type 의 scripture 객체를 받는다 사용자에게서 검색어를 입력 받아 검색을 수행한다 :param scripture_path: 검색을 수행할 txt 파일 path :param sub_scripture_path: scripture 와 비교할 파일 path :param is_lower: Capital letter ...
82ff85ec44a600511835c70fb1958d65cb561c31
ARuhala/PythonProjects
/ViolentPythonCookBook/PortScanner/sysExperiment.py
1,317
3.6875
4
''' This file is part of examples shown in a book "Violent Python Cookbook for Hackers, Forensic Analysts, Penetration Testers and Security Engineers" Most of the code is copied as is, or with minor changes to make naming easier to understand and some comments may have been added where i explain to myself how everythin...
f84424134fe87e031935ebd4447912c9ee56ea04
arpitpardesi/Advance-Analytics
/Python/Basics/Day2/For Loop/Ex2.py
65
3.53125
4
a = "My name Arpit Pardesi" for i in a.split(" "): print(i, end=" ")
aec51814ff162e4076ffbd2cc5f9513ea9bdf35a
dgquintero/holbertonschool-higher_level_programming
/0x03-python-data_structures/5-no_c.py~
165
3.75
4
#!/usr/bin/env python3 def no_c(my_string): new_s = "" for tmp in my_string: if tmp != 'c' or tmp != 'C': new_s = new_s return new_s
5b85031d8c28adcab1f4d2f144b5c2a1f59e328c
HIjack2015/showLastEvent
/mm/tests.py
289
3.796875
4
# Function defined outside the class def f1(self, x, y): return min(x, x+y) class C: f = f1 def g(self): return 'hello world' h = g int class D: f = f1 def g(self): return 'hello world' h = g f1(C,1,2) c=C() c.f1(1,3) d=D() d.f1(1,3)
fd1f0ef96e43629cec62995b3c46eae67d45b0c9
rijumone/compete_code
/edX/UCSanDiegoX-ALGS200x/AlgorithmicDesignandTechniques/4-1.binary_search.py
639
3.546875
4
from loguru import logger def binary_search(a, x): left, right = 0, len(a) # logger.info(f'{a}, {x}') while left < right: mid = int((left + right) / 2) # logger.info(f'{left}, {right}, {mid}') if a[mid] == x: return mid if a[mid] > x: right = mid ...
ce44a701eb015d53cd9908e207ab9ca9cc2ff4d1
Jairofontalvo/exercism
/python/collatz-conjecture/collatz_conjecture.py
321
4.125
4
def steps(number): if number <= 0: raise ValueError("numero negativo") contador = 0 while number != 1: if number % 2 == 1: number = number * 3 + 1 contador += 1 if number % 2 == 0: number = number / 2 contador += 1 return contador...
1dec86936d04e3d45ab67b09d35112b3a1c179cb
ShivDj/Python_Basic
/Functional_Programm/​ Quadratic.py
1,156
4.3125
4
""" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Purpose: Program To calculate the roots of the equation * @author: Sheevendra Singh Singraul * @version: 3.8.6 * @since: 21-03-2021 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ """ import math #m...
cc84b7c8974b63a4bbac73d53f3e5e2162e3d9c1
thevivekcode/MachineLearning
/Assignment1/q3/part3.py
2,887
3.515625
4
# coding: utf-8 # In[1]: import numpy as np import pandas as pd import matplotlib.pyplot as plt from time import time from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm import matplotlib.animation as animation import math import sys # In[2]: # In[3]: def normalize(data): mean = np.mean(da...
a0dd0562c533da9f2c7589925488d2b11c0e6d3c
Marghrid/Foundations-of-Programming
/Exercicios/a02_12.py
335
4.21875
4
print ('\n') numero='' digito='' while (digito!='-1'): digito = input('Escreva um dgito\n(-1 para terminar)\n') if (digito!='-1'): if (eval(digito)<=0): print('No pode colocar dgitos negativos num nmero inteiro') else: numero=numero+digito print ('o numero e:', ...
9a1167136730ea4da1b6fa621033f21cc274a777
Nukeguy5/OperatingSystems
/threadingx/nthread.py
411
3.671875
4
import time import threading class CountdownThread(threading.Thread): def __init__(self, acount): threading.Thread.__init__(self) self.count = acount def run(self): while self.count > 0: print(self.getName(), ": Counting down", self.count) self.count -= 1 ...
c95b592447cbe3e13a0651216006471fb6656188
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/3113/codes/1594_1800.py
136
3.890625
4
a=float(input("valor de a:")) b=float(input("valor de b:")) c=float(input("valor de c:")) X=(a**2+b**2+c**2)/(a+b+c) print(round(X,7))
9690d4fbf10f21a92d44ac0344aa83a97155f18c
adityasriv22/Python-Drilling
/minelementoflist.py
478
3.828125
4
""" Write two Python functions to find the minimum number in a list. The first function should compare each number to every other number on the list. O(n^2).The second function should be linear O(n). """ import time from random import randrange def findmin(l): overallmin=l[0] for i in l: issmallest=True ...
a3f090471bcc501a1d0b762cd2a15264f467f755
SWMGroup11/XiaoMiOJ
/小米兔跳格子.py
413
3.5625
4
import sys def solution1(line): nums = [int(x) for x in line.rstrip().split()] current = 1 while 1: if current -1 == len(nums) - 1: return "true" elif nums[current - 1] == 0: return "false" elif current -1>len(nums): return "false" else:...
16bcff98521e09820019e11e388ae94819f78f92
groovallstar/test2
/python/example/p_chapter02_03.py
2,904
4.28125
4
# Chapter02-03 # 파이썬 심화 # 클래스 메소드, 인스턴스 메소드, 스테이틱 메소드 # 기본 인스턴스 메소드 # 클래스 선언 class Car(object): ''' Car Class Author : Me Date : 2019.11.08 Description : Class, Static, Instance Method ''' # Class Variable price_per_raise = 1.0 def __init__(self, company, details): self._...
0fc5fb6cca78f5a59778b6cfb3f38131eae186ec
childe/leetcode
/add-digits/solution.py
1,380
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ https://leetcode.com/problems/add-digits/ Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up: ...
b58b0dbd0d8180852362bbe7fa889fbc8506e80b
santhosh-kumar/AlgorithmsAndDataStructures
/python/problems/dynamic_programming/wildcard_matching.py
2,662
4.125
4
""" Wildcard Matching Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). Note: s coul...
3a1b03bbe91fccda2bd5396b0dac5c927b2b536a
halysl/python_module_study_code
/src/study_cookbook/3数字日期和时间/精准的浮点数运算.py
1,811
3.765625
4
# -*- coding: utf-8 -*- from decimal import Decimal from decimal import localcontext def unprecision(): a = 4.2 b = 2.1 print("{0}\n{1}\n{2}\n".format(a, b, a+b)) print("(a + b) == 6.3 >>> {0}".format((a + b) == 6.3)) def precision(): # decimal 模块的一个主要特征是允许你控制计算的每一方面,包括数字位数和四舍五入运算。 a = Deci...
f6ff9a6f67ef5ea319001ea4a89d51e5ced373d1
gabrielsalless/python-tutor
/Exercicios anteriores/ex019.py
290
3.734375
4
import random primeiro=input('Digite o primeiro aluno: ') segundo=input('Digite o segundo aluno: ') terceiro=input('Digite o terceiro aluno: ') quarto=input("Digite o quarto aluno: ") lista = [primeiro,segundo,terceiro,quarto] print ('O aluno escolhido foi {}'.format(random.choice(lista)))
7d08ab38a7ef4ddcbce9b5916cc4177dc1c5f6ed
anchall21/HealthAccess
/API connection_1.py
1,843
4.0625
4
""" HealthAccess team Primary Author: Abhilash Biswas Objective: This program takes in 2 parameters a)User's location b)Destination location and uses Google Map's API to calculate the distance between the 2 locations For our app, we can use this program to create a travel time table f...
1e711033434ac5d74dae39f7b9f5bd0812ef1565
guangfnian/PAT
/advanced/1108/1108.py
703
3.59375
4
n = int(input()) cnt, sum = 0, 0 for x in input().split(): f = 1 k = 0 try: k = float(x) except: f = 0 if f == 0: print('ERROR: %s is not a legal number' % x) continue if k > 1000 or k < -1000: print('ERROR: %s is not a legal number' % x) ...
f75d40528f9b271bd21854654f252442ed2abfdf
fordham-css/TryPy
/Tutorials/jeeves.py
3,214
4.15625
4
''' jeeves.py ---------- Robot to suggest outfit based on the weather - Variables - Conditionals ---------- Python Demo Workshop, March 22nd 2017 ''' #### Declaring variables in Python # Good news: No need to lock variable to a type! # Bad news: No real implementation of constant variable types... # Integer Da...
fe1a760204cf99ccce7fccd1bf4bc59a800d330f
T-Corazon/CodeChallenge
/Hard/transactionsStability.py
2,705
4.0625
4
#~ You're working in a big bank with a lot of money transactions everyday. #~ Your boss gave you a task to increase the stability of your system. #~ After some thinking you came up with the following way for determining #~ the stability of the set of transactions: if you have n transactions, #~ ith of which was mad...
43b2a69cc9becf71e19bc8ea5bbbf8ec3ffb7151
TomiSar/ProgrammingMOOC2020
/osa09-11_havaintoasema/src/havaintoasema.py
1,454
3.6875
4
# Luokan kaikkien attribuuttien pitää olla asiakkaalta piilossa. Saat itse päättää luokan sisäisen toteutuksen. # Havaintoasema, johon voidaan tallentaa säähavaintoja nimi (str), havainnot (int) ja viimeisin havainto (str) class Havaintoasema: def __init__(self, nimi: str): self.__nimi = nimi s...
bfd4f6527a8e8a6a45b089399e8fdff0f900660a
lucashsbarros/Python_Curso
/Mundo 1/aula 08a UTILIZANDO MODULOS.py
1,374
4.59375
5
''' Nessa aula, vamos aprender como utilizar módulos em Python utilizando os comandos import e from/import no Python. Veja como carregar bibliotecas de funções e utilizar vários recursos adicionais nos seus programas utilizando módulos built-in e módulos externos, oferecidos no Pypi.''' '''Importa todas as "bebidas e ...
340f27c3bbae962830f73671578325af1a2917fc
chamoddissanayake/Video-Editor-QA-Extractor
/model/speaker.py
378
3.5
4
class Speaker: def __init__(self): self.lecturerCount = 0 self.studentCount = 0 def increaseLecturerCount(self): self.lecturerCount += 1 def increaseStudentCount(self): self.studentCount += 1 def ifLecturer(self): if self.lecturerCount > self.studentCount: ...
a27ecb663f41e2421771329f8a8387340897bf4a
Marcopy123/EMDR
/Desktop/EMDR/EMDR.py
1,385
3.578125
4
import pygame import time pygame.init() FPS = 120 fpsClock = pygame.time.Clock() WIDTH = pygame.display.Info().current_w HEIGHT = pygame.display.Info().current_h screen = pygame.display.set_mode((WIDTH, HEIGHT)) done = False pos = [int(WIDTH/2), int(HEIGHT/2)] ballColor = (42, 68, 148) backgroundColor = (121, 199...
1d5c069f108d49b463a047d002bbdfb76626088e
zjphftl/pychildren
/group2/pavement/main.py
681
3.515625
4
import pygame, sys pygame.init() screen = pygame.display.set_mode((480, 320)) class Tile(pygame.sprite.Sprite): def __init__(self, image): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load(image) self.rect = self.image.get_rect() self.rect.bottom = 320 self...
23031f003a00ca6a0ea0a3879e343ad11862d6eb
ishaniray/Python-Basics
/rovarspraket.py
2,037
4.125
4
""" Rövarspråket (English: The Robber Language) is a Swedish language game. Every consonant is doubled, and an 'o' is inserted in-between. Vowels are left intact. For example, 'stubborn' in Rövarspråket would be expressed as 'sostotubobboborornon'. """ # Function to check if the character passed is a vowel def ...
b28bb1ed72898f4b61787cf2ec04577dc0685abb
Erritro/zadania_p
/zadanie23.py
793
3.828125
4
# Napisz funkcję, która pobiera # macierz i oblicza średnią wszystkich # jej elementów wiersze = int(input("Podaj liczbę wierszy macierzy: \n")) macierz = [] def srednia(macierz): lista = [] #lista to macierz spłaszczona do 1 wymiaru for wiersz in range(len(macierz)): for kolumna in range(len...
54fc05d0bad363e1aa47e1621c4bff8fb74e6bde
phyogitty/rass-ciscohackathon
/track1/buildDatabase.py
1,473
3.53125
4
import sqlite3 import mysql.connector # TODO: Write proper documentation class DatabaseHandler: def __init__(self): self.conn = sqlite3.connect('rass.db') self.cur = self.conn.cursor() self.cur.execute(""" CREATE TABLE IF NOT EXISTS emails( id INT PRIMARY KEY, ...
7c0a8bf323ebd2e147f2a26ff4546eb7f9c05d2d
nsbhoangmai/Ph20
/load.py
298
3.6875
4
def load_num(filename): """ Load variables x0, v0, t, h from a plain-text file and return these as a list. """ with open(filename) as vari: A0 = vari.read().split() A1 = [] for i in A0: i1 = float(i) A1.append(i1) return A1
b1d78a7dde7d8c2f39256d180b884267ea145a56
Rijipuh/pythonCIT
/Class/Python/numberTypes.py
582
3.84375
4
x = 1 y = 2.8 z = 1j print(type(x)) print(type(y)) print(type(z)) stringThree = "3" numberThree = 3 stringTwo = "2" numberTwo = 2 print (numberTwo + numberThree) print( stringTwo + stringThree) # print(numberTwo + stringTwo) : this code is not working becuase it adds string with number. # stringTwo = int(2) : not g...
46157989652007add3e453a4da2ee08605cc8deb
jennyyu73/projecteuler
/truncatablePrimes.py
702
3.859375
4
def isPrime(n): if n < 2: return False elif n == 2: return True elif n % 2 == 0: return False maxFactor=round(n**0.5) for i in range(3, maxFactor+1, 2): if n % i == 0: return False return True def isRightTruncatablePrime(n): while n > 0: if not isPrime(n): print(n) return Fal...
0303d3442ddc58878d25b0a316b3a7b1912befb5
parksjsj9368/TIL
/ALGORITHM/BAEKJOON/SOURCE/02. Implemented(구현)/12. 문자가 몇갤까.py
136
3.671875
4
import re while 1: data = input() if data == '#': break print(len(set(re.sub('[^A-Z]', '', data.upper()))))
0e709f1b933447d013b954ca3e28cda2b40da513
Darya1501/Python-course
/lesson-14/Password-generator.py
2,848
3.765625
4
import random def ask_question(question, sets): global enabled_chars print('Если в пароле нужны', question, 'введите Да: ') answer = input().lower() if answer.strip() == 'да': enabled_chars += sets def generate_password(length, chars): password = ' ' if length > 0: ...