blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f28878e88c75381e75a59524d9f1a2a62b39ef09
Derrick-Guo/Learning
/EPI/EPI12-1.py
592
4.15625
4
# Tip: A string can be permuted to form a palindrome if and only if # the number of chars whose occurence is odd is at most 1. import collections def can_form_palindrome(s): res=collections.Counter(s) counter=0 for num in res.values(): if num%2!=0: counter+=1 if counter>1: return False return True # Optim...
true
46afe5aea6c250f16ea65ced3f693900dba39db4
rastgeleo/python_algorithms
/etc/finding_gcd.py
403
4.125
4
def finding_gcd(a, b): """Euclid's algorithm 21 = 1 * 12 + 9 12 = 1 * 9 + 3 9 = 0 * 3 + 0 """ while (b != 0): result = b a, b = b, a % b print(a, b) return result def test_finding_gcd(): number1 = 21 number2 = 12 assert(finding_gcd(number1, numb...
true
13cb53b4afc73762e4101ea7800b1ee3a81a7c77
rastgeleo/python_algorithms
/sorting/quick_sort_inplace.py
1,549
4.1875
4
import random def quicksort(unsorted, start=0, end=None): """quicksort inplace""" if end is None: end = len(unsorted) - 1 if start >= end: return # select random element to be pivot pivot_idx = random.randrange(start, end + 1) # include idx end pivot_element = unsorted[pivo...
true
13ecd9dfd2b1633a3e8788edc632efacfd640e86
adela8888/CS995-Introduction-To-Programming-Principles
/Library/edevice.py
2,096
4.34375
4
class EDevice: """ A class to represent a real-life object with its parameters. In this case to represent an electronic device """ def __init__(self, member = None): """ A constructor to initialize the instance members of the class EDevice """ self.typeOfDevice = "no...
true
7817f6ec9f063f74dccb25bf04368acee6671eb7
gabrypol/Algorithms-and-data-structure-IC-
/nth_fibonacci.py
2,176
4.25
4
''' Write a function fib() that takes an integer n and returns the nth Fibonacci number. Let's say our Fibonacci series is 0-indexed and starts with 0. So: fib(0) # => 0 fib(1) # => 1 fib(2) # => 1 fib(3) # => 2 fib(4) # => 3 ... ''' ''' Solution 1: Using recursion, I can reduce the given problem...
true
826cd37957db210480006ac6b14cdba95e906d20
gabrypol/Algorithms-and-data-structure-IC-
/word_cloud.py
2,678
4.28125
4
''' You want to build a word cloud, an infographic where the size of a word corresponds to how often it appears in the body of text. To do this, you'll need data. Write code that takes a long string and builds its word cloud data in a dictionary, where the keys are words and the values are the number of times the word...
true
62a0c2be9dd1b181e966e60fd515f128499ce34f
whereistanya/toddlerclock
/events.py
2,502
4.3125
4
#!/usr/bin/python3 """A clock to tell your toddler whether they can wake you.""" import logging import time MINUTES_IN_DAY = 1440 class Event(object): """A single event on a clock, with a start and stop time.""" def __init__(self, start_time, stop_time, description): """Create an event. Can't cross midnight ...
true
a2d4f606b729ca27dfea6badcebb27b32d1ed352
gustavoclay/PythonStudy
/exercices/Lista2/ex1.py
764
4.28125
4
'''Faça um Programa que peça os três lados de um triângulo. O programa deverá informar se os valores podem ser um triângulo. Indique, caso os lados formem um triângulo, se o mesmo é: equilátero, isósceles ou escaleno. ''' a = float(input('Lado a:')) b = float(input('Lado b:')) c = float(input('Lado c:')) ''' if a != b...
false
7aa74971b0ac528ac4a3094223fe784cd51b12bb
julianfrancor/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
473
4.25
4
#!/usr/bin/python3 "function that prints a square with the character" def text_indentation(text): """Args: text must be a string """ if not isinstance(text, str): raise TypeError("text must be a string") delimiters = [".", "?", ":"] aux = "." for char in text: if char ...
true
d43c9e4d31bc5ae951741f9594919c113573e0e1
capy-larit/exercicios_python
/exer48.py
849
4.25
4
''' Elabore um programa em Python que seja capaz de contar a quantidade de números ímpares existentes entre dois números fornecidos pelo usuário. ''' numero_1 = int(input('Digite um número: ')) numero_2 = int(input('Digite um número maior: ')) cont = 0 if numero_1 > numero_2 or numero_1 == numero_2: print( f'''\...
false
bc30941e553d9c705866d8679b140e6d63cf2537
capy-larit/exercicios_python
/exer73.py
521
4.1875
4
""" Faça um programa que leia um número qualquer e mostre o seu factorial. """ # OUTRA FORMA DE FAZER # from math import factorial # n = int(input('Digite um número para calcular seu factorial: ')) # f = factorial(n) # print('O factorial de {} é {}.'.format(n, f)) n = int(input('Digite um número para calcular seu fact...
false
5f1d4ae6e02e4e33bd1e5716d22ee7da2b0c0cbd
capy-larit/exercicios_python
/exer95.py
675
4.21875
4
""" Faça um programa utilizando um dict (dicionário) que leia dados de entrada do usuário. O usuário deve entrar com os dados de uma pessoa como nome, idade e cidade onde mora. Após isso, você deve imprimir os dados como o exemplo abaixo: nome: João idade: 20 cidade: São Paulo """ def chamar_menu(): nome = input('...
false
f62ed7987da178d089221189ed8889b79e68b26c
capy-larit/exercicios_python
/exer20.py
205
4.21875
4
''' Faça um algoritmo que calcule a raiz do número recebido. ''' from math import sqrt num = int(input('Digite um número: ')) raiz = sqrt(num) print('A raiz de {} é igual a {:.2f}'.format(num, raiz))
false
eb232820f7f73dc4a8cc1d698697cd12853f4649
capy-larit/exercicios_python
/exer24.py
391
4.1875
4
''' Faça um programa que leia os nomes recebidos e sorteie uma ordem com esses nomes. ''' from random import shuffle nome = input('Digite o primeiro nome: ') nome_1 = input('Digite o segundo nome: ') nome_2 = input('Digite o terceiro nome: ') nome_3 = input('Digite o quarto nome: ') lista = [nome, nome_1, nome_2, no...
false
2a62d1f4a3d0d2d8365e6668dafdb44667b35ace
capy-larit/exercicios_python
/exer72.py
754
4.3125
4
""" Crie um algoritmo em que o computador sorteie um número e o usuário tente acertar qual é esse número. No final diga em quantas tentativas ele acertou. """ # Sorteia um número from random import randint computador = randint(0, 10) print('Sou seu computador...\nAcabei de pensar em um número entre 0 e 10.\nSerá que ...
false
5a76ee6c5b7edc7959888cb8e08974bc05db2dae
capy-larit/exercicios_python
/exer47.py
600
4.375
4
''' Faça um programa em Python que solicitei ao usuário dois números inteiros e mostre na tela a soma dos elementos existentes entre os dois números informados. ''' numero_1 = int(input('Digite um número inteiro: ')) numero_2 = int(input( 'Digite outro número inteiro: ') ) soma = 0 if numero_1 < numero_2: nume...
false
faa204a805bc22d636100b2d6552e1a82888561d
pdelboca/hackerrank
/Algorithms/Implementation/Utopian Tree/solution.py
985
4.25
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 4 18:06:25 2015 @author: pdelboca Problem Statement The Utopian Tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by ...
true
b8d6894771e59fbb5a43cebeaa0ee02c68c8a47d
MachineLearnWithRosh/Data-Structure-and-Algorithms
/LinkedList/NodeInsertion_LL.py
1,211
4.15625
4
class Node: def __init__(self,data): self.data = data self.next = None def insertNodeBeg(head, newNode): newNode.next = head head = newNode return head def insertmiddle(head, targetNode, newNode): cur = head while(cur.data != targetNode.data): cur = cur.next newNode.next =...
false
9c45711d85c91f82586408a10981442712a571a0
jlbattle/lpthw_exercises
/ex16/ex16_2.py
927
4.34375
4
#this round, I open the file and read it again after writing to it from sys import argv script, filename = argv print "We're going to erase %r." % filename print "If you don't want that, hit CNTRL-C (^C)" print "If you do want that, hit RETURN." raw_input("?") #Opens the file in write('w') and truncate('+') mode p...
true
5a14c31da8d6a4c2e1c919f3150fb16da884b687
jlbattle/lpthw_exercises
/ex19/ex19.py
1,314
4.125
4
#define the function, its parameters, and its content def cheese_and_crackers(cheese_count, boxes_of_crackers): print "You have %d cheeses!" % cheese_count print "You have %d boxes of crackers!" % boxes_of_crackers print "That's enought for a party!" print "Get a blanket. \n" #These are all different ways we can ...
true
463d6cacb322a56c27008d668168c46432c389c3
kitilibup/tasks
/task3.py
255
4.15625
4
x1 = float(input("Введите минимум x: ")) x2 = float(input("Введите максимум x: ")) step = float(input("Введите шаг: ")) while x1<=x2: y=-1.24 * x1**2 + x1 x1+=step print ("шаг %s:" % x1, y)
false
e3e11669edf28ac80b535942e56fb9637a2b54cb
TmNguyen12/python_algos
/reverse_an_array.py
1,567
4.1875
4
# Given a string, that contains special character together with alphabets (‘a’ to ‘z’ and ‘A’ to ‘Z’), # reverse the string in a way that special characters are not affected. # Examples: # Input: str = "a,b$c" # Output: str = "c,b$a" # Note that $ and , are not moved anywhere. # Only subsequence "abc" is revers...
true
b026bfb3863229b22bd241c1e7ed3451136f6cd2
TmNguyen12/python_algos
/reverse_string.py
508
4.53125
5
# Write a program to reverse an array or string # Given an array (or string), the task is to reverse the array/string. # Examples : # Input : arr[] = {1, 2, 3} # Output : arr[] = {3, 2, 1} # Input : arr[] = {4, 5, 1, 2} # Output : arr[] = {2, 1, 5, 4} def reverseString(word): start = 0 end = len(word) - 1 w...
true
05a285c72d052f8c832c28d1e110023bd1926e78
Dylans123/First-Step-Python-Workshops
/Week 1/functions.py
1,766
4.5625
5
""" FUNCTIONS In programming often times we write code that we want to reuse many times. It can be difficult if we have to write all of our code together and have no way of deciding which code we want to execute and when. The way this problem is solved is by splitting our code up into functions and then calling them w...
true
741f24f3b77be7357709f50d594afdb5bb44b2ca
emeznar/PythonPrograms
/setAlarmClock.py
379
4.3125
4
#ask user to input time in hours current_time = int(input("What time is it now(hours only please)?")) #ask user how many hours they want to wait for an alarm alarm_set = int(input("When do you want to set an alarm(in hours)")) #compute time with alarm hours added to it wake_time = (current_time + alarm_set)%24 print ("...
true
7ef87965a60157dc1f9c96454319008ff6196c44
emeznar/PythonPrograms
/functionThatReturnsAreaofaCircle.py
683
4.25
4
import math # TODO: use def to define a function called areaOfCircle which takes an argument called r def areaOfCircle(r): a = r**2 * math.pi return a #print (areaOfCircle (5)) # TODO implment your function to return the area of a circle whose radius is r # below are some tests so you can see if your co...
true
f5d2740548dbbfe5dc486b5f69ce7a8dad4135e2
emeznar/PythonPrograms
/askUserforNumberofSidestoDrawPolygon.py
380
4.28125
4
import turtle wn = turtle.Screen() sides = int(input("How many sides does your figure have?")) distance = int(input("How long is each side?")) color = input("What color is your turtle?") fill = input("What color should it be filled with") alex = turtle.Turtle() alex.color(color) alex.fillcolor(fill) for i in range(si...
true
8bd3fe01788ce6558bd822dc58fc186b50c0e5fa
Superdadccs57/The_Ultimate_Fullstack_web_development_Bootcamp
/Python101/lesson400_Comparison.py
1,200
4.28125
4
# can_code = True # if can_code == True: # #Do a thing # print("You can code!") # else: # #Do Something Else # print("You don't know how to code yet!") # teacher = "Kalob Taulien" # if teacher == "Kalob Taulien": # print("Show the teacher portal") # else: # print("You are a student. Welc...
true
dfaa0f21933cb52997fb8b377a439550c849a6fb
Superdadccs57/The_Ultimate_Fullstack_web_development_Bootcamp
/Python101/lesson406_Functions.py
1,077
4.53125
5
print("") def welcome(name): print(f"Welcome to Lesson 406 Functions; {name}") print("________________________________________") welcome("Thomas") print("") print("The welcome message just happens to be the first example of this lesson and is designed to welcome me into the lesson using a function!") pr...
true
95eb8152ede1763b246b427fac1225e09df0a0d6
achkataa/Softuni-Programming-Fundamentals
/Functions/6. Password Validator.py
750
4.125
4
input_password = input() def validator(password): is_valid = True if len(password) < 6 or len(password) > 10: is_valid = False print("Password must be between 6 and 10 characters") for el in password: if el.isdigit() == False: if el.isalpha() == False: ...
true
2fee2311d86f92deec4ee9296b4e4709ac113933
kerembalci90/python-challenges
/string_sort.py
237
4.1875
4
# input: string of words seperated by space # output: string of words order alphabetically def sort_word_list(full_string): list_of_words = full_string.split() list_of_words.sort(key=str.lower) return ' '.join(list_of_words)
true
4a5d8339547a50321c779fb411e67a5bedc9da54
G00398347/pands-problem-sheet
/Week 02/bmi.py
752
4.40625
4
#this is a programme that calculates somebody's Body Mass Index (BMI) #Author: Ruth McQuillan strweight = input ('Enter your weight in kilograms: ') # this line asks for the persons weight in kgs strheight = input ('Enter your height in centimetres: ') # ditto for height in cms heightinmetres= float(...
true
a3106b26c45b9b6d34066b35c8e844d23ea2dc10
mstiles01/learningpython
/listandfunctions/lists.py
372
4.15625
4
#Value "friends" is a list. String, Number, Boolean friends = ["Kevin", "Karen", "Jim", "Oscar", "Toby"] print(friends) #Indicating the Index print(friends[0]) #Denotes grabbing element from index one and over print(friends[1:]) #Grabs range of index, not the last index though print(friends[1:3]) #Changing index p...
true
5c3e70ff64c9cb390a629acfaef4397af327dbb4
rianayar/Python-Projects
/Girls Code Inc./Session2.py
1,764
4.40625
4
# # inputs # print("What is your name?") # name = input() # print("Hello", name) # print() # # COMMENT ABOVE CODE BEFORE CONTINUING # # Conditionals: if, elif, else # x = 15 # y = -8 # if(x > y): # print("x is greater than y") # elif(x == y): # print("x is equal to y") # else: # print("x is less than y") # # ...
true
7d0c33c932809af6af84f92072043db310e283b2
clemencegoh/Python_Algorithms
/algorithms/HackerRank/level 1/warmups/countingValleys.py
1,731
4.40625
4
""" Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step he took, he noted if it was an uphill, U, or a downhill, D step. Gary's hikes start and end at sea level and each step up or down represents a...
true
8a4f773f11a2f0b9b71728993b190ac71c57b50d
basilwong/coding-problems
/hackerrank/python/easy/exercises/regex-and-parsing/detecting-floating-point-number.py
642
4.21875
4
""" Verifies that the given strings can be converted into float numbers. Note: A quicker way would have been to use REGEX: import re for _ in range(int(input())): print(bool(re.match(r'^[-+]?[0-9]*\.[0-9]+$', input()))) """ def check_float(s): try: float(s) except(Exception): return False ...
true
127ea566e279a49376fdba651b1c8086e5e3dee9
ArjunBisen/assignments
/calculator.py
481
4.15625
4
#!usr?bin/env python """this program defines four functions (multiply, add, subtract, and divide)""" # This part of the code defines a multiply function def multiply(a,b): return a * b def add(a,b): return a + b def subtract(a,b): return a - b def divide(a,b): return a / b def square(a): return a ** 2 de...
true
c645fe0b5568fa3dc0fe8e55cf8e7f72a7280fdf
gmdmgithub/pandas-playground
/validators_util.py
2,235
4.34375
4
import re import pandas as pd import validators import util_func as ut def valid_email(val): """ simple email validation - to consider using python validate_email - existence is possible Arguments -- val: single cell Return: 0 - not valied, 1 valied """ if ut.isnull(val): return ...
true
cd84527fd7b49f9837dd3ca6b60a96c1c10e1d15
sudhirmd005/PYTHON-excerise-files-
/cl_var.py
1,482
4.15625
4
# instance variable and class variable """ DEFINE : INSTANCE variable can be accessable inside the each instances where as class variable can be accessible through out the class Instance variables are variables whose value is assigned inside a constructor or method with 'self'...
true
99da173ebb0630569b348bb913912ff2ffd216da
ayushgnero/temporary
/Pyhton/Problem Solving/Very Big Number.py
1,394
4.1875
4
""" In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large. Function Description Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements. aVeryBigSum has the following p...
true
77bfe14deea1964d1997f7ad8ee83f7cdffcc197
EastonI/gpaCalculator
/Grade Percent Average.py
1,197
4.21875
4
print("GPA Calculator\n") numOfClasses = int(input("Enter your number of classes: ")) if numOfClasses == 4: grade = float(input("\nEnter the percentage of your first class: ")) grade1 = float(input("Enter the percentage of your second class: ")) grade2 = float(input("Enter the percentage of your third cla...
false
0a9de29b3d031c4f64c74c248c1012c59697b590
rajataneja101/Python-Lab
/alternates/classes/time.py
1,819
4.125
4
#16/2/2017 import copy class time: hours=0 minutes=0 seconds=0 def __init__(self,hours=0,minutes=0,seconds=0): self.hours = hours self.minutes = minutes self.seconds = seconds def input_values(self): print("Enter time (hh:mm:ss) : ") ...
false
d56261addd33e68f1a5be1e10a5452c2021fe276
Drakshayani86/MathBot
/trignometry.py
897
4.1875
4
#importing required modules and files import math #finds the trignometic values def trignometric_val(): #takes user choice as input value = int(input("Enter your value : ")) if(value>=1 and value<=6): #takes the user input in degrees deg = int(input("Enter value of degree: ")) #conv...
true
a91a8218ffb59dfe1f6ef6888d3021ad6aca1250
SumanSunuwar/python-basic-advance
/advance_scopes.py
1,652
4.21875
4
#scopes = > global and local scope # num = 10 # gloabal variable (Immutable obj) # def some_func(): # global num # num += 1 #local variable # print(f"this is inside function: {num}") # print(f"value of num before function exec: {num}") # some_func() # print(f"value of num after function exec: {num}") # alist =...
true
8ea0e242d2f0027b357281d5ff2e95111711838c
mvkumar14/Data-Structures
/code_challenge_2.py
2,279
4.40625
4
# Print out all of the strings in the following array that represent a number divisible by 3: # [ # "five", # "twenty six", # "nine hundred ninety nine, # "twelve", # "eighteen", # "one hundred one", # "fifty two", # "forty one", # "seventy seven", # "six", # "twelve", # "four", # "sixteen" # ...
true
ed1438961951485f7787cb4a0fdb5f8e71924ad2
chandan-stak/AI_1BM18CS026
/prog3_IDDFS/IDDFS.py
2,798
4.125
4
# Python program to print DFS traversal from a given # given graph from collections import defaultdict # This class represents a directed graph using adjacency # list representation class Graph: def __init__(self, vertices): # No. of vertices self.V = vertices # default di...
true
7a6c640a591ba246c5e397d953042bed14c0067f
welgt/Exercicios_python_pi2_Dp
/Aula03/Ex03_interseccaoLista.py
927
4.4375
4
''' 3) Escreva um função que efetua a INTERSECÇÃO entre duas listas, ou seja, os elementos em comum entre as duas listas. Considere que as listas não contêm valores duplicados e não estão ordenadas. Como resultado deve ser gerado uma nova lista e retornada, a nova lista conterá a INTERSECÇÃO das duas listas, exemplo: A...
false
7d90b4076944f7330a557b2a3dc625f4c039d83e
dp1608/python
/LeetCode/17/171021third_maximum_number.py
2,077
4.21875
4
# -*- coding: utf-8 -*- # @StartTime : 10/21/2017 14:34 # @EndTime : 10/21/2017 14:49 # @Author : Andy # @Site : # @File : 171021third_maximum_number.py # @Software : PyCharm """ Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximu...
true
bf75bd8eadff62ac94ad23de041ddf5bc5416086
dp1608/python
/LeetCode/17/171009max_area_of_island.py
2,305
4.125
4
# -*- coding: utf-8 -*- # @StartTime : 10/9/2017 14:18 # @EndTime : 10/9/2017 15:15 # @Author : Andy # @Site : # @File : 171009max_area_of_island.py # @Software : PyCharm """ Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (hori...
true
8bb8bfe62a053c3c6dc005e90d69d21167b397e2
dp1608/python
/LeetCode/1806/180608zigzag_conversion.py
1,565
4.15625
4
# -*- coding: utf-8 -*- # @Start_Time : 2018/6/8 17:43 # @End_time: # @Author : Andy # @Site : # @File : 180608zigzag_conversion.py """ 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) ...
true
1d38d807788b0e3ba2b9c896dcf5c656e7976357
dp1608/python
/LeetCode/1807/116_populating_next_right_pointers_in_each_node_180702.py
2,627
4.125
4
# -*- coding: utf-8 -*- # @Start_Time : 2018/7/2 15:30 # @End_time: # @Author : Andy # @Site : # @File : 116_populating_next_right_pointers_in_each_node_180702.py """ Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to po...
true
7da2a3869b97014c1638dc19f39e0676a67ad973
dp1608/python
/LeetCode/17/171018best_time_to_buy_and_sell_stock.py
1,851
4.1875
4
# -*- coding: utf-8 -*- # @StartTime : 10/18/2017 15:13 # @EndTime : 10/18/2017 15:58 # @Author : Andy # @Site : # @File : 171018best_time_to_buy_and_sell_stock.py # @Software : PyCharm """ Say you have an array for which the ith element is the price of a given stock on day i. If you were only permit...
true
a84eb297b6a54c8c3b69f375bc9622700111a2b0
dp1608/python
/LeetCode/17/reshape_the_matrix.py
2,287
4.6875
5
# -*- coding: utf-8 -*- # @StartTime : 9/28/2017 10:14 # @EndTime : 9/28/2017 10:36 # @Author : Andy # @Site : # @File : reshape_the_matrix.py # @Software : PyCharm """ In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but k...
true
f81faa097ead6fc3d0812e0a288c5a4cb893e2a4
dp1608/python
/LeetCode/1807/134_gas_station_180721.py
2,544
4.1875
4
# -*- coding: utf-8 -*- # @StartTime : 2018/7/21 21:26 # @EndTime : 2018/7/21 21:40 # @Author : Andy # @Site : # @File : 134_gas_station_180721.py # @Software: PyCharm """ There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tan...
true
35160d62a4a0e631598cf309500bf6d84e780527
dp1608/python
/LeetCode/17/171018pascal's_triangle.py
1,155
4.15625
4
# -*- coding: utf-8 -*- # @StartTime : 10/18/2017 14:20 # @EndTime : 10/18/2017 14:42 # @Author : Andy # @Site : # @File : 171018pascal's_triangle.py # @Software : PyCharm """ Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1]...
false
57d42228e26afb65aef09f2edb2b5104103663cf
CP1404/Practicals
/prac_03/capitalist_conrad.py
1,156
4.1875
4
""" CP1404/CP5632 - Practical Capitalist Conrad wants a stock price simulator for a volatile stock. The price starts off at $10.00, and, at the end of every day there is a 50% chance it increases by 0 to 10%, and a 50% chance that it decreases by 0 to 5%. If the price rises above $1000, or falls below $0.01, the progra...
true
fb364986fb5737f6f517f6d62928cdad5a5f8b06
CP1404/Practicals
/prac_10/recursion.py
700
4.28125
4
""" CP1404/CP5632 Practical Recursion """ def do_it(n): """Do... it.""" if n <= 0: return 0 return n % 2 + do_it(n - 1) # TODO: 1. write down what you think the output of this will be, # TODO: 2. use the debugger to step through and see what's actually happening print(do_it(5)) def do_somethin...
true
c9d2cee52a708856839e5c8659a63b58b67fa6c5
gauravjoshi1998/joshi_gaurav1-hackerrank
/percentage.py
627
4.125
4
#You have a record of students. Each record contains the student's name, and their percent marks in Maths, Physics and Chemistry. #The marks can be floating values. The user enters some integer followed by the names and marks for students. #The user then enters a student's name. Output the average percentage marks ...
true
b7db1b591dc1c70e5664f3b6d96167c9f8af3cd0
snallanc/Python-Projects
/quick-examples/lambdaFunc.py
361
4.34375
4
""" lambda keyword is used to define/return small anonymous functions. lambda expressions are meant to have just one expression per definition. """ def power(x): return lambda y: x ** y p=power(10) print("Powers of 10:\n") for i in range(1,10): print(p(i)) """ Output: Powers of 10: 10 100 1000 10000 100000 ...
true
39d8eb384876ef640b633c9c95097675d8ea670a
SACHSTech/livehack-1-python-basics-JackyW19
/problem1.py
556
4.1875
4
""" Name: problem1.py Purpose: compute the temperature in celsius to fahrenheit and output it to the user. Author: Wang.J Created: date in 07/12/2020 """ print ("**** Welcome to the celsius to fahrenheit ****") # get the temperature in celsius from the UserWarning celsius_temperature = float(input("Enter the temp...
true
c22afee28f141c89f3021c6bf8c6c6caed098afc
bobbytoo2/SJ-Sharks
/TuitionIncrease.py
1,102
4.1875
4
# TuitionIncrease.py ''' This program calculates tuition (per semester) on a yearly basis with the percent increase and amount of years. ''' def main(): # Enter tuition fee t = float(input("Enter the current tuition fee: ")) while t < 0: print("ERROR: The tuition fee cannot be negative.") t = float(input(...
true
889a9805a5758489e51c052a6e4fb4b8b44cc9d8
IsadoraRochaB/lp2.4
/a2b3/quest1.py
223
4.125
4
D = int(input('Insira a quilometragem alcançada pela partícula: ')) D -= 5 (D%8) if (D%8 <= 3): print (('Essa partícula atingiu o sensor'),(D%8)) else: print ('Essa partícula não chegou a atingir algum sensor')
false
cd98b77f7b44f64495f7221e320b8f7967830e9b
kanatnadyrbekov/Ch1Part2-Task-17
/task17.py
1,457
4.125
4
# Write the code which will write excepted data to files below # For example given offices of Google: # 1) google_kazakstan.txt # 2) google_paris.txt # 3)google_uar.txt # 4)google_kyrgystan.txt # 5)google_san_francisco.txt # 6)google_germany.txt # 7)google_moscow.txt # 8)google_sweden.txt # When the user will say “Hell...
true
850f118e89a82c763881e122bcb146796ce8c12a
mdfarazzakir/Pes_Python_Assignment-3
/Program55.py
1,776
4.21875
4
""" Exception Handling Write a program for converting weight from Pound to Kilo grams. a) Use assertion for the negative weight. b) Use assertion to weight more than 100 KG """ """Function to convert pounds to kg and to check that the weight should not be negative""" def poundsTokgs(pound): print("\na)Converting n...
true
d94858c4bddeb340f0a45af9a59aa707384ef2fa
mdfarazzakir/Pes_Python_Assignment-3
/Program60/listPackage/list3.py
2,146
4.28125
4
""" Python List functions and Methods Create a list of 5 names and check given name exist in the List.         a) Use membership operator (IN) to check the presence of an element.         b) Perform above task without using membership operator.         c) Print the elements of the list in reverse direction. """ l = ...
true
deab2c1a0cbc174c7feaa1c00c7dbb837ff09ed9
mdfarazzakir/Pes_Python_Assignment-3
/Program58/calc.py
1,144
4.3125
4
"""Function to add two numbers""" def add(num1,num2): return(num1 + num2) """Function to subtract two numbers""" def subtract(num1,num2): return(num1 - num2) """Function to multiply two numbers""" def multiply(num1,num2): return(num1 * num2) """Function to find the suare root of a number""" def squareRoo...
true
a87c5c45b59b01bf7934f3ef409e77ce066c6950
mdfarazzakir/Pes_Python_Assignment-3
/Program60/stringPackage/string12.py
2,127
4.46875
4
def strgOp(): strg = input("Enter the string: ") print("\nYour enetered string is: ",strg) print("\nString operation using startswith return True if S starts with the specified prefix, False otherwise: ") stg1 = input("Enter the string for check: ") print("\nAfter performing startswith:",strg.start...
true
f47d8e9d4fed9676d7e6b134f18818d93db21d44
mdfarazzakir/Pes_Python_Assignment-3
/Program41b.py
846
4.15625
4
""" Dictionary  and Date & Time: Using calendar module perform following operations. a) Print the 2016 calendar with space between months as 10 characters. b) How many leap days between the years 1980 to 2025. c) Check given year is leap year or not. d) print calendar of any specified month of the year 2016. """ """I...
true
ac44a72d80053e2484a03a77451db74accf387ae
mdfarazzakir/Pes_Python_Assignment-3
/Program60/stringPackage/string5.py
2,072
4.59375
5
""" Strings: Write a program to check given string is Palindrome or not.That is reverse the given string and check whether it is same as original string, if so then it is palindrome.Example: String = "malayalam"  reverse string = "malayalam" hence given string is palindrome. Use built functions to check given string is...
true
a9d6b7af8185c2cca2dd3df0c0a9aace8b3e4942
Amarthya03/Scripting-Languages-Lab
/Week_2/lab2.py
635
4.25
4
# Python has 5 data types: Number, String, List , Tuple, Dictionary # Strings are immutable # All the elements belonging to a list or tuple can be of different data type # List elements and size can be changed # Tuples are "read-only" lists. They are immutable. Once created, their size and elements cannot be changed # ...
true
f500e62929cdeee175464927e2564d59eda1d8ac
vonbalzer/module
/db/people.py
288
4.25
4
def what(): answer = input("Do you know how much will be, 2 + 2 ? !!!yes or no!!!") if answer == 'yes': print('You are smart') elif answer == 'no': print('You need to learn the multiplication table, xD') else: print('Read the terms carefully)))')
true
61bd084536f349759ea4ce6e26a81a507f30b56e
aliceshan/Practice-Questions
/recursion_dynamic_programming/robot_in_a_grid.py
2,743
4.25
4
""" Type: Dynamic programming, graphs Source: Cracking the Coding Interview (8.2) Prompt: Imagine a rovot sitting on the upper left corner of grid with r rows and c columns. The robot can only move in two directions, right and down, but certain cells are "off limits" such that the robot cannot step on them. Design an a...
true
560df3a1ab20c6a2e6f2966e6070e93a2682d537
parisa7103/Python
/hw3q3.py
400
4.125
4
#Define a procedure, product_list, #takes as input a list of numbers, #and returns a number that is #the result of multiplying all #those numbers together. #product_list([9]) => 9 #product_list([1,2,3,4]) => 24 def product_list(inputList): result = 1 for a in inputList: result *= a print result inputList1 = [9]...
true
ab1c2281fd3c21a6768c9c4343c11146b95b29a6
TanyaPaquet/sortrec
/sortrec/sorting.py
2,490
4.46875
4
def bubble_sort(items): '''Return array of items, sorted in ascending order. Args: items (array): list or array-like object to sort. Returns: array: list or array-like object to sorted in acsending order. Examples: >>> bubble_sort([3, 6, 3, 5, 8, 1]) [1, 3, 3, 5, 6, 8] ...
true
6fa9fd0df0aa8c79b20d6844d9df464589a145a2
PrithviRajMamidala/Leetcode_Solutions
/Problems/Arrays&Strings/climbingStairs.py
424
4.125
4
"""bottom-top approach Can use dictionary for storing other elements and easy lookup more optimized solution""" def climbStairs(n): stairs = [] stairs.extend([0, 1, 2]) # print(stairs) if n <= 2: return stairs[n] i = 3 while i <= n: stairs.append(stairs[i-1] + stairs[...
true
abf3c8d71bd970d0b6f48040b70f1e9df32fba0f
rohan2jos/SideProjects
/BinaryTree/HeapNode.py
2,092
4.21875
4
''' Class for the node that will be used in the heap will be imported into the implementing program ''' class HeapNode: data = 0 left = '' right = '' ''' __init__() --> constructor args: data, left node, right node returns: the initialized node with the passed arguments ''' def __...
true
404285ea7804e88c002400b7f301f07933f2ea5b
jdpoccorie/ejercicios
/r5_10.py
546
4.125
4
# Nombre: Juan Diego Poccori Escalante # Código: 144884 # 10. Escribir un algoritmo para calcular el promedio aritmético de N números # Leer numero numero = int(input("Ingresar número: ")) # Verificar si numero es positivo if numero >= 0: i = 1 suma = 0 promedio = 0 while numero >= i: # Leer numeros i...
false
7fc0f940d23c137748ab18f91b1625b25d2c38f3
sampita/Python-Showroom-Junkyard
/cars.py
1,655
4.1875
4
# Create an empty set named showroom. showroom = set() # Add four of your favorite car model names to the set. showroom = {'Jeep Renegade', 'Kia Soul', 'Ford Thunderbird', 'Toyota Prius'} # Print the length of your set. print(len(showroom)) # Pick one of the items in your show room and add it to the set again. showr...
true
02640b8941b4e0ea239b980c9ea90123cd6c538b
jared-chapman/Projects
/Python/Python_Examples/Chapter 9 (Files)/Writing to files.py
1,167
4.3125
4
#open a file with the open function #Takes two parameters, a string representing the path, and a string representing the mode to open the file in #File paths shouldn't be typed manually as different OS's label them differently #Instead, use the built-in os module. Takes each location in a file as a parameters #Fi...
true
9c8d0bf8df50fb169aec3657cdb7cb0c2ebd0faf
jared-chapman/Projects
/Python/Python_Examples/Chapter 4 (Functions)/Functions.py
924
4.59375
5
#Define a function with [def functionName(paramaters):] def double(x): return x*2 #Call a function with [functionName(paramaters)] result = double(3) print(result) #A function doesn't have to have parameters def sayMyName(): return "Jared" name = sayMyName() print(name) #A function ca...
true
a4c841c701a38f50417a4b3f1c91f630f17cd5f8
Lackman-coder/python-tutorail
/while_loop/introduction.py
690
4.53125
5
i = 1 while i < 6: print(i) i += 1 # With the while loop we can execute a set of statements as long as a condition is true. # Note: remember to increment i, or else the loop will continue forever. i = 1 while i < 6: print(i) if i == 3: break i += 1 # With the break statement we can stop the loop even i...
true
ad064a81e1db44094af4f23eca4857085402a233
Lackman-coder/python-tutorail
/list/add list items.py
722
4.5625
5
thislist = ["apple", "banana", "cherry"] thislist.append("orange") print(thislist) # To add an item to the end of the list, use the append() method. thislist = ["apple", "banana", "cherry"] thislist.insert(1, "orange") print(thislist) # Insert an item as the second position. thislist = ["apple", "banana", "cherry"] t...
true
09fdff6a6ae012ea69be341a50b80954b2d7ab41
Lackman-coder/python-tutorail
/list/remove list itmes.py
699
4.4375
4
thislist = ["apple", "banana", "cherry"] thislist.remove("banana") print(thislist) # The remove() method removes the specified item. thislist = ["apple", "banana", "cherry"] thislist.pop(1) print(thislist) # The pop() method removes the specified index. thislist = ["apple", "banana", "cherry"] thislist.pop() print(th...
true
67d39141c45d50ecf1b95ada231c6c603fcaba26
kinderferraz/mc102
/lab02/main.py
1,015
4.25
4
# MC102 O -- Alkindar Rodrigues # lab 02 -- Calculadora simples # para ler o primeiro operando op1 = input() if op1.isdigit(): op1 = int(op1) else: op1 = float(op1) # para ler a operação a ser realizada e = input() # para ler o segundo operando op2 = input() if op2.isdigit(): op2 = int(op2) else: op2...
false
6122065a8b5bf2e5c61c3a0a92464559a6c5281e
gdashua/codeWitAssignments
/codewit_July_Wk3/ageFinder.py
1,187
4.28125
4
#second assignment import datetime def ageFinder(): print('Please enter your last birthday to know you exact birthdate') print() try: day = int(input('day: ')) month = int(input('month: ')) year = int(input('year: ')) day_position = ''; print('How old are you?') current_age ...
false
7f3e78c527fb47cf594222462974dd04342819a8
JoaquinRodriguez2006/CursoPythonSabados
/Ejercicios Clase 1 - Joaquín Rodríguez.py
1,431
4.125
4
#CLASE 1: # Ejercicio 1 mensaje=("Hola") print(mensaje) mensaje=("Chau") print(mensaje) #Ejercicio 2 mensaje=("HolaFede") print(mensaje) #Ejercicio 3 print(5+3) print(9-1) print(80/10) print(4*2) #Ejercicio 4 mi_entero=14 print(type(mi_entero)) mi_booleano=True print(type(mi_booleano)) mi_strin...
false
c7a8a4ab465127aad357db61f5a00cf496a27c4a
leobarros/zumbis
/lista_1/questao08.py
265
4.21875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- #Faça agora o contrário, de Fahrenheit para Celsius. fahrenheit = float(input("Temperatura em Fº: ")) celsius = ((fahrenheit - 32) / 1.8000) #ºC = ((ºF - 32)/1.8000) print ("Temperatura em Celsius é: ", celsius)
false
acf5c8dc39ec562558978c1f25b7f5ca4d039edd
sayaliphatak9628/Python
/Data structure - Tuples.py
374
4.34375
4
''' #Tuples are like list. #tuples introduction x = ('abc','def','ghi','jkl') print(x) print(x[2]) y=(1,3,9,12,7,4) print(max(y)) y[2]=5 print(y) for i in y: print(i) #tuples can be added on left-hand side also #tuples and dictionaries (x,y) = (1,'sayali') print(x,y) (a,b) = (44,65) print(b) dic = dict() dic ...
false
ae5e01be8e3605a1c14866421730be6f299b1bc8
greysou1/pycourse
/mod2/practice/challenge.py
602
4.15625
4
the_list = ['cat', 'dog', 'machine'] def list_o_matic(the_list, entry): if entry == '': popped = the_list.pop() return popped + ' popped from list' elif entry in the_list: the_list.remove(entry) return '1 instance of "' + entry + '" removed from the list' else: ...
true
7ec2a68c19999add01fe0d807dc817fee175d94c
midhilajnisam1/dumbest-dictionary
/Firstprog/mishi.py
489
4.3125
4
dict1 = {"Burger":"Best fast food for timepass", "PS4":"A Gaming Console for Game Lovers", "Midhilaj":"Best in the world","Avengers":"Best multi super hero movie ever",2:"Lucky Number for Most peoples" } print("""Enter any of the words below to know the dumbest definitions\n 1. Burger\n 2. PS4\n 3. Midhilaj\n 4. A...
false
f078f8206acd2bdeb1429404507975e17fb84c90
bijp/pycharm
/actual_combat/top6.py
523
4.21875
4
"""定义一个python类IOString,有两个成员方法get_String 和 print_String get_String 获取用户输入 print_String 将获取的输入信息大写输出 请写出类的实现,并分别调用这两个方法""" class IOString(): def __init__(self): self.inpu='' def get_String(self): self.inpu=input('请输入信息:') def print_String(self): t=self.inpu print(t.upper()) ...
false
e6e14e6d570ac3ea2d0d5622545d817323a23b18
TheSahilGit/Recursive-Functions
/Recursion.py
1,159
4.3125
4
"""Use of recursive function to draw beautiful fractal patterns.""" ### Sahil Islam ### ### 09/06/2020 ### import pygame pygame.init() width = 800 height = 600 black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) clock = pygame.time.Clock() screen = pygame.display.set_mode((width, height...
false
38998023327df8304e560fe098edcc07fb05cdec
adrianocerutti/fatorial_python
/fatorial.py
354
4.15625
4
''' Programa que lê um número inteiro n >= 0 e imprime n! ''' print("Cálculo do fatorial de um número\n") # leia o valor de n n = int(input("Digite um número inteiro não-negativo: ")) i = 1 # contador n_fat = 1 # variável de cálculo fatorial # calcule n! while i <= n: n_fat = n_fat * i i = i + 1 print(...
false
d9f1229f680f3f33e15eb90522e36aca499f5c7f
hafij15/python-basic
/6/short_circuit_evalution.py
261
4.28125
4
# name = '' # if name == "": # default_name = "Guest" # else: # default_name = name # print(default_name) # name = 'Hafij' # default_name = name or 'Guest' # print(default_name) name = "Hafij" upper_name = name and name.upper() print(upper_name)
true
82570514a9830884ba59d6acd247f0d9000d5a78
tberhanu/elts-of-coding
/Arrays/primes.py
1,202
4.40625
4
import math def is_prime(n): if n == 2: return True if n < 2: return False i = 2 while i <= math.sqrt(n): if n % i == 0: return False i += 1 return True def list_all_primes_upto(n): """ Getting all the prime numbers upto number N. Note: Rather...
true
fc1a7e72faaff24a58411840f763eb732bbe91cf
tberhanu/elts-of-coding
/HashTables/test_collatz_conjecture.py
1,878
4.46875
4
def test_collatz_conjecture_driver(num): s = {1: 1} i = 2 return test_collatz_conjecture(i, num, s) def test_collatz_conjecture(i, num, s): """ Coolatz conjecture is: Taking any natural number, and halve it if it's even, or multiply it by 3 and add 1 if it's odd number. If...
true
1a4dcdb5122d2540963d77450759faa7c10bd71a
tberhanu/elts-of-coding
/DynamicProgramming/min_triangle_path_weight.py
1,576
4.15625
4
def min_path_weight(triangle): """ Write a program that takes as input a triangle of numbers and returns the weight of a minimum weight path. Tess Strategy: Once we know the min at row 1, then we will know at row 2, and once we know the min at row 2, we will know the min at row 3 without the...
true
6f73e8b67c000778c1007c8a558fdfb591641a47
tberhanu/elts-of-coding
/Searching/binary_search.py
2,520
4.1875
4
""" In built Binary Search Libraries: 1. bisect.bisect_left(arr, e): return the first index whose value is >= e, else return len(arr) arr = [0, 1, 2, 4] bisect.bisect_left(arr, 2): return 2 bisect.bisect_left(arr, 3): return 3 num = [0, 1, 2, 2, 2, 2, 4, 5] bisect.bisect_left(nu...
true
72412b507958b248e4c579e8b8ab337d3e3c4a22
tberhanu/elts-of-coding
/Arrays/46. permutations.py
796
4.125
4
""" Given a collection of distinct integers, return all possible permutations. Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] """ def permute(nums): nums2 = nums[:] # copying the nums to reserve start = 0 result = [] return permutation(nums, nums2, start, re...
true
f353962660242276ab460e96fd3b3ffdac2ba141
tberhanu/elts-of-coding
/Graphs/search_maze.py
2,761
4.25
4
from collections import namedtuple WHITE, BLACK = range(2) Coordinate = namedtuple('Coordinate', ('x', 'y')) def search_maze_driver(maze, start, end): path = [] return search_maze(maze, start, end, path) def search_maze(maze, start, end, path): """ Consider a black and white digitized image of a maze-w...
true