blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4a1510182817ca687e96b12c6ff1764e5413ae40
mikebpedersen/python_med_gerth
/uge_5/opgave8_4.py
1,624
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Exercise 8.4* (validate leaf-labeled binary trees) Assume we want to represent binary trees, where each leaf has a string as a label, by a nested tuple. We require the leaves are labeled with distinct non-empty strings and all non-leaf nodes have exactly two children...
true
d9c23e09c23090d9f1b4da7686f5c1bae152392d
mikebpedersen/python_med_gerth
/uge_2/opgave2_7.py
1,572
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 28 12:20:09 2020 @author: JensTrolle """ """ import math n = float(input("Write a number equal to or above 1 here " "to approximate the square root: ")) while n <= 1: # Check for n = float(input("Yo...
true
7042e40fc79bca2079f52355dfdf1ce45e0a8cd0
mikebpedersen/python_med_gerth
/uge_5/opgave7_1.py
715
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Exercise 7.1 (average) """ """ Write a function average2(x,y) that computes the average of x and y, i.e. (x+y)/2. """ def average2(x, y): return (x+y)/2 print(average2(2, 6)) """ Write a function list_average(L) that computes the average of the numbers in th...
true
ad28a851eca6e4bbf663c671666248c0f56d82d0
mikebpedersen/python_med_gerth
/uge_4/opgave5_2.py
490
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Given a list of first names first = ['Donald', 'Mickey', 'Scrooge'] and last names last = ['Duck', 'Mouse', 'McDuck'], use list comprehension, zip, and sorted to generate an alphabetically sorted list of names 'lastname, firstname', i.e. generates the list: ['Duck, Don...
true
df1ec46df1e55ca8e8f46db217159836d1256687
DuvanSGF/Python3x
/Listas2.py
444
4.40625
4
""" Una lista puede contener datos de todo tipo, lo que incluye cadenas, numeros y hasta otras listas. Ademas, dentro de una lista puede mezclar tipos de Datos. Para Acceder al contenido de una Lista dentro de otra, se pone un indice acontinuacion del otro: """ lista = [["1", "2", "3"], ["Uno", "Dos", "Tres"],"Hola"...
false
7cbfe54d027d3f83c972b06413347cddb18b4c58
eduardobrennand/estrutura_sequencial
/11.py
543
4.40625
4
"""Faça um Programa que peça 2 números inteiros e um número real. Calcule e mostre: a)o produto do dobro do primeiro com metade do segundo . b)a soma do triplo do primeiro com o terceiro. c)o terceiro elevado ao cubo.""" n1 = int(input('Primeiro numero inteiro: ')) n2 = int(input('Segundo numero inteiro: ')) n3 = floa...
false
1e30df646d4e07c84f2becbacc64ae255da06a6a
Suleiman99Hesham/Algorithms-Foundations
/factorial.py
303
4.3125
4
def power(num,pwr): if (pwr==0): return 1 else: return num*(power(num,pwr-1)) def factorial(num): if num==0: return 1 else: return num*factorial(num-1) print("{} to the power of {} is {}".format(2,3,power(2,3))) print("{}! is {} ".format(3,factorial(3)))
true
7f8bf75aac959e0a15af1349d1a53b1c9928a39a
Isabellajones71/plhme
/animal.py
485
4.25
4
#Abstraction is displaying only essential information to the user and hiding # the details from the user class Animal(): animal_kind = "Canine" def __init__(self,name,age): self.name = name self.age = age def eat(self): return("{}SaysI am eating Chicken".format(self.name)) # Dog1...
true
964545ad94e3ec490a1c24a8bf40aeeb29780983
mondaya/CodingCojo
/pythonstack/fundamentals/tasks/PythonFundamnetals/fun_with_function.py
1,245
4.71875
5
""" Create a function called odd_even that counts from 1 to 2000. As your loop executes have your program print the number of that iteration and specify whether it's an odd or even number. """ def odd_even() : for num in range(1,2001): if num % 2 == 1 : print "Number is {}.".format(num), "This...
true
fdd0783ae2773f4530ea0baf0bfb3d38d3f77206
mondaya/CodingCojo
/pythonstack/fundamentals/tasks/PythonFundamnetals/names.py
2,204
4.28125
4
""" Part I: Given the following list: students = [ {'first_name': 'Michael', 'last_name' : 'Jordan'}, {'first_name' : 'John', 'last_name' : 'Rosales'}, {'first_name' : 'Mark', 'last_name' : 'Guillen'}, {'first_name' : 'KB', 'last_name' : 'Tonel'} ] Copy Cre...
false
d1d63d749bc4669cc9e4ca06975805fdd9a26b50
alex-dsouza777/Python-Basics
/Chapter 5 - Dictionary & Sets/05_set_methods.py
514
4.21875
4
#Creating empty set b = set() print(type(b)) #Adding values to an empty set b.add(4) b.add(5) b.add(5) #Set is a collection of non repatative items so it will print 5 only once b.add(5) b.add(5) b.add((4,5,6)) #You can add touple in set #b.add({4:5}) # Cannot add list or dictionary to sets print(b) #Length of set pri...
true
bc2db92500488ec07b4034dd8118d1b824989470
alex-dsouza777/Python-Basics
/Chapter 7 - Loops in Python/12_pr_03.py
202
4.40625
4
#Program to print multiplication table of a given number using while loop num = int(input("Enter the number ")) i=1 while i<=10: a = num * i print(f"{num} X {i} = {num*i}") i=i+1
true
3605e055d5a03b1c1e8ea12a482e328336918086
alex-dsouza777/Python-Basics
/Chapter 3 - Strings/09_pr_05.py
295
4.15625
4
#Format the following letter using escape sequence characters #letter = "Dear Root, welcome to python course. Thank You!" letter = "Dear Root, welcome to python course. Thank You!" print(letter) formatted_letter = "Dear Root, \n\tWelcome to python course.\n Thank You!" print(formatted_letter)
true
270444411a071df27ae14699aa4ffeab8bd4a74d
alex-dsouza777/Python-Basics
/Chapter 7 - Loops in Python/10_pr_01.py
228
4.46875
4
#Program to print multiplication table of a given number using for loop num = int(input("Enter the number ")) for i in range(1, 11): # print(str(num) + " X " +str(i) + " = " + str(i*num)) print(f"{num} X {i} = {num*i}")
true
44ee90743a5ab2acf930418db50b534793cbec12
alex-dsouza777/Python-Basics
/Chapter 13 - Advanced Python 2/09_pr_02.py
459
4.4375
4
#Write a program to input name, marks and phone number of a student and format it using the format function like below: # “The name of the student is Root, his marks are 72 and the phone number is 99999888” name = input("Enter Your Name: ") marks = int(input("Enter Your Marks: ")) phone = int(input("Phone Number: ")) ...
true
becf87c41cb32dcb20746b06c89951b9b6998b03
Mikes-new/automate-stuff
/regexStrip.py
505
4.15625
4
#! python3 # regexStrip.py - performs same task as strip string method, using regexStrip import re def regexStrip(s, side=None): # s is string to be processed; side is left/right side of string whitespaceRegex = re.compile(r'(\s*)(\S+.*\S+)(\s*)') mo = whitespaceRegex.match(s) if mo == None: return...
true
637d88d2a950499b8b521069973da7ea65097516
sanidhya-singh/sample-code-in-every-language
/python/quick-sort.py
769
4.125
4
""" SORTING ALGORITHM : QUICK SORT TIME COMPLEXITY : O(nlogn) """ # implementation def quicksort(arr): if len(arr) <= 1: # base line for recursion return arr else: pivot = arr.pop() # pivot, in this place last item in array item_lower = [] # list having elements lower than piv...
true
64551fe02f2c244f9a89655e4e8720c5edaae789
ajh1143/FireCode_Solutions
/Level_1/RepeatedArrayElements.py
620
4.375
4
""" Write a function - duplicate_items to find the redundant or repeated items in a list and return them in sorted order. This method should return a list of redundant integers in ascending sorted order (as illustrated below). Examples: duplicate_items([1, 3, 4, 2, 1]) => [1] duplicate_items([1, 3, 4, 2, 1, 2, 4]) ...
true
e4807875c3365081448a756183814d528622bc27
rodneygauna/palomar-CSIT175-Python
/10/10-7.py
719
4.59375
5
# 10.7 - Basic Coding Skills # 1. Code a program in a .py file that displays "Hello Python" on the console print("Hello Python") # 2. Change that program to use two print statements... the first displays "Hello" and the second displays "Python" on the next line of the console. print("Hello") print("Python") # 3. Ch...
true
eab2f2aa2eaafdffd80e09e80594a5f4fabafe12
rodneygauna/palomar-CSIT175-Python
/10/gauna_asgn1.py
1,290
4.65625
5
# Assignment 1 # Rodney Gauna // February 5, 2021 # Please carefully read the Instructions and Grading Criteria. # Write a program that determines approximately how many years of your life you have been asleep. # Name your program yourlastname_asgn1.py (obviously, replace "yourlastname" with your last name!) # 1. Coll...
true
0782b6162eba654f86f36d598ecbde39a43991de
Irlirion/data_structures_and_algorithms
/sort/quick_sort.py
1,460
4.15625
4
def quick_sort(arr: list, simulation=False) -> list: """ Quick sort \n Complexity: best O(n log(n), avg O(n log(n), worst O(n^2) """ iteration = 0 if simulation: print("iteration", iteration, ':', *arr) arr, _ = __quick_sort_recur(arr, 0, len(arr) - 1, iteration, simulation) ret...
false
45f5a8f8848572354be4ed6c191dfd5d179a0b25
PdxCodeGuild/class_mouse
/1 Python/solutions/practice1.py
2,084
4.25
4
# Write a function that tells whether a number is even or odd (hint, compare a/2 and a//2, or use a%2) def is_even(a): if a % 2 == 0: return True else: return False # while a != 1 and a !=0: # a //= 2 # if a == 0: # return True # elif a == 1: # ...
true
2d18633081d491981fcf8adc3a99f70bb60eff15
Igor-Zhelezniak-1/ICS3U-Assignment-2-Python-Program
/program.py
530
4.5
4
#!/usr/bin/env python3 # Created by: Igor # Created on: Oct 2021 # This program calculates the area of a rectangle # where the user gets to enter the length and width in mm import math def main(): # main function print("We will be calculating the area of a rectangle. ") # input length = int(input("E...
true
053dc414d0451a1485a81ac0065812e34aab918e
andrex-naranjas/test
/CodigoDePractica/CodigoPython/clases.py
1,505
4.5
4
# Una clase es como un plano para crear objetos. Un objeto tiene propiedades y metodos (funciones) asociadas a el. Casi todo en python es un objeto (clase) #Create a class class Usuario: #Constructor (funcion que corre cuando haces una instanciacion d una clase) def __init__(self, nombre, email, edad): ...
false
27a3da7ffae3c001f3de463c3b31f0af99012de7
QMSS-G5072-2020/cipher_Zhou_Xuanyi
/cipher_xz2959/cipher_xz2959.py
906
4.40625
4
def cipher(text, shift, encrypt=True): """ Encrypt the text using shift coding. Args: text (str): represent the source text shift (int): the shift size encrypt (bool): True for encrypt and False for decrypt Returns: str: represent the cipher Examples: ...
true
c60eb356afc847057629ec1d0365bfedfc6e93b9
Navaneeth1706/Agile_notes
/datatype.py
1,185
4.28125
4
#Day2 in training # 1. Print function displays the contents # 2. type function display data type of the variable no = 10 print(no) print(type(no)) no = 4.5 print(no) print(type(no)) result = True print(result) print(type(result)) name = 'navanee' print(name) print(type(name)) print(id(name)) no = 2 print(no)...
true
5436afe22ed781d05b56c883689085b7c2e0ecd5
IsFilimonov/Interviews
/LeetCode/Python/101-Symmetric_Tree.py
1,239
4.25
4
from typing import Optional # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isSymmetric(self, root: Optional[TreeNode]) -> bool: def is_equal(L, R): ...
true
f16f0128f3a8ef33871daddf811ee4ab20396fa7
stur-na/wordguess_game
/word_game.py
1,383
4.15625
4
'''This project taught me about the open module and the readline method and also the random shuffle method''' #import the random shuffle module for shuffling the dictionary list from random import shuffle #Start game def start_game(): print('Welcome to the word guess game, guess a word from the dictionary') pr...
true
4ef99db04a657a26292c03880b8656a67e96e60f
rex-mcall/Learn-Python-Course
/ex32.py
682
4.59375
5
the_count = [1,2,3,4,5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] #this for loop goes through a list for number in the_count: print(f"This is count {number}") for fruit in fruits: print(f"A fruit type: {fruit}") #We can go through mixed lists too #We ...
true
3dc4eaecee2a1b71b7fbeb16f7429ea04ae8e8e0
upeismcschatbot/upeismcschatbot
/chatbot/Chatbot_Server_Code.py
825
4.1875
4
""" This code receives an argument from a PHP code (could be any code really though. Since a sentence is received as an array it appends the array together to get one string called result. It is important to note that the Website will grab the first print statement it sees and return that to the user. THERE SHOU...
true
ff11412fb41a249d7dfb3efd8a9d57e6c1954271
luohengsdjzu/python_study
/Day05/垃圾回收.py
390
4.125
4
# -*- encoding:utf-8 -*- # 垃圾回收机制详解 # 1、引用计数 # x = 10 # 直接引用 # print(id(x)) # # l = ['a', x] # 间接引用 # print(id(l[1])) # # d = {'name': x} # 间接引用 # print(id(d['name'])) x = 10 l = ['a', 'b', x] # 列表当中实际上存的是内存地址,跟x变量没关系 x = 123 print(l[2]) print(x) # 2、标记清除 # 3、分代回收
false
679fef8e6b5042aac4d69704e59e88c044b795ba
NNADIHENRY/python_program
/area-of-a-sector.py
223
4.28125
4
""" area of a sector by NNADI HENRY IFEANYI 08139264713 nnadihenry92@gmail.com """ pi = 3.142857 r = float(input("enter radius: ")) o = float(input("enter the angle in degree: ")) area = (o/360) * pi * r * r print("area = " + str(area))
false
3256b9c3b9704fe7477cb2cd5adcffa1f7e9d474
NNADIHENRY/python_program
/arc-lenght-of-an-angle.py
237
4.21875
4
""" arc length of an angle(2*pi*r*(angle/360)) by NNADI HENRY IFEANYI 08139264713 nnadihenry92@gmail.com """ pi = 3.142857 r = float(input("enter radius: ")) o = float(input("enter the angle: ")) length = 2*pi*r*(o/360) print("area = " + str(length))
false
3c93e65dfe2297a146d72234a173992248152cda
monishreddy143/oops-concepts
/00p2.py
1,125
4.375
4
#inheritance #super() method will allow the sub class ti acces any class constructers and #als0 it is use to acces the methods also class grandpa: #constructers in inheritance def __init__(self): print("my son is father class") def name1(self): print("my name is monish im aged") def age1(self): ...
false
a536eff68fa30383df537430136a0d8c4ad56dbc
TechArpit20/Python-Playlist
/operators1.py
1,725
4.46875
4
''' Operatore are basically used to perform various operations on the values contained in different variables Types of Operators: 1. Arithmetic operators=> Addition(+), Subtraction(-), Multiplication(*), Division(/), Modulus(%), Exponential(**), Floor Division(//) 2. Assignment => (=), (+=), (-=), 3. Comparison ...
true
b15a11759446e52d6f0ac0a12f9f9527de5e10ea
diamondjaxx/PyNet_Test1
/ex7_yaml_json.py
596
4.1875
4
#!/usr/bin/env python ''' Write a Python program that reads both the YAML file and the JSON file created in exercise6 and pretty prints the data structure that is returned. ''' import yaml import json from pprint import pprint def main(): yaml_file = 'my_file.yml' json_file = 'my_file.json' with open(yam...
true
9454af19a1bdb0c7072603a7eca55ffdb1122dbb
pirategiri/30daysOfPython
/day2/lengthcon.py
1,836
4.21875
4
# Python Programming Course : GUI Applications # -Kiran Giri # Length Converter ( Meter <-> Inch <-> Foot ) from tkinter import * # Main window App = Tk() App.title("Length Converter") App.geometry('350x150') # Scales to be used scales = ['Meters', 'Inches', 'Foot'] # The scale of th...
true
8d050db21f700046e4f19488aa3beef872ab3cd6
Prabin-Neupane/task1.py
/task5.py
1,672
4.21875
4
# bird = ['crows','pigeon','eagles','falcon','pigeon','falcon','falcon'] # Remove all the duplicates from the following list using while. bird = ['crows','pigeon','eagles','falcon','pigeon','falcon','falcon'] new =[] while bird: x = bird.pop() if x not in new: new.append(x) print(new) #Deli: Make a lis...
true
927338a47736e15dba2ce0efd15725f725563fd0
analien-16/LearnCodingInPython
/Lesson-one/fibonacci.py
255
4.28125
4
# Write a program to generate the Fibonacci series up to a number a, b = 0, 1 x = int (input("What is the last term you would like to display up to? " )) print (0,1,end=' ') while True: c = a + b a = b b = c if c > x: break print(c, end=' ')
true
c754668b054d5bbe0a48f28a7c5f335d6fc6dc1a
ZandbergenM/Homework-week-5_Zandbergen
/Part 1 Exercise 9.2.py
832
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #9.2 Write a function called has_no_e that returns True if the given word doesn't have the letter "e" in it # Write a program that reads words.txt and prints only the words that have no "e", Compute the percentage of words in the list that have no "e" # In[67]: def ...
true
1dd5b839e79f148b3e2a8b013b7677586546b15a
TunTunNikitun/Python_Programming
/1_module/1.12.7.py
1,202
4.28125
4
""" Паша очень любит кататься на общественном транспорте, а получая билет, сразу проверяет, счастливый ли ему попался. Билет считается счастливым, если сумма первых трех цифр совпадает с суммой последних трех цифр номера билета. Однако Паша очень плохо считает в уме, поэтому попросил вас написать программу, которая про...
false
6aead7adb7b835fb5477e49b8370ecc3b21c126b
rrssantos/Python
/Python39/ex1t5py.py
373
4.21875
4
#Pedir um número qualquer ao usuário e apresentar o fatorial deste número. Quando o valor 0 #for informado o programa deverá encerrar import math a = 1 while a > 0 : a =int(input("digite o valor do numero para descobrir o Fatorial: ")) if a > 0 : b = math.factorial(a) print("o faltorial...
false
a3f618fbdfbc1b9980ff08eeea6bb158437837dd
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/Harry_Maher/Python210B/Session03/slicing.py
1,191
4.34375
4
#!/usr/bin/env python3 """ Write some functions that take a sequence as an argument, and return a copy of that sequence: with the first and last items exchanged. with every other item removed. with the first 4 and the last 4 items removed, and then every other item in between. with the elements reverse...
true
4c5141f78846558468c0d0063838394610fe74dc
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/TracyA/session03/list_lab3.py
602
4.15625
4
#!/usr/bin/env python # Programming in python B Winter 2018 # February 5, 2017 # list Lab #3 # Tracy Allen - git repo https://github.com/tenoverpar/Wi2018-Classroom # Series 3 of list lab exercises # Create a list with Apples, Pears, Oranges, and Peaches. Print the list. fruits3 = ["Apples", "Pears", "Oranges", "Peac...
true
f54058443bbc32eb2457e05b8e71ae49127e0ffc
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/jchristo/session11/range_iterator_assignment.py
1,514
4.5625
5
#!/usr/bin/env python import itertools """ Simple iterator examples """ class IterateMe_1: """ About as simple an iterator as you can get: returns the sequence of numbers from zero to 4 ( like range(4) ) """ def __init__(self, stop=5): self.current = -1 self.stop = stop ...
true
ea92968b66755c86da0f93dac46e7ef7fe5a84af
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/alxsk/session04/File_exercise.py
744
4.25
4
''' Read file exercise A script that reads students.txt and generates a list of the languages students know. ''' languages=set() with open('students.txt', 'r') as file_name: for line in file_name: line_split = line.split(":") #creates list keep_lang=line_split.pop() # removes and returns la...
true
112aa1ed121e19113544074b4fae75ae239162ed
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/solutions/Session03/string_formatting.py
1,647
4.59375
5
#!/usr/bin/env python """ String formatting lab: This version using the format() method """ ##### # Write a format string that will take the tuple: # (2, 123.4567, 10000, 12345.67) # and produce: # 'file_002 : 123.46, 1.00e+04, 1.23e+04' ##### print("file_{:03d} : {:10.2f}, {:.2e}, {:.3g}".format(2, ...
true
df75460a1d78ed644dc6123a042785c3bdff3f02
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/rusty_mann/Session02/series.py
1,339
4.125
4
def fibonacci(n): #if n == 0: if n == 0 or n == 1: return 0 #elif n == 1: elif n == 2: return 1 else: return fibonacci(n-2)+fibonacci(n-1) ###################################################################### def lucas(n): if n == 0: return 0 elif n == 1...
false
eadafa5a48a4a2eba2e37d3713d21d651a9962d4
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/jchristo/session03/list_lab.py
1,273
4.21875
4
#List Lab #!/usr/bin/env python3 """ Series 1 Create a list that contains “Apples”, “Pears”, “Oranges” and “Peaches”. Display the list (plain old print() is fine…). Ask the user for another fruit and add it to the end of the list. Display the list. Ask the user for a number and display the number back to the user and ...
true
d5e535b0b668e17c434ed6af84632736550b6e90
UWPCE-PythonCert-ClassRepos/Wi2018-Classroom
/students/maria/test.py
2,311
4.1875
4
# Return a copy of the sequence given after ordering transformation. def split(s,x): """Given a sequence break into three variables.""" first = s[:x] last = s[-x:] middle = s[x:-x] return first, last, middle def first_last(s): """Return a copy of a given sequence with first and last items swa...
true
a42b9f46df26cdbb91b2625ee4ab6b44b55d9d89
IshpreetKGulati/100DaysOfCode
/day7.py
1,259
4.3125
4
""" Monotonic Array Write a function that takes in an array of integers and returns a boolean representing whether the array is monotonic. An array is said to be monotonic if its elements, from left to right, are entirely non-increasing or entirely non -decreasing. Sample Input: array = [-1, -5, -10, -1100, -1100, -11...
true
18bb62cde4bf84e4734d3cb1cd05ae236c57a0bb
IshpreetKGulati/100DaysOfCode
/day29.py
1,565
4.1875
4
""" Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,4,7,5,3,6,8,9] Explanation: Will share image in whatsapp group Note: The total number of elements of th...
true
cd31a899c6e416d592f4a9feca8b008064a1e54b
hardy-awan/learning-python
/latPy/kalkulator2.py
758
4.1875
4
print("Masukan angka anda") def add(x, y): return x + y angka1 = int(input("silahkan masukan angka pertama : ")) angka2 = int(input("silahkan masukan angka kedua : ")) operator= input("silahkan masukan penjumlahan:") if operator == '+': print('{} + {} = ', add(angka1, angka2)) print() elif...
false
83462da197bb2f281be4cb41779ea530cdf64fa9
eduOSS/configuration_files
/Documents/python/git/forExce/guessNumber.py
1,896
4.21875
4
#template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import random import simplegui # initialize global variables used in your code range_num = 100 # helper function to start and restart the game def new_game(...
true
b1bfaeefd86ff33e4f6435d12811422df64d7741
Joey-Marcotte/ICS3U-Unit4-03-Python
/to_the_power_of.py
712
4.5
4
#!/usr/bin/env python3 # Created by: Joey Marcotte # Created on: October 2019 # This program shows the factorial of a number def main(): power_of_number = 0 total_number = 0 # input number = input("Input the number: ") try: number_as_number = int(number) if number_as_number ...
true
20311467d24015b8ebcc512a6c899f163a142d5b
Lwarren51/cti110
/P3HW2_SoftwareSales_WarrenLorenzo.py
1,898
4.1875
4
# CTI-110 # P3HW2 - Software Sales # Lorenzo Warren # March 11, 2018 # Get the quantity of the packages purchased 1. quantity10_19 = float(input('Enter the number of packages purchased 1: ')) # Calculate the amount the discount total purchased. discount = quantity10_19 * 99 # Display the discount. print('The discoun...
true
51fc1d9a5e2f1933b89a9a9874c86a41f1b37b58
sbtries/Class_Polar_Bear
/Code/Ryan/python/python3_lab_1.py
1,403
4.15625
4
score = input('Please enter a number representing the score (0-100): ') # Need to do an input validation if a letter is typed in this will be taught in 102 and requires # a 'try' / 'except' structure to see if using the float() function on the str would produce an error. try: score = float(score) except ValueError:...
true
6f4fbbe0cec197d63d5f8b212595075817e45bd9
sbtries/Class_Polar_Bear
/Code/Ryan/python/blackjack_advice.py
2,404
4.375
4
# Let's write a python program to give basic blackjack playing advice during a game by asking the player for cards. First, ask the user for three playing cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K). Then, figure out the point value of each card individually. Number cards are worth their number, all face cards are...
true
c9ecc1d15bc842832d7845476a70018f99b961f8
sbtries/Class_Polar_Bear
/2 Python/demo/hello.py
359
4.1875
4
"Hello" # string 4 # int 2.5 # float True # boolean / False None # none x = input("Enter a number: ") try: x = int(x) except ValueError: print("That was not a number...") exit() if x > 0: print("This number is positive") print("😎") elif x == 0: print('The number is 0') else:...
true
66c40980c69ca5004482cf638ff8c92172a15288
Shingirai98/Digital-Factorial-Summer-
/factorial-digits.py
1,128
4.125
4
# ------------------------------------------------------- # | Name: Digital Factorial Sum | # | @Author: Shingirai Denver Maburutse | # | Date: 18/07/2021 | # ----------------------------------------------------- import numpy as n...
true
826c4375823225cd442946ed45c02ee9a87f0b9d
raadzi/comp110-21ss1-workspace
/projects/pj01/data_utils.py
1,699
4.125
4
"""Data utility functions.""" __author__ = "730429363" from csv import DictReader def read_csv_rows(path: str) -> list[dict[str, str]]: """Read a CSV file and return a table that is a list of its rows (dicts).""" file_handle = open(path, "r", encoding="utf8") csv_reader = DictReader(file_handle) ta...
true
94d312e5bde0f084dd1fb9351e04ef5c4d408542
Zhaoyubao/Onsite-Python
/Python OOP/Bike.py
807
4.1875
4
class Bike(object): def __init__(self, price, max_speed): self.price = price self.max_speed = max_speed self.miles = 0 def displayinfo(self): print "Bike's Price:", self.price print "Bike's Maximum Speed:", self.max_speed if self.miles < 0: self.miles ...
true
cf8994a4a1f3d61dc896e27c4533d1c895f7a85c
MattPhillips1/comp1531-wk8
/Rectangle.py
1,354
4.1875
4
from abc import abstractmethod, ABC class Shape(ABC): def __init__(self, color): self._color = color @abstractmethod def area(self): pass @abstractmethod def scale(self, ratio): pass class Rectangle(Shape): def __init__(self, width, height, color): Shape.__...
false
bf50bc2d83fc835fe197b3b0a6031eb875a37970
green-fox-academy/Simon--Kerub88
/week-04/day-3/E_02_Sum.py
696
4.21875
4
# Create a sum method in your class which has a list of integers as parameter # It should return the sum of the elements in the list # Follow these steps: # Add a new test case # Instantiate your class # create a list of integers # use the assertEquals to test the result of the created sum method # Run ...
true
162050d2f9723d5194ccbb8b654f100809ab0cc5
green-fox-academy/Simon--Kerub88
/week-02/day-5/Guess_my_number.py
1,978
4.3125
4
# Write a program where the program chooses a number between 1 and 100. The player is then asked to enter a guess. If the player guesses wrong, then the program gives feedback and ask to enter an other guess until the guess is correct. # # Make the range customizable (ask for it before starting the guessing). # You can...
true
53b5bd025757649396f7dce0f3321fa6bb8925c1
green-fox-academy/Simon--Kerub88
/week-02/day-2/E_11_seconds-in-a-day.py
399
4.28125
4
current_hours = 14; current_minutes = 34; current_seconds = 42; # Write a program that prints the remaining seconds (as an integer) from a # day if the current time is represented bt the variables TotalDaySeconds = 60*60*24 print(TotalDaySeconds) current_seconds = (14*60*60) + (34*60) + 42 print(current_seconds) prin...
true
b545f00ca11459c59fa36c7ffb5a947175d8471a
PengChen11/math-series
/math_series/series.py
1,337
4.21875
4
# function to calculate the nth fibonacci number. I hate using recursion for this task cause the big O is 2*n and when n goes above 30, it eats up all my computer's resources. # The following solution's big O is only n-2. much faster. # n starts with 0. def fibonacci(n): prev, nex = 0, 1 for i in range(n - 1): ...
true
beba030545cf43bc8b8921a9f65796af35ebacd7
mahmud-sajib/30-Days-of-Python
/L #23 - Class & Object.py
1,997
4.65625
5
## Day 23: Class & Object ## Concept: Creating a Class - To define a class, use the class keyword, and define the data points inside. # Simple class with a property class Person: name = "John Wick" ## Concept: Creating an Object - o create a new object, simply reference the class you want to build the object ou...
true
f4aa81270ce4056c79fa5e5f165844b6984f4efe
mahmud-sajib/30-Days-of-Python
/L #20 - Generators.py
934
4.46875
4
## Day 20: Python Generators ## What are generators in Python? """ Python generators are a simple way of creating iterators. A generator is a function that returns an object (iterator) which we can iterate over (one value at a time). """ ## How to create a generator in Python? """ It is the same as defining a normal...
true
0b94b60f57bc7df66c46ab53e8876cc79c41f505
mahmud-sajib/30-Days-of-Python
/L #14 - First Class Functions.py
2,892
4.125
4
## Day 14: First Class Functions ## Concept: What are first class functions? """ In Python, functions are first class object (first class citizen too!). Programming language theorists defined some criteria for first class object of a programming language. A “first class object” is a program entity which can be : 1...
true
c65dd1db722d58105d44319f10926aca267ff5b9
srmchem/python-samples
/Python-code-snippets-101-200/149-Convert KMH to MPH.py
298
4.21875
4
''' Python Code Snippets - stevepython.wordpress.com 149-Convert KMH to MPH Source: https://www.pythonforbeginners.com/code-snippets-source-code/ python-code-convert-kmh-to-mph/ ''' kmh = int(input("Enter km/h: ")) mph = 0.6214 * kmh print ("Speed:", kmh, "KM/H = ", mph, "MPH")
false
d75a3e2695842452e0b9e7b79b45603d17c438ac
srmchem/python-samples
/Python-code-snippets-201-300/294-All permutations of a string.py
615
4.3125
4
"""Code snippets vol-59 294-Print permutations of a given string Download all snippets so far: https://wp.me/Pa5TU8-1yg Blog: stevepython.wordpress.com Requirements: None origin: https://gist.github.com/accakks/fbf2383ce782bbf089c68a807695b3e1 """ from itertools import permutations def ...
true
1f503566bf6c2b75cec56f463c8d255737b75f84
srmchem/python-samples
/Python-code-snippets-201-300/284-Check string for pangram.py
860
4.15625
4
"""Code snippets vol-57 284-Check string for a pangram Download all snippets so far: https://wp.me/Pa5TU8-1yg Blog: stevepython.wordpress.com Requirements: None original code here: https://gist.github.com/Allwin12/4f8d9d8066adc838558a22949ba400c0 """ import string alphabets = string.ascii...
true
9e75fdf33b319779671252f257d4f6c018c6ea4c
KarlosTan/python-bootcamp
/session1/conditions/speed_func.py
1,710
4.25
4
def speed_function_simple(speed): # example of function with no return value if speed < 80: print(" speed is ok") else: print(" you. have to pay a fine") def speed_function_advanced(speed, provisonal): # example of function with return value total_fine = 0 print(provisonal, ' is pro...
true
40204f14232ce556f2a3b2221d24e4fe4737186e
KarlosTan/python-bootcamp
/session1/loops/nested_loops.py
1,685
4.21875
4
import numpy as np import random import sys # for end or endline in nested food loops, python 3 def nested_loops(): print(' nested loops function') #https://www.ict.social/python/basics/multidimensional-lists-in-python length = 3 width = 4 height = 5 two_dimen = np.random.rand(length, width) p...
false
dbe62c68d5e967190b9c9b81b3bd8d52b33479b8
KarlosTan/python-bootcamp
/session4/simple_programs/palindromine_others.py
1,460
4.34375
4
#Source: https://www.geeksforgeeks.org/python-program-check-string-palindrome-not/ # Python program to check # if a string is palindrome # or not x = "malayalam movies" w = "" for i in x: w = i + w print(w, ' *') if (x == w): print("Yes") else: print("No") # Python program to check # if a ...
false
944099badbe822e8bddeec61d337320be7ec6c40
BeefCakes/CS112-Spring2012
/day4-2.py
328
4.15625
4
#!/usr/bin/env python TAs = ["Alec","Jack","Jonah"] #added later, a list name_in=raw_input("enter a name: ") if name_in == "Paul": print "you are cool" elif name_in in TAs: #originally: elif name_in == "Alec" or name_in == "Jonah" or name_in == "Jack": print "you smell bad" else: print "you need some le...
false
8eaeaa038a8a7fe4cb91b24eb0d881645fccfd53
BeefCakes/CS112-Spring2012
/hw10/multidim.py
2,653
4.3125
4
#!/usr/bin/env python """ multidim.py Multidimensional Arrays ========================================================= This section checks to make sure you can create, use, search, and manipulate a multidimensional array. """ # 1. find_coins # find every coin (the number 1) in a givven room # room:...
true
4be6912a06cdeb6e179e8168208d4869c8fab455
ruchika0201/Basic-Data-Stuctures
/strings/Python/camel.py
962
4.1875
4
#Alice wrote a sequence of words in CamelCase as a string of letters, , having the following properties: #It is a concatenation of one or more words consisting of English letters. #All letters in the first word are lowercase. #For each of the subsequent words, the first letter is uppercase and rest of the letters are l...
true
d4bc2da87af4976f6a1e39162acfd8faea3504c5
gugun/pythoncourse-coder-dojo
/day02/module_package/main.py
374
4.3125
4
""" This program will calculate triangle area using the formula area = height * bottom /2 """ import geometry.triangle as triangle import geometry.square as square import geometry.circle as circle print 'Main Program' print 'Triangle area', triangle.calc_triangle_area(10, 5) print 'Square area', square.calc_square_are...
true
c04ee354b90c1f259d29db36178d280d2c81db09
longlee218/Python-Algorithm
/020_week5/020_rectangles.py
663
4.21875
4
""" A rectangle is represented as a list [x1, y1, x2, y2] where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordinates of its top-right corner. Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corn...
true
e4a6e5850fd8df693131d90db42251b15a8e5972
longlee218/Python-Algorithm
/017_week2/17+4_dubstep.py
1,384
4.25
4
""" Let's assume that a song consists of some number of words. To make the dubstep remix of this song ,Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero) ,after the last word (the number may be zero), and between words (at least one between any pair of n...
true
9165aca764ec0baab0df685e9148912420b82e20
longlee218/Python-Algorithm
/014_largest_mul.py
2,715
4.15625
4
""" Hi, here's your prblem today. This problem was recently ask by Microsoft You are given an array of integers. Return the largest product that can be made by multiplying any 3 integers in the array Example [-4, -4, 2, 8] should return 128 as the largest product can made by multiplying -4 * -...
true
74a4103afa9e439d53d2a2fe2f4d74a8d78ad209
mariuszbrozda/python_rps_game
/rps.py
2,072
4.375
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____)...
false
b16767793fdab1333e0ae15b6a6f11ddb2d70012
PatrickArthur/FunWithPython
/demo.py
385
4.1875
4
name = raw_input("What is your name? ") while name != "Patrick": print("{} Nice to meet you, how do you like python".format(name, name)) print "Your name length: {0}".format(len(name)) raw_input("Press <ENTER> to exit\n") name = raw_input("What is your name? ") else: print("{} Is my name, and I like python"....
true
118286ce5dc33d660367b05f66c5bcd9c336b371
crystal1509/Day-5
/facrecursion.py
315
4.21875
4
#Python Program to Find Factorial of Number Using Recursion def fac_recursion(n): if n==1: return n else: return n*fac_recursion(n-1) num=int(input("enter a number:")) if num<0: print("negative number!!! enter again") else: print("factorial is:",fac_recursion(num))
false
d530661de1b951cd8660beebd5e82f8343a87d4e
kamranajabbar/python3_practice
/10-classes.py
1,458
4.46875
4
#Chapter # 53-61 Classes class Car(): def __init__(self, make, model, year): self.make = make self.model = model self.year = year self.battery = "200 AMP" #Default attribute def descriptionCar(self): print(f"The make of car is {self.make}") print(f"The mo...
true
10335d9043dd5add872d6dc67802c171959cfbb0
kamranajabbar/python3_practice
/13-csv.py
930
4.375
4
#Chapter # 67-73 CSV files #67: CSV files #68: CSV files: Reading them #69: CSV files: Picking information out of them #70: CSV files: Loading information into them. Part 1 #71: CSV files: Loading information into them. Part 2 #72: CSV files: Loading information into them. Part 3 #73: CSV files: Appending rows to them...
true
b54dfc1418d04d43179927efe953fcabcd067706
khanhbao128/HB-Code-Challenge-Problems
/Whiteboarding problems/Easier/remove_duplicates.py
818
4.21875
4
# given a list of items, return the new list of items in the same order but with all duplicates removed # Q: what does an empty list return? empty list def deduped(items): """Remove all duplicates in a list and return the new list of items in the same order""" # new_list = [] # for item in items: # ...
true
080d4f2b339e75cb49611cd1920733dd26dece94
tamatamsaigopi/python
/rotatearray.py
829
4.6875
5
# Python program to left rotate array # Function to rotate arrays in Python def rotateArrayLeft(arr, R, n): for i in range(R): firstVal = arr[0] for i in range(n-1): arr[i] = arr[i+1] arr[n-1] = firstVal # Taking array input from user arr = [1, 2, 3, 4, 5, 6, 7] n = int(input("Ent...
true
117166ff8c5d0a3b4f2f08159c4056e071554d34
xanderquigley/a1_prog1700
/hipster_local_records.py
1,751
4.34375
4
""" Student Name: Alex Quigley - W0458866 Program Title: IT Data Analytics Description: Assignment 1 - Problem 1 - Hipster's Local Vinyl Records This program will take in customer information and calculate the total for the customer to pay for the records purchased along with the price of delivery. """ def main():...
true
556ce7be3a1a5d91f7138537ac575e94a72ff7b2
alexpickering/Python
/printWithoutVowels.py
600
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: taka0 """ def print_without_vowels(s): ''' s: the string to convert Finds a version of s without vowels and whose characters appear in the same order they appear in s. Prints this version of s. Does not return anything ''' vowels ...
true
56977469a39132bf485b07cc6401d77c9a169f8b
nekocheik/python__back
/exercises /sort_array_by_element_frequency.py
1,282
4.25
4
"""Sort the given iterable so that its elements end up in the decreasing frequency order, that is, the number of times they appear in elements. If two elements have the same frequency, they should end up in the same order as the first appearance in the iterable.""" from collections import Counter def frequency_sor...
true
0f0a720060fe01d52d250c29f505dc3d9010a27a
agastyajain/Number-Guessing-Game
/NumberGuessingGame.py
594
4.21875
4
import random print('Welcome To The Number Guessing Game !!!') number = random.randint(1,9) chances = 0 print('Guess a number between 1 and 9 ...') while chances < 5: guess = int(input('Enter your guess: ')) if guess == number: print('Congrats! You Won') break elif guess < numb...
true
4848076f5d159bdd1ed89bc0632de8b5e4bb3b91
wherculano/Curso-em-Video-Python
/Desafio103.py
899
4.3125
4
#Desafio103.py ''' Faça um programa que tenha uma função chamada ficha(), que receba dois parametros opcionais: o nome de um jogador e quantos gols ele marcou. O programa deverá ser capaz de mostrar a ficha do jogador, mesmo que algum dado não tenha sido informado corretamente. Nome do Jogador: Romario Numero ...
false
72208fd934ad705cdc8a81773b01f37994349c65
wherculano/Curso-em-Video-Python
/Desafio037.py
649
4.125
4
#Desafio037 - Binario, Octal e Hexadecimal sair = 's' while sair == 's': n = int(input('\nDigite um número inteiro: ')) op = int(input('\nAgora escolha para qual base deseja converte-lo:\ \n1- Binário\n2- Octal\n3- Hexadecimal\n')) if op == 1: print('{} em Binário = {}\n'.format(n, str(bin(...
false
ed4c96100cc1fb4c6316a8f457884567d3875d4b
wherculano/Curso-em-Video-Python
/Desafio102.py
859
4.4375
4
#Desafio102.py ''' Crie um programa que tenha uma função fatorial() que recebe dois parametros: o primeiro que indique o numero a calcular e o outro chamado show, que será um valor lógico (opcional) indicando se será mostrado ou não na tela o processo de calculo do fatorial print(fatorial(5)) >>> 120 print(...
false
c7b0cb79a06393adb912e0b4ac6fdd38a002f2af
sofiakn/pycoding
/ch03-repetitions/01-while.py
343
4.125
4
number = int( input("Enter a number for times table (0 to stop): ")) while number != 0 : print(f"{number} x 1 = {number*1}") print(f"{number} x 2 = {number*2}") print(f"{number} x 3 = {number*3}") print() number = int( input("Enter a number for times table (0 to stop): ")) print("Thank you fo...
true
595207952cdedd6cb8f38c34800546c70a2b244d
sofiakn/pycoding
/ch02-conditions/02tax.py
261
4.1875
4
# Ask for the price and if price is dollar or more, there will be tax otherwise no tax is charged price = float(input("What is the \"price\"? ")) if price >= 1.0 : print("You will be charged tax") else : print("You will not be charged tax")
true
0a72559c8782ecbf0fa9598ce478a8eb007c9116
c4collins/Euler-Project
/euler25.py
261
4.125
4
def fibonacci(length): # initialize variables num1 = 1 num2 = 1 even_total = 0 term = 2 while len(str(num1)) < length: # generate fibonacci series num_total = num1 + num2 num2 = num1 num1 = num_total term += 1 return term print fibonacci(1000)
false