blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
b5fa47092ffc8d0a9f927d9769edc5d41daa6aa4
MayowaLabinjo/Guessing-game
/Guessing game.py
421
4.1875
4
import random highest=10 answer=random.randrange(highest) guess=input("guess a number from 0 to %d: " % highest) while(int(guess)!=answer): if(int(guess)<answer): print ("answer is higher") else: print ("answer is lower") g...
true
a11123124c72d59f1eddcef83eaed890c8d5b9c0
jbking/pythonista-misc
/python_math/fibonacci_graph.py
542
4.15625
4
import matplotlib.pyplot as plt def draw_graph(final): if final <= 1: raise ValueError("specify number bigger than 1") fibonacci = [1, 1] for _ in range(final - 2): fibonacci.append(fibonacci[-1] + fibonacci[-2]) ys = [fibonacci[x + 1] / fibonacci[x] for x in range(len(fibonacci)...
false
e7724794b94a65e9a7f6aae136d821de1f33698a
vagmithra123/python
/Operators.py
1,353
4.15625
4
#range, only stop for num in range(10): print(num) #range , start, stop for num in range(2, 10): print(num) #range , start, stop, step for num in range(2, 10, 2): print(num) print(list(range(0, 11, 2))) #Generator is a special type of function, it will generate information instead of saving it all to memory. in...
true
852c417315a6eb604da0c9f1ca1d3a016c062a81
vagmithra123/python
/FunctionsPracticeExercises.py
2,821
4.125
4
''' LESSER OF TWO EVENS: Write a function that returns the lesser of two given numbers if both numbers are even, but returns the greater if one or both numbers are odd lesser_of_two_evens(2,4) --> 2 lesser_of_two_evens(2,5) --> 5''' def lesser_of_two_evens(a, b): if a%2 == 0 and b%2 == 0: return min(a,b) elif a%2...
false
1db8c24dbf53530312c12a4c105312e55853ab60
dhsabigailhsu/y1math
/t01primeshcflcm_evennumbers.py
255
4.25
4
# What are the even numbers from 1 to num? #num is 123 num = 123 #execute a loop from 1 to 123 for i in range(1, num+1): #check if the current number is divisible by 2 if i % 2 == 0: #print out the number, in the same line print(i, end=' ')
true
bc0dcb7241bbb3d6860b2cf1e71c2adcfa4c4f1a
cassiakaren/ULTIMA-LISTA
/ex2.py
716
4.375
4
#2) Refaça o exercício da questão anterior, imprimindo os retângulos sem preenchimento, #de forma que os caracteres que não estiverem na borda do retângulo sejam espaços. largura = int(input("Coloque a largura: ")) print("") altura = int(input("Coloque a altura: ")) print("") caractere = "#" def retângulo(largura, a...
false
13c90534c5dd14fe60cfeef25d6f14dd2c3648ab
clebertonf/Python-ciencia-da-computacao
/001-bloco-33-01/003-funcoes.py
2,001
4.21875
4
# definição de funçoes # parametros posicionais def soma(a, b): return a + b print(soma(10, 50)) # parametros nomeados print(soma(b=40, a=120)) # Os parâmetros também podem ser variádicos. Ou seja, podem variar em sua quantidade. # Parâmetros posicionais variádicos são acessados como tuplas no interior de uma...
false
6967353bd2cd897f2b93df03d855c2255380a48d
LucyMbugua/python_bootcamp
/intro_to_python/strings.py
612
4.3125
4
firstName = 'Lucy' lastName = "Wanjiku" print(type(firstName)) print(type(lastName)) #string indexing = retrieve certain character from a string #positive indexing print(firstName[0]) print(firstName[3]) #negative indexing print(firstName[-4]) #string slicing institution = "Techcamp" #positive slicing print(insti...
false
e188153fc3bae693a94f3d1cdb6cb5bb6683af4b
LucyMbugua/python_bootcamp
/practice_tasks/pythonbasics.py
2,170
4.25
4
#TASK 1: # Write a program which accepts a string as input to print "Yes" if the string is "yes", "YES" or "Yes", otherwise print "No". # Hint: Use input () to get the persons input string = input("Enter a string:") if string == "yes" or string == "YES" or string == "Yes": print("Yes") else: print("No") """...
true
f4ccec5460ab8e338326978451907f2fb71edf0a
ofbozlak/alistirma1
/dongu_yapilari/armstrong_sayi.py
749
4.28125
4
""" Kullanıcıdan aldığınız bir sayının "Armstrong" sayısı olup olmadığını bulmaya çalışın. Örnek olarak, Bir sayı eğer 4 basamaklı ise ve oluşturan rakamlardan herbirinin 4. kuvvetinin toplamı ( 3 basamaklı sayılar için 3.kuvveti ) o sayıya eşitse bu sayıya "Armstrong" sayısı denir. Örnek olarak : 1634 = 1^4 + 6^4 + ...
false
efb0a0ff7d4a195ced46dacb9b8cc5bef1e9391a
varghesechacko/PracticePython
/Exercise1.py
850
4.21875
4
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. # Extras: # Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. (Hint: ...
true
a4e582bfb6d450c57afdf516e69bb0ceae45880d
jmartinknoll/PY4E
/exercise3.1.py
459
4.125
4
# calculate gross pay (user input) # find the breakdown of how much of the gross pay is regular pay and overtime pay # 1.5x pay for overtime x = input('enter hours: ') y = input('enter rate of pay: ') hours = float(x) payrate = float(y) if hours > 40 : print('overtime') regpay = hours * payrate otpay = (hou...
true
edf032ebdb1ee2ba3a9403c5daabd748faf05d92
jmartinknoll/PY4E
/exercise7.2.py
873
4.375
4
# Write a program to prompt for a file name, and then read # through the file and look for lines of the form: # X-DSPAM-Confidence: 0.8475 # When you encounter a line that starts with “X-DSPAM-Confidence:” # pull apart the line to extract the floating-point number on the line. # Count these lines and then compute the t...
true
2d56cebf279f5333ab4139fc5299ad96c2fd43cf
jmartinknoll/PY4E
/exercise10.2.py
802
4.15625
4
# This program counts the distribution of the hour of the day # for each of the messages. You can pull the hour from the “From” line # by finding the time string and then splitting that string into parts using # the colon character. Once you have accumulated the counts for each # hour, print out the counts, one per lin...
true
bb4d1b7eb0f74274f3da3243dbab87a421041def
jmartinknoll/PY4E
/exercise9.4.py
966
4.34375
4
# Add code to the program in exercise 9.3 to figure out who has the # most messages in the file. After all the data has been read and the dictionary has been created, # look through the dictionary using a maximum loop (see Chapter 5) to find who has # the most messages and print how many messages the person has. fnam...
true
bc2ff903e559b4010ae4b52aea7afe6867a1cb3a
KiranJungGurung/tip-calculator
/main.py
1,187
4.375
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 #Format the result to 2 decimal places = 33.60 # Print welcome to the tip calculator. print("Welcome to the tip calculator.") #Assign bill,tip and people as a variable name. bill = float(input("What was...
true
211dd14fb065f37996f918e3543851ec7824d00f
Humayungithub/TextEditor
/TextEditor.py
1,317
4.15625
4
#import tkinter from tkinter import * #import filedialog from tkinter.filedialog import * filename = None def newFile(): global filename filename = "untitled" text.delete(0.0, END) def saveFile(): global filename t = text.get(0.0, END) f = open(filename, 'w') f.write(t) f.close() def...
true
56e17ec36959de88aa5eecd836a0e7fb907b2633
melvinm4697/cti110
/P4T2_BugCollector_MorinekiMelvin.py
458
4.28125
4
# This program will calculate total bugs collected over 5 days # March 31, 2020 # CTI-110 P4T2 - Bug Collector # Morineki Melvin # # Set total to 0 # Enter bugs collected each day for five days # Add the bugs collected for the five days # Display the total amount of bugs collected total = 0 for day in ran...
true
66bee0c1e0f28c4d18c0afd73bd6da748657b64d
gabrielb09/Python-For-Lab
/Chp. 2 Problem 1/Problem1.py
1,007
4.25
4
#INSTRUCTIONS: run the program, it will print the information to the command line. #creates a function for calculating the Height and Velocity of the projectile def HandV (h,v,t): #calculates Height based on initial height, velocity, and time H = h + (v*t) - 4.9*(t**2) #calculates Velocity based on initial ...
true
93611faabdd036b15be790cf9c2f4a8690fc5ef0
ArishaGo99/Python
/LAB_3/LAB_3.py
642
4.25
4
#Развлетвляющиеся вычислительные процессы. #Задание2 from math import * flag=0 print('Введите значение R ') R=float(input('R=')) print('Введите координаты точки') x=float(input('X=')) y=float(input('Y=')) if (x>R) or (y>R) or (x < -R) or (y < -R): flag=0 elif ((y<=sqrt(R**2-x**2) and (x>=0))) or ((y>=-R) \ and...
false
fd1ad85c9b81fc0949ea0ceb836cbd432fbb9496
rajivmanivannan/learning-python
/src/basics/functions.py
2,579
4.6875
5
#!/usr/bin/env python3 # encoding= utf-8 """ Functions A function is a block of code that takes in some data and, either performs some kind of transformation and returns the transformed data, or performs some task on the data, or both. Functions are useful because they provide a high degree of modularity. Similar ...
true
df30f6702a20868ccceac3a84b29a185c993401d
DanielDrex/Introduccion-python
/Scripts-DS/Numpy.py
715
4.1875
4
#Importamos las librerias de array y numpy import array as a import numpy as np L = list(range(10)) A = a.array('i',L) print(A) #Creacion de arreglos desde listas de python print(np.array([1,2,3,4,5],dtype='float32')) #Creacion de arreglos multidimensionales print(np.array([range(i,i+3) for i in [2,4,6]])) print(np...
false
c7246a27cc3c9afa67b060b09de5d4267d5d8338
StevenR152/Connect4-Python
/code/main.py
2,149
4.1875
4
def print_board(board): print("Printing the board...") # write code that prints the board 2d array def get_user_input(valid_inputs, player): users_input = input("Enter the move for player " + str(player) + ":") print("User entered: " + users_input) # TODO Use valid_inputs to check the users input ...
true
dcb88a1be04cd3f87f50c65209203ed44c8b8d1c
DanieleMagalhaes/Exercicios-Python
/Mundo1/convMedidas.py
452
4.125
4
metro = float(input('Digite uma distancia em metros: ')) km = metro / 1000 hm = metro / 100 dam = metro / 10 dm = metro * 10 cm = metro * 100 mm = metro * 1000 print('A distancia de {} metros corresponde a: '.format(metro)) print('{} Quilômetros'.format(km)) print('{} Hectômetros'.format(hm)) print('{} Decâmetros'.form...
false
aee1648e7f57b8951bc4475a10240d9b62661045
DanieleMagalhaes/Exercicios-Python
/Mundo1/hello.py
541
4.125
4
nome = input('Qual é o seu nome? ') print('\nOlá {}!' .format(nome) , ' Seja bem-vinda! \n') print ('Quando você nasceu?') dia = input ('DIA = ') mes = input ('MES = ') ano = input ('ANO = ') print ('Você nasceu no dia' , dia , 'de' , mes , 'de' , ano ,'. Correto?') print('\nVamos somar dois números?') num1 = int(inp...
false
4313e649e845d28f81c91ee484d3d844c7554faa
Prince7862/Number-Guessing-Game
/numberguessingGame.py
686
4.15625
4
import random; chances = 0 randomNum = random.randint(1,9) #print(randomNum) #a = (randomNum > number) #print(type(number)) #print(a) while(chances < 5): chances = chances + 1 number = int(input("Guess a Number from 1 to 9: ")) if(number < randomNum): print("The number you have entered is...
true
9a34ae5932e673a307c07cc91f4a305c7d13c680
Tanishk-Sharma/Data-Structures-and-Algorithms
/Data Structures/Queue.py
1,238
4.375
4
class Queue: def __init__(self): #Constructor creates a list self.queue = list() def enqueue(self,data): #Adding elements to queue if data not in self.queue: #Checking to avoid duplicate entry (not mandatory) self.queue.insert(0,data) ...
true
4c07495d4ac8161878fd8f34282e57023c59b4c1
michaelGRU/temp
/lists20.py
977
4.375
4
# data type: list (mutable) # create a list names = ["Chloe", "Victoria", "Jackson"] # find the index of an item names.index("Jackson") # loop through the list for i, name in enumerate(names): pass # print(f"{name} is in index {i}") # adding items: append, insert names.append("Michael") names.insert(...
true
754d28fec133038d9e44f139c1ad1972d1d9e620
michaelGRU/temp
/dic20.py
413
4.1875
4
# dictionary # indexed by keys, can be any immutable type d = {"pet": "dog", "age": 5, "name": "kgb"} print(type(d)) d = dict(pet="dog", age=5, name="spot") print(d.items()) print(d.keys()) print(d.values()) print(d["pet"]) # add an item d["add"] = "sit" # remove an item del d["add"] # the value as...
true
fa9127a292ada7a481b87cd997128e923aaf9a26
GeekGirlDee/FirstProjectWithTakenMind
/FirstProject/venv/Pandas/Pandas Statistics.py
2,036
4.4375
4
from pandas import Series, DataFrame import numpy as np from numpy.random import randn import matplotlib.pyplot as plt # 2d array # np.nan stands for non value array1 = np.array([[10, np.nan, 20], [30, 40, np.nan]]) print array1 # creating a Data Frame # this dataframe will print out the index which is the row number...
true
ca6eadf33cfef18f5767d072dbadf72980f14742
oxygenJing/Big-Data-exercise
/feature-engineering-with-pyspark/No16-Calculate-Missing-Percents.py
1,170
4.5
4
#Calculate Missing Percents ''' Automation is the future of data science. Learning to automate some of your data preparation pays dividends. In this exercise, we will automate dropping columns if they are missing data beyond a specific threshold. Instructions 100 XP Define a function column_dropper() that takes the pa...
true
6be955db0f313c5af57520a9e3b6e9bad7f35854
oxygenJing/Big-Data-exercise
/feature-engineering-with-pyspark/No12-caling-your-scalers.py
2,292
4.40625
4
#Scaling your scalers ''' In the previous exercise, we minmax scaled a single variable. Suppose you have a LOT of variables to scale, you don't want hundreds of lines to code for each. Let's expand on the previous exercise and make it a function. Instructions 100 XP Define a function called min_max_scaler that takes p...
true
726157b25bec6fd17c28310b5e25a6e22c7e79ce
oxygenJing/Big-Data-exercise
/big-data--fundamentals-pyspark/No32-Loading-spam-and-non-spam-data.py
2,044
4.28125
4
#Loading spam and non-spam data ''' Logistic Regression is a popular method to predict a categorical response. Probably one of the most common applications of the logistic regression is the message or email spam classification. In this 3-part exercise, you'll create an email spam classifier with logistic regression usi...
true
c8a9a041e3bf8a1b22ff94f3532db84929554205
oxygenJing/Big-Data-exercise
/big-data--fundamentals-pyspark/No37-Visualizing-clusters.py
1,491
4.125
4
#Visualizing clusters ''' After KMeans model training with an optimum K value (K = 15), in this final part of the exercise, you will visualize the clusters and their cluster centers (centroids) and see if they overlap with each other. For this, you'll first convert rdd_split_int RDD into spark DataFrame and then into P...
true
fbbf3b764a4bcec5c900e1c9c45b70b235b2cbfd
KruZZy/magic-of-computing
/perm_backtracking.py
857
4.125
4
def backtrack(depth, max_level): global solution, appears ## in Python, global variables used inside a function definition should be mentioned beforehand. if depth <= max_level: ## if depth reaches max_level, we have generated a permutation. for i in range(1, max_level+1): if appears[i] == F...
true
054510812ff367b36335420214408a41f13a00a9
python-kurs-sda/python-kurs
/zadania_domowe/liczby_pierwsze.py
871
4.15625
4
""" Napisz funkcje stwierdzajaca czy podana jako argument liczba jest liczba pierwsza czy nie. Liczba jest pierwsza, kiedy dzieli sie tylko przez siebie i przez 1. Jednym z algorytmow wyszukiwania liczb pierwszych jest sprawdzenie czy zadna z liczb od 2 do LICZBA-1 (lub od 2 do pierwiastek z LICZBA)...
false
97621a05f4e5632190b12bd08275ad6510fa850a
BrunoVittor/pythonexercicios
/pythonexercicios/pythonexercicios/ex085.py
589
4.25
4
#Exercício Python 085: # Crie um programa onde o usuário possa digitar sete valores numéricos e cadastre-os em uma lista única que mantenha separados os valores pares e ímpares. # No final, mostre os valores pares e ímpares em ordem crescente. lista = [[], []] valor = 0 for c in range(1, 8): valor = int(input(f'D...
false
b0f806ba4c57e9266dc436b4919d80dd99b55858
BrunoVittor/pythonexercicios
/pythonexercicios/pythonexercicios/ex088.py
1,304
4.15625
4
# Exercício Python 088: Faça um programa que ajude um jogador da MEGA SENA a criar palpites. # O programa vai perguntar quantos jogos serão gerados e vai sortear 6 números entre 1 e 60 para cada jogo, cadastrando tudo em uma lista composta. from random import randint for x in range(int(input("Digite quantidade de jo...
false
845dfa9e7e10caba0ea4862866f7138b0f3a3542
poojitha2803/lab-programs
/lab exp-4.4.py
760
4.40625
4
4.4) In algebraic expressions, the symbol for multiplication is often left out, as in 3x+4y or 3(x+5). Computers prefer those expressions to include the multiplication symbol, like 3*x+4*y or 3*(x+5). Write a program that asks the user for an algebraic expression and then inserts multiplication symbols where approp...
true
672843b94c411d5121eeccf9637ca26e68895620
ectom/Coding-Dojo-Python-Stack
/1 - python_fundamentals/dictionary.py
250
4.125
4
def dictionary(): dict = { 'name' : 'Ethan Tom', 'age' : '20', 'country of birth' : 'The United States', 'favorite language' : 'python' } for i in dict: print "My " + i + " is " + dict[i] dictionary()
false
bb2d174195cab59c27f2006540c6389f5934bc60
TLyons830/The-Tech-Academy-Basic-Python-Projects
/Python_if.py
278
4.21875
4
num1 = 10 key = False if num1 == 12: if key: print('num1 is EQUAL to 12 and they have the key') else: print('num1 is EQUAL to 12 and they DO NOT have the key') elif num1 < 12: print('num1 is LESS than 12') else: print('num1 is GREATER than 12')
true
92e7aefdb2813c3da5c2d27bd398aaf1f5ece125
IliaIliev94/cs50-psets
/pset6/mario.py
833
4.46875
4
from cs50 import get_int # Main function which calls the get input function and prints the piramid def main(): height = get_user_input() # Prints the piramid on the basis of the number of rows the user has given as input in the height variable for i in range(height): for j in range(i + 1, heigh...
true
6da71344509a6de17ab0334682d7938a1bb5d9b6
niniyao/PythonCrashCourse
/Chapter 4/TryitYourself_4_13 copy.py
315
4.1875
4
my_foods = ['pizza', 'falafel', 'carrot cake'] friend_foods = my_foods[:] my_foods.append('cannoli') friend_foods.append('ice cream') print("my favoriate foods are:") for my_food in my_foods: print(my_food) print("\nmy friend's favoriate foods are:") for friend_food in friend_foods: print(friend_food)
false
1c00dfda6bbdbcb31d471be6dfa3a9ad0fdcfcd5
ZhangzhiS/study_note
/Algorithm/binary_search_tree.py
2,232
4.34375
4
""" 二叉查找树(英语:Binary Search Tree),也称为二叉搜索树、有序二叉树(ordered binary tree)或排序二叉树(sorted binary tree),是指一棵空树或者具有下列性质的二叉树: 1. 若任意节点的左子树不空,则左子树上所有节点的值都小于他的根节点的值。 2. 若任意节点的右子树不空,则右子树上所有节点的值都大于他的根节点的值。 3. 任意节点的左右子树也分别为二叉查找树。 4. 没有键值相等的节点 二叉查找树于其他数据结构的优势在于查找、插入的时间复杂度较低。为O(log n)。 来源于:https://zh.wikipedia.org/wiki/%...
false
fdd668a446e26600bc06b2d3a6c648a63271b270
chen808/python_fundemental_assignments
/assignment_10_Regular_Expression_findword.py
816
4.1875
4
# importing 're' to use Regular expression import re str = 'an example word:cat!!' match = re.search(r'word:\w\w\w', str) # If-statement after search() tests if it succeeded if match: print 'found', match.group() ## 'found word:cat' else: print 'did not find' # searches to see if word 'Bat'...
true
9a07f9201feedb1002445d2a7cc44cebe85cbd3c
mskenderovicGH/Data-Structures-Implementation-Python
/HeapValidation.py
407
4.125
4
# this function will check if heap is as it should be def heap_check(heap): i=0 while (2 * i + 1) < len(heap): if heap[i] < heap[2*i+1] and heap[i] < heap[2*i+1]: print('ok') else: print('bad') return False i = i + 1 return True if _...
false
bf5d3eb1e0644ff2c6e1e756f0874778f4022df0
monica-cornescu/learn_python_hackerrank-30-days
/hackerrank_day7.py
484
4.15625
4
#Given an array, , of integers, print 's elements in reverse order as a single line of space-separated numbers. import math import os import random import re import sys if __name__ == '__main__': n = int(input()) arr = list(map(int, input().rstrip().split())) reverseArr = arr[::-1] for ele...
true
73a0b4c8c0c52a314801f74957c52f34069d8d4b
Katiedaisey/Projects
/Solutions/factorial_finder.py
643
4.3125
4
# **Factorial Finder** - # The Factorial of a positive integer, n, is defined as # the product of the sequence n, n-1, n-2, ...1 and the # factorial of zero, 0, is defined as being 1. # Solve this using both loops and recursion. def factorial(num): if num < 2: fact = 1 else: fact = num * factorial(num - 1) ...
true
b2f4654953d024fe23e34af66d4f6922e29b9970
ScottLoPinto/ToyProblems
/src/2021/june/2/switch_sort.py
1,835
4.40625
4
# Have the function SwitchSort(arr) take arr which will be an an array consisting of integers # 1...size(arr) and determine what the fewest number of steps is in order to sort the array # from least to greatest using the following technique: Each element E in the array can swap # places with another element that is ...
true
81600d0a5d82922f89ff10b94157f24de6752067
psnehas/PreCourse-2
/Exercise_3.py
1,226
4.25
4
# Time complexity:O(n) # Space complexxity: O(1) # Node class class Node: # Function to initialise the node object def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): newNode = ...
true
34bea9ae596a785783149b1c97ad0339d63079f8
davidknoppers/interview_practice
/codewars/triplet_sums.py
1,609
4.34375
4
#!/usr/bin/python3 #we import random to generate random arrays to test the algo import random """ triplet_sums finds all groups in an array that add up to the target sum The array and target are both supplied by the user """ def triplet_sums(arr, target): #sort the array to make subsequent subroutines much faster ...
true
e36fc7cb4cd92bbb359491a3e477e059b6379b74
GururajM/SimpleCalculation
/simple_calculation/simple_calculation/logic/calculator.py
2,334
4.40625
4
class Calculator: """ A class used to represent a basic calculator that performs an arithmetic operation on two operands ... Attributes ---------- operand_1 : int An interger value that represents the first operand operand_2 : int An interger value that represents the first op...
true
7c122b2ceeb257b19178075d1b7accb63ed7b5c9
anujvyas/Data-Structures-and-Algorithms
/Data Structures/3. Linked List/node_swap_sll.py
1,193
4.125
4
# Swap two nodes in a given linkedlist without swapping data from singly_linked_list import Node, LinkedList def swap_node(head, x, y): # If both values are same if x == y: return head # Find x prevX = None currX = head while currX != None and currX.data != x: prevX = currX currX = currX...
true
f98705a18fb7e34b4e4a3ba8292aa01d05409e77
honghaoz/DataStructure-Algorithm
/Python/Cracking the Coding Interview/Chapter 5_Bit Manipulation/5.6.py
746
4.21875
4
from Bit import * from operator import xor # Write a program to swap odd and even bits in an integer with as few instructions as possible # (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, and so on) # Suppose 32-bit integer def swapOddWithEven(num): oddMask = bitToInt("010101010101010101010101010101...
true
a40e3892dd553267873b17ec1ebecbbadd9e8415
honghaoz/DataStructure-Algorithm
/Python/LeetCode/ZigZag Conversion.py
1,616
4.21875
4
# ZigZag Conversion # The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) # P A H N # A P L S I I G # Y I R # And then read line by line: "PAHNAPLSIIGYIR" # Write the code that will take a...
true
3d21be7ff3d017b4cf4685049a63194743820f83
honghaoz/DataStructure-Algorithm
/Python/Cracking the Coding Interview/Chapter 7_Mathematics and Probability/7.4.py
1,594
4.21875
4
# Write methods to implement the multiply, subtract, and divide operations for integers. # Use only the add operator. # multiply def multiply(a, b): summ = 0 if b == 0: return 0 elif b > 0: for i in xrange(b): summ += a return summ else: for i in xrange(b, 0): summ += a return negate(summ) def sub...
true
8b807ed989dddfecc2e89f7632ca3da1f6ac1f47
caveman0612/python_fundeamentals
/03_more_datatypes/4_dictionaries/03_17_first_dict.py
261
4.125
4
''' Write a script that creates a dictionary of keys, n and values n*n for numbers 1-10. For example: result = {1: 1, 2: 4, 3: 9, ...and so on} ''' dict = {} for i in range(1, 11): value = input(f"input value for {i} key") dict[i] = value print(dict)
true
dedf0e77eb39d7ff8d20d1a79162f43187ce3248
caveman0612/python_fundeamentals
/03_more_datatypes/3_tuples/03_16_pairing_tuples.py
691
4.5
4
''' Write a script that takes in a list of numbers and: - sorts the numbers - stores the numbers in tuples of two in a list - prints each tuple If the user enters an odd numbered list, add the last item to a tuple with the number 0. Note: This lab might be challenging! Make sure to discuss it with your me...
true
d124098dda95e3b66e6a78d6d9f65ea76525b1b1
salisquraishi/Python-programming-1
/codes/program17.py
1,957
4.34375
4
# A website requires the users to input username and password to register. # Write a program to check the validity of password input by users. # Following are the criteria for checking the password: # 1. At least 1 letter between [a-z] # 2. At least 1 number between [0-9] # 1. At least 1 letter between [A-Z] # 3. At l...
true
86be9953fb3c6ce6071970af31f4b614ea976e6c
salisquraishi/Python-programming-1
/codes/program29.py
581
4.3125
4
# Define a class named Shape and its subclass Square. # The Square class has an init function which takes a length as argument. # Both classes have a area function which can print the area of the shape # where Shape's area is 0 by default. class Shape(): def __init__(self): pass def area(self): ...
true
db651349442682ab85e0b52b8a136ba374fc9663
salisquraishi/Python-programming-1
/codes/program41.py
425
4.1875
4
# Please write a program which count and print the numbers of each character in a # string input by console. # Example: # If the following string is given as input to the program: # abcdefgabc # Then, the output of the program should be: # a,2 # c,2 # b,2 # e,1 # d,1 # g,1 # f,1 count = {} s = input(">") for c in l...
true
1ac3343ed21639ba7e243b65f6abc69d5e04e4ed
predatory123/byhytest
/python_practice/python0525/001.py
553
4.25
4
#定义一个汽车类 class car(): def __init__(self,make,model,year): # 描述汽车的3个属性 self.make = make self.model = model self.year = year #定义一个汇总信息的方法 def get_desciptive_name(self): long_name = str(self.year) + ' ' + self.make + ' ' + self.model return long_name.title() #调用类和方法 class ne...
false
52de20c4cb0d29595026a8690a3f1d566040ba66
11Vladimir/algoritm
/lesson_3/task_7.py
481
4.15625
4
#!/usr/bin/python3.8 # 7. В одномерном массиве целых чисел определить два наименьших элемента. # Они могут быть как равны между собой (оба являться минимальными), так и различаться. from random import randint array = [randint(1, 20) for i in range(10)] print(array) min1 = min(array) array.remove(min1) min2 = mi...
false
8ea531d7828985ff3649b1bc809d6225226a0aa0
vpivtorak/Python-home-work
/home work 1 hard.py
605
4.1875
4
print("Здравствуйте, введите:") a = str(input('Имя:')) b = int(float(input('Возраст:'))) c = int(float(input('Вес:'))) if c > 50 and c < 120 and b < 35: print (a,', ' 'у вас отличное здоровье') elif c < 50 or c > 120 and b < 35: print(a,', ' 'вам стоит изменить образ жизни') elif c < 50 or c > 120 and b > 45: ...
false
144bee13861744e0a7dd3fd7606e6d906121c43b
Graham-CO/ai_ml_python
/chapter_4/ReLU_applied.py
1,015
4.15625
4
# Graham Williams # grw400@gmail.com # Apply ReLU activation function to a dense layer import numpy as np import nnfs from nnfs.datasets import spiral_data nnfs.init() class Layer_Dense: def __init__(self, n_inputs, n_neurons): self.weights = 0.01 * np.random.randn(n_inputs, n_neurons) self.b...
true
4861446c3fd28a9c675bb295a64895de73c2d8bb
Philosocode/python-stuff
/recursion/factorial.py
380
4.21875
4
""" Factorial of 5: 5 * factorial(4) = 120 4 * factorial(3) = 24 3 * factorial(2) = 6 2 * factorial(1) = 2 """ def factorial(num): if num == 0: return 1 return num * factorial(num - 1) def iter_factorial(num): product = 1 for num in range(num, 1, -1): product *= num print(p...
false
9d4508554077b8d19e2736f10fd2186ef67058ea
fathurdanu/time-calculator
/time_calculator.py
2,545
4.3125
4
#What is n days from now? def what_day(today,how_many_days): list_of_days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] today = "".join([char.lower() for char in today]) for day in range(len(list_of_days)): now = "".join([char.lower() for char in list_of_days[day]]) if now == ...
false
6b4333b7346228c192fa2b21698629235ea873d9
nuocode/python
/python-exercise/面向对象编程/类和实例.py
1,288
4.125
4
# class Student(object): # pass # #bart是指向Student的实例 # bart = Student() # print(bart) # 返回<__main__.Student object at 0x00000230C87C9630> 0x00000230C87C9630表示内存 # print(Student) # # #给实例绑定属性 # bart.name = "Simpson Blair" # print(bart.name) #### 创建模板,绑定属性 #### # class Student(object): # # 第一个参数永远是self,指向自己,不需要传...
false
df595a116cc32bd0b410ce437495a46fd4504640
mailgurudev/python
/string_list.py
272
4.375
4
word = input(str("Enter a word ")) new_word = [] for c in word: new_word.append(c) print(new_word) print(list(reversed(new_word))) if new_word == list(reversed(new_word)): print("Its is a pallindrome") else: print("it is not a pallindrome")
true
17de56cea61b7de040969163bdc810fab2df99ea
malliksiddarth/python-program
/sid3.py
297
4.40625
4
#!/usr/bin/python3 # guess what this program does? import random r=random.randint (1,6) #give random number print(r) if r<35: print(r) print(":is less than 35") elif r==30: print("30 is multiple of 10 and 3, both") elif r>=35: print(r,"is greater than 35") else: print("your number is:",r)
true
a49580e8528396802a65a6f8112fab04ed1adede
adronkin/algo_and_structures_python
/Lesson_1/6.py
688
4.25
4
# 6. Пользователь вводит номер буквы в алфавите. Определить, какая это буква. def search_letter(num, letter_list): """По числу num возвращает символ из строки под номером num""" return letter_list[num - 1] ABC = 'abcdefghijklmnopqrstuvwxyz' LETTER_NUM = int(input('Ввидите номер буквы: ')) if 1 <= LETTER_NU...
false
ecf342a3f0a02baa168e7e55ceb2afc5033ed4ad
revanthreddy7/HacktoberFest_2021
/Python/LinkedList.py
1,103
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.last = None def __iter__(self): return self def __next__(self): def print(self): t = self.head while(t != None): print("Node:", t.data) t = t.next def print_n...
false
8d0943d7c1bec41ba89e223b676244e1b55efde7
Cherry-RB/sc-projects
/stanCode_Projects/hangmen_game/complement.py
1,023
4.46875
4
""" File: complement.py Name:Cherry ---------------------------- This program uses string manipulation to tackle a real world problem - finding the complement strand of a DNA sequence. THe program asks uses for a DNA sequence as a python string that is case-insensitive. Your job is to output the complement of it. """ ...
true
e20ffa60712f7febaf611b7d53a67c50def43b06
Cherry-RB/sc-projects
/stanCode_Projects/boggle_game_solver/largest_digit.py
1,083
4.375
4
""" File: largest_digit.py Name: ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. """ def main(): print(find_largest_digit(12345)) # 5 print(find_larg...
false
49692a5b089f09ed652d3122af53758c56d7f5bf
delos/dm-pta-mc
/src/parallel_util.py
1,791
4.3125
4
""" Collection of useful functions which handle parallelizing the main program """ import numpy as np def generate_job_list(n_proc, total_job_list): """ Will generate the job list to send to the processors. total_job_list - all of the jobs that need to be done """ n_jobs = len...
true
ea78d8f3ebbdf04c9ce4ee372c42eca87b38468b
OlehHnyp/Home_Work_4
/Home_Work_4_Task_3_v2.py
538
4.1875
4
while 1: try: number = input("""Please insert integer number and get \ Fibonacci numbers up to this number:""") if int(number) - float(number) == 0 and int(number) == abs(int(number)): break except ValueError: pass up_border = int(number) former_number = 0 next_number = 1 pr...
true
82aad93d10020fa7ad335e417f69950b53d07123
ThilinaTLM/code-juniors19
/BinaryTree.py
1,592
4.15625
4
""" Add given numbers to a binary tree. Author : Thilina Lakshan Email : thilina.18@cse.mrt.ac.lk """ ## Tree Travels ================================================================================= def getParent(ind): if ind == 0: return None return ((ind + 1)//2) - 1 def g...
true
d51481c812f3d52ed6aa662f69bf3c295985f196
vaishnavi555/ppl_assignment
/ass1_4.py
336
4.28125
4
import random print("welcome to guessing game!") no = random.randrange(1,11) for x in range(3): guess = input("guess the number from 1-10: ") if guess > no: print("guess is greater than no. !") elif guess < no: print("guess is smaller than no. !") else: print("correct guess!") break print("{} was the number...
true
4b449817b6867bce05e8ac54dad93c132cd08ed6
SUKESH127/bitsherpa
/[3] CodingBat Easy Exercises /solutions/Warmup-1/pos_neg.py
334
4.28125
4
#Given 2 int values, #return True if one is negative and one is positive. #Except if the parameter "negative" is True, then return True only if both are negative. def pos_neg(a, b, negative): if negative: return (a < 0) and (b < 0) return a * b < 0 print( pos_neg(1, -1, False), pos_neg(-1, 1, False), pos_neg(...
true
97595b723f01c5c7e07e15347554bd3d72c2580f
simon-pinkmartini/foundations
/class-02/dictionaries.py
303
4.28125
4
#Create a dictionary myself = { "name": "Simon", "age": 35, "home": "Upper East Side" } print (myself) print (myself.keys()) #Reference item in dictionary print ("My name is", myself["name"],".") #Loop through the keys for attribute in myself: print (attribute,":",myself[attribute])
true
9f737dd3188fa08adb3b1afc7a832b1a1c95b51f
bigpigbigpig/learning-python
/Python基础/3. 类中初始化方法.py
707
4.15625
4
# !/usr/bin/env python # -- coding:utf-8 -- # 小猫爱吃鱼,小猫要喝水 class Cat: '''cat link eat fish. cat need drink water. ''' def __init__(self): print("This is a init function.") def eat(self): print("%s like eat fish." % self.name) def drink(self): print("cat need drink water...
false
d03ea54828a02d741a030a29d6f7c4aa00088d3d
bigpigbigpig/learning-python
/Python基础/14. super.py
783
4.125
4
# super对父类方法的扩展 class Animal: def __init__(self): pass def eat(self): print('eat') def run(self): print('run') def drink(self): print('drink') class Dog(Animal): def bark(self): print('wang') class Xi(Dog): def fly(self): print('i can fly')...
false
6b68c4831b63781058af3d477c5598bc300015c4
CarlosVGC/Codigos-Python
/2_TiposDeDatos.py
588
4.28125
4
#Tipos de datos en python numero = 89 print(numero) print(type(numero)) print('------------------------') numeroFlotante = 16.89 print(numeroFlotante) print(type(numeroFlotante)) print('------------------------') cadena = "Esto es una cadena" print(cadena) print(type(cadena)) print('------------------------') boleano ...
false
b669363d3fdf0e5fffed7cb4e1fe67f5c19628e9
CarlosVGC/Codigos-Python
/3_OperadoresMat.py
605
4.28125
4
#Programa en el que se usan operadores matemáticos n1 = 10 n2 = 2 resultado = n1 + n2 print("La suma es: ", resultado) # se concatena entero con coma (,) resultado = n1 - n2 print("La resta es: ", resultado) resultado = n1 * n2 print("La multiplicacion es: ", resultado) resultado = n1 / n2 print("La division es: ", ...
false
fb8fec5701a6dd4bce19313ec45ba45a1e998c3a
CarlosVGC/Codigos-Python
/PI/04_Diccionarios.py
1,402
4.21875
4
# Ejemplo de uso de diccionarios ''' Estructuras que permite almacenar datos en un diccionario clave: valor Los elementos almacenados no estan ordenados, el orden es indiferente a la hora de almacenar informacion en un diccionario se pueden almacenar dentro de ellos:variables, listas, tuplas, diccionarios, ''' def dic...
false
bef5d16b5c52b3f37b2046bd452608b8af2c9de1
namratapandit/python-project1
/code/repeatloop.py
1,400
4.28125
4
# program to take 2 numeric inputs and and operation selection from user # the program repeats until the user does not exit # Perform operations like add, sub, mul, divide # keep repeating till user exits # also handle exceptions for invalid inputs def main(): validinput = False # while loop runs till valid en...
true
aa6c909edb7d736d23f630be97a28871ba10fcc9
achilles8work/Python_EDX_MIT
/polysum.py
605
4.125
4
''' Grader A regular polygon has n number of sides. Each side has length s. The area of a regular polygon is: The perimeter of a polygon is: length of the boundary of the polygon Write a function called polysum that takes 2 arguments, n and s. This function should sum the area and square of the perimeter of the regu...
true
70b5e56d8f9bf558869dde812e459bd46f975f58
pixelsomatic/python-notes
/tipos.py
651
4.15625
4
tipo = input('Coloca mais um número por favor: ') print('E {} é:\n Int -> {}\n String -> {}\n Alfanumérico -> {}'.format(tipo, tipo.isnumeric(), tipo.isalpha(), tipo.isalnum())) tipos = input('Escreve alguma coisa aí: ') print('O que tu mandou só tem espaço: ', tipos.isspace()) print('O que tu mandou é número: ', tipo...
false
090d7811f4d90d89084d6aa8075811995f9e137d
rob-kistner/udemy-python-masterclass
/examples/functions_scope.py
1,477
4.28125
4
################################ # # FUNCTIONS - SCOPE # ################################ from modules.utils import * banner("""showing local function vs. global scope""") ############################## def my_function(): test = 1 print('my_function: ', test) test = 0 my_function() print('global: ', test) ...
true
43120cd6adcbe8a50f8ddb2b4b30e032321ca087
RakeshSuvvari/Joy-of-computing-using-Python
/anagrams.py
298
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 17 22:34:21 2021 @author: rakesh """ str1 = input("Enter the first string: ") str2 = input("Enter the second string: ") if(sorted(str1)==sorted(str2)): print("These are Anagrams") else: print("These are not Anagrams")
true
34f5ee3e01391ac7156c416ceeb87b807ad06701
MarioMarinDev/PythonCourse
/files.py
1,153
4.3125
4
""" r = Read; Shows an error if the file does not exist a = Append; Creates the file if it does not exist w = Write; Creates the file if it does not exist x = Create; Returns an error if the file exists file.read() = Read the entire file file.read(x) = Read the first 'x' chars of the file f...
true
c02ecb661961def9a8d7f92612f007188130ba8f
mycomath/First-Code-Upload
/madlib.py
1,024
4.28125
4
storyFormat = ''' Once upon a time, deep in an ancient jungle, there lived a { animal }. This {animal} liked to eat {food}, but the jungle had very little {food} to offer. One day, an explorer found the {animal} and discovered it liked {food}. The explorer took the {animal} back to {city} where it could eat as ...
true
0d8e4f608cff645d2f765ced84b492c3c3f3338e
mohammedthasincmru/royalmech102018
/greater.py
310
4.15625
4
'''a=int(input("enter the value of a:")) b=int(input("enter the value of b:")) if(a>b): print("a is greater than b") else: print("b is greater than a")''' a=int(input("enter the value of a:")) b=int(input("enter the value of b:")) if(a<b): print("a is lesser than b") else: print("b is lesser than a")
true
07a1f9e9eb5b863e476cc5722cab3437dee44c66
fztest/Classified
/10.bit_manipulation/10.3_L371_Sum_of_two_numbers.py
1,467
4.1875
4
""" Description _______________ Calculate the sum of two integers a and b but you are not allowed to use the operator + and -. Example _____________ Given a = 1 and b = 2, return 3. Approach ______________ a&b - gives you the carry digits a^b - gives you distinctive digits (equals to plus without caring about carry) ...
true
c66d8e382f798362c16cd9f9dd941c7d63db6f1b
fztest/Classified
/2.Binary_Search/2.16_L274_H-Index.py
1,623
4.15625
4
""" Description ______________ Given an array of citations (each citation is a non-negative integer) of a researcher write a function to compute the researcher's h-index. According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each and the other N...
true
5977c9f8b609edfccd873bb3116293e5c402f0b1
fztest/Classified
/3.Binary_Tree_DC/3.15_453_Flatten_Binary_Tree_to_linked_list.py
2,228
4.46875
4
""" Description ___________ Flatten a binary tree to a fake "linked list" in pre-order traversal. Here we use the right pointer in TreeNode as the next pointer in ListNode. Notice Don't forget to mark the left child of each node to null. Or you will get Time Limit Exceeded or Memory Limit Exceeded. Have you met t...
true
10b1c8ebcb77a4a42e82ad16cb9721d6f5faddeb
fztest/Classified
/6.LinkedList&Array/6.2_599_Insert_Into_a_Cyclic_Sorted_list.py
1,919
4.1875
4
""" Description _________________ Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be any single node in the list. Return the inserted new node. Example ________________ Given a list, and insert ...
true
35db605f8d41a5b2a0a0cd577da438078d289e64
fztest/Classified
/4.BFS/4.11_178_graph_valid_Tree.py
1,947
4.21875
4
""" Description ______________ Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. Notice ____________ You can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1]...
true
7f639eb12ac60c72593d175c02d2b41dff6cecce
bhavyaagg/python-test
/algs4/sorting/heap.py
1,933
4.21875
4
# Created for BADS 2018 # See README.md for details # Python 3 import sys from algs4.stdlib import stdio """ The heap module provides a function for heapsorting an array. """ def sort(pq): """ Rearranges the array in ascending order, using the natural order. :param pq: the array to be sorted """ ...
true
0ecbbd7c74bffafc2b9270efbba0fb99ff2b2334
bhavyaagg/python-test
/algs4/sorting/merge.py
2,292
4.34375
4
# Created for BADS 2018 # See README.md for details # Python 3 """ This module provides functions for sorting an array using mergesort. For additional documentation, see Section 2.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. """ # Sorts a sequence of strings from standard input using mergesort ...
true