blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4a8c2ad2eafe2cefe78c0ccd5750f097671c7075
GermanSumus/Algorithms
/unique_lists.py
651
4.3125
4
""" Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays. In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array. The unique numbers should be sorted by the...
true
b7ac1cfbb9087510ade29a2d2605b8cc01345d1f
GermanSumus/Algorithms
/factorialize.py
268
4.21875
4
# Return the factorial of the provided integer # Example: 5 returns 1 * 2 * 3 * 4 * 5 = 120 def factorialize(num): factor = 1 for x in range(1, num + 1): factor = factor * x print(factor) factorialize(5) factorialize(10) factorialize(25)
true
c2790a23c2030775a1ed612e3ee55c594ad30802
iamzaidsoomro/Python-Practice
/Calculator.py
706
4.15625
4
def calc(): choice = "y" while(choice == "y" or choice == "Y"): numb1 = input("Enter first number: ") numb2 = input("Enter second number: ") op = input("Enter operation: ") numb1 = int(numb1) numb2 = int(numb2) if op == '+': print("Sum = " + str(numb1 + nu...
false
8f076f012de7d9e71daff7736fc562eff99078aa
kartikay89/Python-Coding_challenges
/countLetter.py
1,042
4.5
4
""" Write a function called count_letters(text, letter), which receives as arguments a text (string) and a letter (string), and returns the number of occurrences of the given letter (count both capital and small letters!) in the given string. For example, count_letters('trAvelingprogrammer', 'a') should return 2 an...
true
7c54349a4f78cefb44bff8616fc370b865849d48
kartikay89/Python-Coding_challenges
/phoneNum.py
1,223
4.53125
5
""" Imagine you met a very good looking guy/girl and managed to get his/her phone number. The phone number has 9 digits but, unfortunately, one of the digits is missing since you were very nervous while writing it down. The only thing you remember is that the SUM of all 9 digits was divisible by 10 - your crush was ne...
true
c3bd11215bb589aa0940cf92e249d2dd8815b8e8
ravenawk/pcc_exercises
/chapter_07/deli.py
413
4.28125
4
#!/usr/bin/env python3 ''' Making sandwiches with while loops and for loops ''' sandwich_orders = ['turkey', 'tuna', 'ham'] finished_sandwiches = [] while sandwich_orders: current_sandwich = sandwich_orders.pop() finished_sandwiches.append(current_sandwich) print(f"I made your {current_sandwich} sandwich....
true
b0ee2dc3c3865353f42b2b18c45e0a8b77c7c7bc
ravenawk/pcc_exercises
/chapter_04/slices.py
326
4.25
4
#!/usr/bin/env python3 list_of_cubes = [ value**3 for value in range(1,11)] for cube in list_of_cubes: print(cube) print(f"The first 3 items in the list are {list_of_cubes[:3]}.") print(f"Three items in the middle of the list are {list_of_cubes[3:6]}.") print(f"The last 3 items in the list are {list_of_cubes[-3:...
true
f87fbc9f1ad08e89dd1fd5e561bf0956f01b2a6e
ravenawk/pcc_exercises
/chapter_07/dream_vacation.py
381
4.21875
4
#!/usr/bin/env python3 ''' Polling for a dream vacation ''' places_to_visit = [] poll = input("Where would you like to visit some day? ") while poll != 'quit': places_to_visit.append(poll) poll = input("Where would you like to visit one day? (Enter quit to end) ") for place in places_to_visit: print(f"{p...
true
b102953b0aaef366c4056dfb9b94210c416b7512
ravenawk/pcc_exercises
/chapter_08/user_albums.py
514
4.34375
4
#!/usr/bin/env python3 ''' Function example of record album ''' def make_album(artist_name, album_title, song_count=None): ''' Create album information ''' album = {'artist': artist_name, 'album name': album_title,} if song_count: album['number of songs'] = song_count return album while True: ...
true
0d1604f91d1634f8d3d55d54edc6ed1bc0ce44ca
Tananiko/python-training-2020-12-14
/lists.py
709
4.15625
4
names = [] # ures lista names = ["John Doe", "Jane Doe", "Jack Doe"] john = ["John Doe", 28, "johndoe@example.com"] print(names[0]) print(names[1]) # print(names[4]) # list index out of range print(names[::-1]) print(names) numbers = [1, 2, 3, 4, 5] print(numbers) print(len(numbers)) employees = [['John Doe',...
false
12c1a2d3672a7f0c7d391e958e8a047ff3893106
joesprogramming/School-and-Practice
/Calculate Factorial of a Number CH 4 pgm 10.py
281
4.25
4
# Joe Joseph # intro to programming # Ask user for a number fact = int(input('Enter a number and this program will calculates its Factorial: ',)) # define formula num = 1 t = 1 #run loop while t <= fact: num = num * t t = t + 1 print(num)
true
b931256e821d0b59a907d580734f21c455c22eb4
joesprogramming/School-and-Practice
/person customer/person.py
1,175
4.125
4
#Joe Joseph # Intro to Programming #Primary Class class Person: def __init__(self, name_p, address_1, phone_1): self.__name_p = name_p self.__address_1 = address_1 self.__phone_1 = phone_1 def set_name_p(self, name_p): self.__name_p = name_p de...
false
6a159a65ea848c61eb4b35980b2bd524a5487b56
BzhangURU/LeetCode-Python-Solutions
/T522_Longest_Uncommon_Subsequence_II.py
2,209
4.125
4
##Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings. ## ##A subsequence is a sequence that can be derived from one s...
true
b339e1b0f40936bbb6974725c525364fa0667a49
Andrejs85/izdruka
/for_cikls.py
1,706
4.1875
4
#iteracija - kadas darbibas atkartota izpildišana mainigais=[1,2,3] for elements in mainigais: print(elements) #darbibas kas javeic #izdruka list elementus myList=[1,2,3,4,5,6,7,8,9,10,11,12] for sk in myList: print(sk) for _ in myList: print("Sveiki!") #var nerakstit cikla mainiga nosaukumu #izdruka tik...
false
79d8085cb879c116c4092396ecc83fa1b7f2b5d2
SanaaShah/Python-Mini-Assignments
/6__VolumeOfSphere.py
290
4.5625
5
# 6. Write a Python program to get the volume of a sphere, please take the radius as input from user. V=4 / 3 πr3 from math import pi radius = input('Please enter the radius: ') volume = 4 / (4 * pi * 3 * radius**3) print('Volume of the sphere is found to be: '+str(round(volume, 2)))
true
4ac590cb424a5d27fc41ccfe671b7c42db027139
SanaaShah/Python-Mini-Assignments
/30__OccurenceOfLetter.py
331
4.21875
4
# 30. Write a Python program to count the number occurrence of a specific character in a string string = input('Enter any word: ') word = input('Enter the character that you want to count in that word: ') lenght = len(string) count = 0 for i in range(lenght): if string[i] == word: count = count + 1 p...
true
53577eb885ed53f2ba4c0d09fa7a0262ff6fdb2f
SanaaShah/Python-Mini-Assignments
/2__checkPositive_negative.py
350
4.4375
4
# 2. Write a Python program to check if a number is positive, negative or zero user_input = float(input('Please enter any number: ')) if user_input < 0: print('Entered number is negative.') elif user_input > 0: print('Entered number is positive') elif user_input == 0: print('You have entered zero, its ne...
true
f81383ec7b0b8be08c8c40ec057866c6b4383879
SanaaShah/Python-Mini-Assignments
/1__RadiusOfCircle.py
299
4.53125
5
# 1. Write a Python program which accepts the radius of a circle from the user and compute the area from math import pi radius = float((input('Please enter the radius of the cricle: '))) print('Area of the circle of radius: '+str(radius) + ' is found to be: '+str(round((pi * radius**2), 2)))
true
06827bf14302ec76a9b9d64a66273db96e3746fa
duplys/duplys.github.io
/_src/recursion/is_even.py
557
4.59375
5
"""Example for recursion.""" def is_even(n, even): """Uses recursion to compute whether the given number n is even. To determine whether a positive whole number is even or odd, the following can be used: * Zero is even * One is odd * For any other number n, its evenness is the same as n-2 ...
true
c3a181aea806b68ce09197560eeb485ca6d8419d
jamesb97/CS4720FinalProject
/FinalProject/open_weather.py
1,535
4.25
4
''' Python script which gets the current weather data for a particular zip code and prints out some data in the table. REST API get weather data which returns the Name, Current Temperature, Atmospheric Pressure, Wind Speed, Wind Direction, Time of Report. ''' import requests #Enter the corresponding api key from...
true
18200cb8e9e584fe454d57f3436a9184159388b8
ayoubabounakif/edX-Python
/ifelifelse_test1_celsius_to_fahrenheit.py
811
4.40625
4
#Write a program to: #Get an input temperature in Celsius #Convert it to Fahrenheit #Print the temperature in Fahrenheit #If it is below 32 degrees print "It is freezing" #If it is between 32 and 50 degrees print "It is chilly" #If it is between 50 and 90 degrees print " It is OK" #If it is above 90 degrees prin...
true
b9804e7911242e9c4eae1074e8ef2949155d60e0
ayoubabounakif/edX-Python
/sorting.py
515
4.125
4
# Lets sort the following list by the first item in each sub-list. my_list = [[2, 4], [0, 13], [11, 14], [-14, 12], [100, 3]] # First, we need to define a function that specifies what we would like our items sorted by def my_key(item): return item[0] # Make the first item...
true
f3019b4227dfd2a758d0585fb1c2f9e27df1b8e9
ayoubabounakif/edX-Python
/quizz_1.py
275
4.28125
4
#a program that asks the user for an integer 'x' #and prints the value of y after evaluating the following expression: #y = x^2 - 12x + 11 import math ask_user = input("Please enter an integer x:") x = int(ask_user) y = math.pow(x,2) - 12*x + 11 print(int(y))
true
7013c99a792f116a7b79f4ad1a60bfb3f4b1a8a2
ayoubabounakif/edX-Python
/quizz_2_program4.py
1,141
4.34375
4
#Write a program that asks the user to enter a positive integer n. #Assuming that this integer is in seconds, #your program should convert the number of seconds into days, hours, minutes, and seconds #and prints them exactly in the format specified below. #Here are a few sample runs of what your program is suppos...
true
940e284ec16e99a3349d00e0611e487cdce976f1
ayoubabounakif/edX-Python
/quizz_3_part3.py
397
4.1875
4
# Function that returns the sum of all the odd numbers in a list given. # If there are no odd numbers in the list, your function should return 0 as the sum. # CODE def sumOfOddNumbers(numbers_list): total = 0 count = 0 for number in numbers_list: if (number % 2 == 1): total += ...
true
9774dac844cb3985d733af0c87e697b85f93be88
ayoubabounakif/edX-Python
/for_loop_ex2.py
296
4.3125
4
#program which asks the user to type an integer n #and then prints the sum of all numbers from 1 to n (including both 1 and n). # CODE ask_user = input("Type an integer n:") n = int(ask_user) i = 1 sum = 0 for i in range(1, n+1): sum = sum + i print (sum)
true
69b29ccaa611a0e92df5f8cd9b3c59c231847b72
fingerman/python_fundamentals
/python-fundamentals/4.1_dict_key_value.py
1,032
4.25
4
''' 01. Key-Key Value-Value Write a program, which searches for a key and value inside of several key-value pairs. Input • On the first line, you will receive a key. • On the second line, you will receive a value. • On the third line, you will receive N. • On the next N lines, you will receive strings in the following ...
true
41b3d14d2ff362836aaf33ab6d7af0382b240d22
fingerman/python_fundamentals
/python_bbq/1tuple/tup_test.py
580
4.40625
4
""" tuples may be stored inside tuples and lists """ myTuple = ("Banane", "Orange", "Apfel") myTuple2 = ("Banane1", "Orange1", "Apfel1") print(myTuple + myTuple2) print(myTuple2[2]) tuple_nested = ("Banane", ("Orange", "Strawberry"), "Apfel") print(tuple_nested) print(tuple_nested[1]) print(type(tuple_nested[1])) ...
false
b0936ba1bc7bc61bec45b91ebb9467b0da6cd47e
fingerman/python_fundamentals
/python_bbq/OOP/008 settergetter.py
1,220
4.46875
4
class SampleClass: def __init__(self, a): ## private varibale or property in Python self.__a = a ## getter method to get the properties using an object def get_a(self): return self.__a ## setter method to change the value 'a' using an object def set_a(self, a): sel...
true
45b01f271a65e346353cc5fcd18383ff480b8c9d
fingerman/python_fundamentals
/python-fundamentals/exam_Python_09.2018/1.DateEstimation.py
1,251
4.4375
4
''' Problem 1. Date estimation Input / Constraints Today is your exam. It’s 26th of August 2018. you will be given a single date in format year-month-day. You should estimate if the date has passed regarding to the date mention above (2018-08-26), if it is not or if it is today. If it is not you should print how many ...
true
d1d7f48647893caeefd979258abd684763d507ba
rgbbatista/devaria-python
/exercícios 2.py
1,859
4.25
4
'''Escrever um prog que recebe dois num e um operador matemático e com isso executa um calculo corretamente''' def soma(num1 , num2): # criando função print('Somando', num1 + num2) resultado = num1 + num2 return resultado def subtracao(num1 , num2): # criando função print('Subtraindo', num1 - num2) ...
false
ec67e60dc31824809ecf5024ce76c1708a46b295
rmalarc/is602
/hw1_alarcon.py
1,967
4.28125
4
#!/usr/bin/python # Author: Mauricio Alarcon <rmalarc@msn.com> #1. fill in this function # it takes a list for input and return a sorted version # do this with a loop, don't use the built in list functions def sortwithloops(input): sorted_input = input[:] is_sorted = False while not is_sorte...
true
1ead53f839aedb80b3d3360ad1d1c972710a2d69
Austinkrobison/CLASSPROJECTS
/CIS210PROJECTS/PROJECT3/DRAW_BARCODE/draw_barcode.py
2,588
4.15625
4
""" draw_barcode.py: Draw barcode representing a ZIP code using Turtle graphics Authors: Austin Robison CIS 210 assignment 3, part 2, Fall 2016. """ import argparse # Used in main program to obtain 5-digit ZIP code from command # line import time # Used in main program to pause program before exit impo...
true
8dd8056d42f4b32c463bc559c4ee173c2339e067
tlarson07/dataStructures
/tuples.py
1,378
4.3125
4
#NOTES 12/31/2016 #Python Data Structures: Tuples #Similar to lists BUT #Can't be changed after creation (NO: appending, sorting, reversing, etc. #Therefore they are more efficient friends = ("Annalise", "Gigi", "Kepler") # numbers = (13,6,1,23,7) print friends[1] print max(numbers) (age,name) = (15,"Lauren") #assi...
true
211273d69389aee16e11ffc9cf9275c0f509029e
sudhapotla/untitled
/Enthusiastic python group Day-2.py
2,426
4.28125
4
# Output Variables # python uses + character to combine both text and Variable x = ("hard ") print("we need to work " + x) x = ("hardwork is the ") y = (" key to success") z = (x + y) print(z) #Create a variable outside of a function, and use it inside the function x = "not stressfull" def myfunc(): print("Python ...
true
deaa241ca580c969b2704ae2eb830487b247c766
sudhapotla/untitled
/Python variables,Datatypes,Numbers,Casting.py
1,192
4.25
4
#Python Variables #Variables are containers for storing data values. #Rules for Variable names #A variable name must start with a letter or the underscore character #A variable name cannot start with a number #A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) #Variable names a...
true
a070d7391d0b798ed5d4b143c113b58d2134b6c4
Allegheny-Computer-Science-102-F2018/classDocs
/labs/04_lab/sandbox/myTruthCalculatorDemo.py
1,176
4.3125
4
#!/usr/bin/env python3 # Note: In terminal, type in "chmod +x program.py" to make file executable """calcTruth.py A demo to show how lists can be used with functions to make boolean calculations""" __author__ = "Oliver Bonham-Carter" __date__ = "3 October 2018" def myAND(in1_bool, in2_bool): # functio...
true
cbe189e695f9b2a21c1f708c3a724fb5ab8e23af
mehulchopradev/curtly-python
/more_more_functions.py
853
4.15625
4
def abc(): a = 5 # scope will abc b = 4 def pqr(): # scope will abc print('PQR') print(a) # pqr() can access the enclosing function variables b = 10 # scope will pqr print(b) # 10 pqr() print(b) # 4 abc() # pqr() # will not work # fun -> function object # scope -> module def fun(): p...
false
d80dcff9be08846685f9f553817a16daf91a2d77
JeanneBM/PyCalculator
/src/classy_calc.py
1,271
4.15625
4
class PyCalculator(): def __init__(self,x,y): self.x=x self.y=y def addition(self): return self.x+self.y def subtraction(self): return self.x - self.y def multiplication(self): return self.x*self.y def division(self): if self.y == 0: ...
true
3f6ff625caa4763758eab2acd908db3abb976e1c
taizilinger123/apple
/day2/高阶函数.py
938
4.125
4
var result = subtract(multiply(add(1,2),3),4); #函数式编程 def add(a,b,f): #高阶函数 return f(a)+f(b) res = add(3,-6,abs) print(res) { 'backend':'www.oldboy.org', 'record':{ 'server':'100.1.7.9', 'weight':20, 'maxconn':30 } } >>> b = ''' ... { ... 'backend':'www.oldboy.org', ... ...
false
ee136845779de40a10d2deb1362f98d3700455dc
markorodic/python_data_structures
/algorithms/bubble_sort/bubble_sort.py
238
4.15625
4
def bubblesort(array): for j in range(len(array)-1): for i in range(len(array)-1): if array[i] > array[i+1]: array[i], array[i+1] = array[i+1], array[i] return array # list = [7,4,2,3,1,6] # print list # print bubblesort(list)
false
ff7dbb03f9a296067fbd7e9cfff1ff58d2a00a63
jocogum10/learning_python_crash_course
/numbers.py
1,487
4.40625
4
for value in range(1,5): print(value) for value in range(1,6): print(value) numbers = list(range(1,6)) print(numbers) even_numbers = list(range(2,11,2)) print(even_numbers) #square values squares = [] #create empty list for value in range(1,11): #loop from 1 to 10 using range function square = value**2 #st...
true
f38a0a567da80562246900f4d8986106e6f99509
CrownCrafter/School
/great3.py
423
4.15625
4
#!/usr/bin/env python3 a = int(input("Enter Number ")) b = int(input("Enter Number ")) c = int(input("Enter Number ")) if(a>=b and a>=c): print("Largest is " + str(a)) elif(b>=a and b>=c): print("Largest is " + str(b)) else: print("Largest is " + str(c)) if(a<=b and a<=c): print("Smallest is " + st...
false
17d50543233400d554d9c838e64ec0c6f5506ce6
ArashDai/SchoolProjects
/Python/Transpose_Matrix.py
1,452
4.3125
4
# Write a function called diagonal that accepts one argument, a 2D matrix, and returns the diagonal of # the matrix. def diagonal(m): # this function takes a matrix m ad returns an array containing the diagonal values final = [] start = 0 for row in m: final.append(row[start]) start += 1 ...
true
15380c51a8f569f66e9ecf0f34000dfe32db85c0
DoolPool/Python
/Calculadora Basica/Calculadora-Vs1.py
1,147
4.1875
4
print("=== CALCULADORA BASICA ===") print("Elige una opción : ") print("1.-Suma") print("2.-Resta") print("3.-Multiplicación") print("4.-División") x= input("Escribe tu elección : ") y= float(x) if(y==1): a=input("Introduce el primer numero \n") b=input("Introduce el segundo numero \n") a2=float(a) ...
false
3f2328a01dd09470f4421e4958f607c3b97a5e1f
Remyaaadwik171017/mypythonprograms
/flow controls/flowcontrol.py
244
4.15625
4
#flow controls #decision making(if, if.... else, if... elif... if) #if #syntax #if(condition): # statement #else: #statement age= int(input("Enter your age:")) if age>=18: print("you can vote") else: print("you can't vote")
true
8fd6028336cac45579980611e661c84e892bbf12
danksalot/AdventOfCode
/2016/Day03/Part2.py
601
4.125
4
def IsValidTriangle(sides): sides.sort() return sides[0] + sides[1] > sides [2] count = 0 with open("Input") as inputFile: lines = inputFile.readlines() for step in range(0, len(lines), 3): group = lines[step:step+3] group[0] = map(int, group[0].split()) group[1] = map(int, group[1].split()) group[2] = map(i...
true
005807a3b2a9d1c4d9d1c7c556ac27b7c526c39f
sumnous/Leetcode_python
/reverseLinkedList2.py
1,585
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Created on 2014-03-02 @author: Ting Wang ''' #Reverse a linked list from position m to n. Do it in-place and in one-pass. #For example: #Given 1->2->3->4->5->NULL, m = 2 and n = 4, #return 1->4->3->2->5->NULL. #Note: #Given m, n satisfy the following condition: #1 ≤ m ...
false
f78c5a609bc06e6f4e623960f93838db21432089
valerienierenberg/holbertonschool-higher_level_programming
/0x05-python-exceptions/0-safe_print_list.py
744
4.125
4
#!/usr/bin/python3 def safe_print_list(my_list=[], x=0): a = 0 for y in range(x): try: print("{}".format(my_list[y]), end="") a += 1 except IndexError: break print("") return(a) # --gives correct output-- # def safe_print_list(my_list=[], x=0): # ...
true
bc9d2fe1398ef572e5f23841976978c19a6e21a6
YusefQuinlan/PythonTutorial
/Intermediate/2.5 pandas/2.5.5 pandas_Column_Edit_Make_DataFrame.py
2,440
4.5
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 19 17:11:39 2021 @author: Yusef Quinlan """ import pandas as pd """ Making a dictionary to be used to make a pandas DataFrame with. The keys are the columns, and the values for the keys (which must be lists) are what are used to make the DataFrame. """ dicti...
true
881419c45d178dec904578bbe59fac4ce828b4b7
YusefQuinlan/PythonTutorial
/Basics/1.16.3_Basic_NestedLoops_Practice.py
2,147
4.40625
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 20 15:10:45 2019 @author: Yusef Quinlan """ # A nested loop is a loop within a loop # there may be more than one loop within a loop, and there may be loops within loops # within loops etc etc # Any type of loop can be put into any other type of loop #as in the example ...
true
05111398ed789569ad5d10cfbf537cb53a069ed5
YusefQuinlan/PythonTutorial
/Intermediate/2.1 Some Useful-Inbuilt/2.1.8_Intermediate_Generators.py
1,879
4.21875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 29 15:38:07 2020 @author: Yusef Quinlan """ # What is a generator? # A generator is an iterable object, that can be iterated over # but it is not an object that contains all the iterable instances of whatever # it iterates, at once. # return will return the first valid v...
true
b51c8430b39bdf7dce428ccaaed9ddf5ef1c9505
mahfoos/Learning-Python
/Variable/variableName.py
1,180
4.28125
4
# Variable Names # A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). # Rules for Python variables: # A variable name must start with a letter or the underscore character # A variable name cannot start with a number # A variable name can only contain alpha-numeric ...
true
ae3689da43f974bd1948f7336e10162aea14cae6
CharlesBasham132/com404
/second-attempt-at-tasks/1-basics/2-input/2-ascii-robot/bot.py
523
4.125
4
#ask the user what text character they would wish to be the robots eyes print("enter character symbol for eyes") eyes = input() print("#########") print("# #") print("# ",eyes,eyes, " #") print("# ----- #") print("#########") #bellow is another way of formatting a face with the use of + instead of , #plusses + d...
true
e2e0488734dab283f61b4114adf692f8d041209e
abhisheklomsh/Sabudh
/prime_checker.py
700
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 9 10:51:47 2019 @author: abhisheklomsh Here we ask user to enter a number and we return whether the number is prime or not """ def prime_check(input_num): flag=1 if input_num ==1: print(str(input_num)+" is not a prime number") else: ...
true
17c67730fe1f49ff945cdd21cf9b814073341e32
ThienBNguyen/simple-python-game
/main.py
1,447
4.21875
4
import random def string_combine(aug): intro_text = 'subscribe to ' return intro_text + aug # def random_number_game(): # random_number = random.randint(1, 100) # user_number = int(input('please guess a number that match with the computer')) # while user_number == random_number: # if ran...
true
c8492b2fc31a4301356bdfd95ead7a6a97fcc010
am93596/IntroToPython
/functions/calculator.py
1,180
4.21875
4
def add(num1, num2): print("calculating addition:") return num1 + num2 def subtract(num1, num2): print("calculating subtraction:") return num1 - num2 def multiply(num1, num2): print("calculating multiplication:") return num1 * num2 def divide(num1, num2): print("calculating division:"...
true
a60f3c97b90c57d099e0aa1ade1650163cf8dd8d
adam-m-mcelhinney/MCS507HW
/MCS 507 Homework 2/09_L7_E2_path_length.py
1,656
4.46875
4
""" MCS H2, L7 E2 Compute the length of a path in the plane given by a list of coordinates (as tuples), see Exercise 3.4. Exercise 3.4. Compute the length of a path. Some object is moving along a path in the plane. At n points of time we have recorded the corresponding (x, y) positions of the object: (x0, y0)...
true
bf8675caa23965c36945c51056f3f34ec76ce1bc
anthonyharrison/Coderdojo
/Python/Virtual Dojo 3/bullsandcows.py
2,390
4.15625
4
# A version of the classic Bulls and Cows game # import random # Key constants MAX_GUESS = 10 SIZE = 4 MIN_NUM = 0 MAX_NUM = 5 def generate_code(): secret = [] for i in range(SIZE): # Generate a random digit code = random.randint(MIN_NUM,MAX_NUM) secret.append(str(code)) return sec...
true
044c1fcd7f2bec2a0b74d90e2dcf4583a2ed876c
mayaugusto7/learn-python
/basic/functions_anonymous.py
391
4.21875
4
# funcoes anonimas no python não tem o def # Para criar funções anonimas devemos usar a expressão lambda sum = lambda arg1, arg2: arg1 + arg2 print("Value of total: ", sum(10, 20)) print("Value of total: ", sum(20, 20)) def sum(arg1, arg2): total = arg1 + arg2 print ("Inside the function : ", total) return t...
false
6bc2dbc19391e9ef4e37a9ce96a4f5a7cdb93654
skfreego/Python-Data-Types
/list.py
1,755
4.53125
5
""" Task:-Consider a list (list = []). You can perform the following commands: . insert i e: Insert integer e at position i . print: Print the list. . remove e: Delete the first occurrence of integer e . append e: Insert integer e at the end of the list. . sort: Sort the list. . pop: Pop the last element from th...
true
80612a7405e7f0609f457a2263715a5077eaa327
buy/leetcode
/python/94.binary_tree_inorder_traversal.py
1,313
4.21875
4
# Given a binary tree, return the inorder traversal of its nodes' values. # For example: # Given binary tree {1,#,2,3}, # 1 # \ # 2 # / # 3 # return [1,3,2]. # Note: Recursive solution is trivial, could you do it iteratively? # confused what "{1,#,2,3}" means? > read more on how binary tree is ser...
true
e8689f10872987e7c74263e68b95788dce732f56
buy/leetcode
/python/145.binary_tree_postorder_traversal.py
983
4.125
4
# Given a binary tree, return the postorder traversal of its nodes' values. # For example: # Given binary tree {1,#,2,3}, # 1 # \ # 2 # / # 3 # return [3,2,1]. # Note: Recursive solution is trivial, could you do it iteratively? # Definition for a binary tree node. # class TreeNode: # def __ini...
true
06dc7790c9206822c66d72f4185f16c0127e377d
AlexandrKnyaz/Python_lessons_basic
/lesson02/home_work/hw02_easy.py
1,716
4.125
4
# Задача-1: # Дан список фруктов. # Напишите программу, выводящую фрукты в виде нумерованного списка, # выровненного по правой стороне. # Пример: # Дано: ["яблоко", "банан", "киви", "арбуз"] # Вывод: # 1. яблоко # 2. банан # 3. киви # 4. арбуз # Подсказка: воспользоваться методом .format() fruits_list = ['Абрико...
false
8f5d33183271397e07fd1b45717bc15dc24ba80f
nayanika2304/DataStructuresPractice
/Practise_graphs_trees/random_node.py
2,420
4.21875
4
''' You are implementing a binary tree class from scratch which, in addition to insert, find, and delete, has a method getRandomNode() which returns a random node from the tree. All nodes should be equally likely to be chosen. Design and implement an algorithm for getRandomNode, and explain how you would implement the ...
true
4774e23e3a65b54ff0e96736d0d491a965c6a1b4
nayanika2304/DataStructuresPractice
/Practise_linked_list/remove_a_node_only pointer_ref.py
1,885
4.375
4
''' Implement an algorithm to delete a node in the middle (i.e., any node but the first and last node, not necessarily the exact middle) of a singly linked list, given only access to that node. iterating through it is a problem as head is unkniwn faster approach is to copy the data of next node in current node and de...
true
c173928913363f978662919341813f5ae867bf95
fanyichen/assignment6
/lt911/assignment6.py
1,816
4.28125
4
# This program is to manage the user-input intervals. First have a list of intervals entered, # then by taking new input interval to merge intervals. # input of valid intervals must start with [,(, and end with ),] in order for correct output import re import sys from interval import interval from interval_functions i...
true
29816333038bf4bf14460d8436d1b75243849537
kevgleeson78/Emerging-Technonlgies
/2dPlot.py
867
4.15625
4
import matplotlib.pyplot as plt # numpy is used fo scientific functionality import numpy as np # matplotlib plots points in a line by default # the first list is the y axis add another list for the x axis # To remove a connecting line from the plot the third arg is # shorthand for create blue dots # numpy range x = n...
true
f17209f360bf135a9d3a6da02159071828ca0087
hamishscott1/Number_Guessing
/HScott_DIT_v2.py
1,120
4.3125
4
# Title: Guess My Number v2 # Date: 01/04/2021 # Author: Hamish Scott # Version: 2 """ The purpose of this code is to get the user to guess a preset number. The code will tell them if the number is too high or too low and will tell them if it is correct.""" # Setting up variables import random int_guess = 0 ...
true
fd4b084531d68577c6ba3c066575fba247aa6daa
summen201424/pyexercise-1
/venv/totalexercise/algorithm.py
618
4.28125
4
#sqrt_newton # import math # from math import sqrt # num=float(input("请输入数字:")) # def sqrt_newton(num): # x=sqrt(num) # y=num/2.0 # count=1 # while abs(y-x)>0.0000001: # print(count,y) # count+=1 # y=((y*1.0)+(1.0*num)/y)/2.000 # return y # print(sqrt_newton(num)) # print(sqr...
false
e995bf856a613b5f1978bee619ad0aaab4be80ed
saibeach/asymptotic-notation-
/v1.py
1,529
4.21875
4
from linkedlist import LinkedList def find_max(linked_list): current = linked_list.get_head_node() maximum = current.get_value() while current.get_next_node(): current = current.get_next_node() val = current.get_value() if val > maximum: maximum = val return maximum #Fill in Func...
true
02a7ab067157be02467fd544a87a26fb7d792d7b
mayurimhetre/Python-Basics
/calculator.py
735
4.25
4
###### Python calculator Program ############################## ### taking two numbers as input from user and option print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") choose = int(input("Enter your option : 1,2,3,4 : ")) a = int(input("Enter First Number :")) b = int(...
true
523f44dfb04138b92c56d603b07f8e4c3a9f75b3
tanmaya191/Mini_Project_OOP_Python_99005739
/6_OOP_Python_Solutions/set 1/arithmetic_operations.py
561
4.1875
4
"""arithmetic operation""" print("Enter operator") print("1 for addition") print("2 for subtraction") print("3 for multiplication") print("4 for division") op = int(input()) print("Enter 1st number") num1 = int(input()) print("Enter 2nd number") num2 = int(input()) if op == 1: print(num1, "+", num2, "...
false
ee6a4589b17ed32172b53dca9e9a054b71ebea60
tanmaya191/Mini_Project_OOP_Python_99005739
/6_OOP_Python_Solutions/set 1/vowel_check.py
488
4.21875
4
"""vowel or consonant""" print("Enter a character") char = input() if len(char) == 1: if char == "a" or char == "e" or char == "i" or char == "o" or char == "u": print(char, "is a vowel") elif char == "A" or char == "E" or char == "I" or char == "O" or char == "U": print(char, "is a vow...
false
2f563e53a9d4c0bbf719259df06fb0003ac205bc
sweetise/CondaProject
/weight_conversion.py
433
4.28125
4
weight = float(input(("Enter your Weight: "))) unit = input(("Is this in 'lb' or 'kg'?")) convert_kg_to_lb = round(weight * 2.2) convert_lb_to_kg = round(weight / 2.2) if unit == "kg": print(f" Your weight in lbs is: {convert_kg_to_lb}") elif unit == "lb": print(f" Your weight in kg is: {convert_lb_to_kg}") ...
true
978e2b9b55998133ab90b0868126f32367f29d60
samcheck/Tutorials
/ATBSWP/Chap3/collatz.py
348
4.125
4
def collatz(number): if number == 1: return elif number % 2 == 0: print(number // 2) collatz(number // 2) else: print(3 * number + 1) collatz(3 * number + 1) print('Input an interger: ') number = input() try: number = int(number) collatz(number) except ValueError: print('Error: please enter an inter...
false
f6b8082233895e0a78275d13d2ec29c14bc088cf
Ethan2957/p03.1
/multiple_count.py
822
4.1875
4
""" Problem: The function mult_count takes an integer n. It should count the number of multiples of 5, 7 and 11 between 1 and n (including n). Numbers such as 35 (a multiple of 5 and 7) should only be counted once. e.g. mult_count(20) = 7 (5, 10, 15, 20; 7, 14; 11) Tests: >>> mult_count(20)...
true
f7f7a5f023f89594db74f69a1a2c3f5f34dfc881
gpallavi9790/PythonPrograms
/StringPrograms/5.SymmetricalString.py
241
4.25
4
#Prgram to check for symmetrical string mystr=input("Enter a string:") n=len(mystr) mid=n//2 firsthalf=mystr[0:mid] secondhalf=mystr[mid:n] if(firsthalf==secondhalf): print("Symmetrical String") else: print("Not a Symmetrical String")
true
57740b0f61740553b9963170e2dddc57c7b9858b
gpallavi9790/PythonPrograms
/StringPrograms/7.RemoveithCharacterFromString.py
400
4.25
4
#Prgram to remove i'th character from a string mystr="Pallavi Gupta" # Removing char at pos 3 # using replace, removes all occurences newstr = mystr.replace('l', '') print ("The string after removal of i'th character (all occurences): " + newstr) # Removing 1st occurrence of # if we wish to remove it. newstr = myst...
true
a8bdf0c4d3abbd4582c4149436a2abed7d48369b
Jessicammelo/cursoPython
/default.py
951
4.15625
4
""" Modulos colection - Default Dict https://docs.python.org/3/library/collections.html#collections.defaultdict # Recap Dicionarios dicionario = {'curso': 'Programação em Python: essencial' print(dicionario) print(dicionario['curso']) print(dicionario['outro']) #???KeyError Default Dict -> Ao criar um dicionario uti...
false
ac582b05af10382ea245887fae34f853cc48b3fe
Jessicammelo/cursoPython
/tipo_String.py
684
4.375
4
""" Tipo String Sempre que estiver entre aspas simples ou duplas ('4.2','2','jessica') """ """ nome = 'Jessica' print(nome) print(type(nome)) nome = "Gina's bar" print(nome) print(type(nome)) nome = 'jessica' print(nome.upper())#tudo maicusculo print(nome.lower())# tudo minusculo print(nome.split())#transfoma em uma l...
false
84dbde9af21ff55e79e696e14d53754929cdf550
Jessicammelo/cursoPython
/lambdas.py
1,826
4.90625
5
""" Utilizando Lambdas Conhecidas por expressões Lambdas, ou simplesmente Lambdas, são funções sem nome, ou seja, funções anonimas. #Função em Paython: def funcao(x): return 3 * x + 1 print(funcao(4)) print(funcao(7)) #Expressão Lambda lambda x: #Função em Paython: def funcao(x): return 3 * x + 1 print(fu...
false
f47f69de9366760f05fda6dd697ce2301ad38e01
johnhjernestam/John_Hjernestam_TE19C
/introkod_syntax/Annat/exclusiveclub.py
453
4.125
4
age = int(input('How old are you? ')) if age < 18: print('You are too young.') if age > 30: print('You are too old.') if age >= 18: answer = input('Have you had anything to drink today or taken something? Yes or no: ') if answer == "no": print('You got to be turned up') else: prin...
true
396d8403fb82b6c4b6f698b5998d0b57f89071fb
felhix/cours-python
/semaine-1/07-boolean.py
2,963
4.1875
4
#! python3 # 07-boolean.py - quelques booléens, opérateurs, et comparateurs # Voici quelques comparateurs print(1 == 1) #=> True, car 1 est égal à 1 print(1 == "1") #=> False, car 1 est un integer, et "1" est un string print("Hello" == "Bonjour") #=> False, car ces 2 strings sont différents print("1" == "...
false
230e1d2846f4b608c3f541d5d089655ca97f9efe
kmrsimkhada/Python_Basics
/loop/while_with_endingCriteria.py
968
4.25
4
#While-structure with ending criteria ''' The second exercise tries to elaborates on the first task. The idea is to create an iteration where the user is able to define when the loop ends by testing the input which the user gave. Create a program which, for every loop, prompts the user for input, and then prints it...
true
e1dca0956dc0547a3090e508787df989034b0eaf
kmrsimkhada/Python_Basics
/type_conversion.py
702
4.5
4
#Type Conversions ''' In this exercise the aim is to try out different datatypes. Start by defining two variables, and assign the first variable the float value 10.6411. The second variable gets a string "Stringline!" as a value. Convert the first variable to an integer, and multiply the variable with the string by...
true
26a5ce912495c032939b4b912868374a6d8f83c7
kmrsimkhada/Python_Basics
/lists/using_the_list.py
2,397
4.84375
5
#Using the list ''' n the second exercise the idea is to create a small grocery shopping list with the list datastructure. In short, create a program that allows the user to (1) add products to the list, (2) remove items and (3) print the list and quit. If the user adds something to the list, the program asks "What...
true
8a49bad35b7b1877abf081adc13ed6b9b63d0de8
suhanapradhan/IW-Python
/functions/6.py
319
4.28125
4
string = input("enter anything consisting of uppercase and lowercase") def count_case(string): x = 0 y = 0 for i in string: if i.isupper(): x += 1 else: y += 1 print('Upper case count: %s' % str(x)) print('Lower case count: %s' % str(y)) count_case(string)
true
35a98e4bf5b1abcd7d6dd9c6ff64d53d07f8788e
BinyaminCohen/MoreCodeQuestions
/ex2.py
2,795
4.1875
4
def sum_list(items): """returns the sum of items in a list. Assumes the list contains numeric values. An empty list returns 0""" sum = 0 if not items: # this is one way to check if list is empty we have more like if items is None or if items is [] return 0 else: for x in items: ...
true
a9cb243ebc4a52d46e6d214a17e011c293cde3ff
s16323/MyPythonTutorial1
/EnumerateFormatBreak.py
1,464
4.34375
4
fruits = ["apple", "orange", "pear", "banana", "apple"] for i, fruit in enumerate(fruits): print(i, fruit) print("--------------Enumerate---------------") # Enumerate - adds counter to an iterable and returns it # reach 3 fruit and omit the rest using 'enumerate' (iterator) for i, fruit in enumerate(fruits): ...
true
d51b4e8230def2eac49d1505656a5f943d162efc
ricardofelixmont/Udacity-Fundamentos-IA-ML
/zip-function/zip.py
556
4.46875
4
# ZIP FUNCTION # zip é um iterador built-in Python. Passamos iteraveis e ele os une em uma estrutura só nomes = ['Lucas', 'Ewerton', 'Rafael'] idades = [25, 30, 24] nomes_idades = zip(nomes, idades) print(nomes_idades) # Mostra o objeto do tipo zip() #como zip() é um iterador, precisamos iterar sobre ele para mostrar ...
false
4cb726601b5dda4443b8fe3b388cbd6f598013a8
varnagysz/Automate-the-Boring-Stuff-with-Python
/Chapter_05-Dictionaries_and_Structuring_Data/list_to_dictionary_function_for_fantasy_game_inventory.py
1,640
4.21875
4
'''Imagine that a vanquished dragon’s loot is represented as a list of strings like this: dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby'] Write a function named addToInventory(inventory, addedItems), where the inventory parameter is a dictionary representing the player’s inventory (like in...
true
71db3ebdbd3bbcac09c385947f6b327f9d7c3d73
harshit-sh/python_games
/matq.py
743
4.25
4
# matq.py # Multiplication Quiz program # Created by : Harshit Sharma from random import randint print "Welcome to Maths Multiplication Quiz!" print "--------------------------------" ques = int(raw_input("How many questions do you wish to answer? ")) print "--------------------------------" limit = int(raw_input("Ti...
true
05c461070ef9f5a7cee7b53541d22be836b65450
crisjsg/Programacion-Estructurada
/Ejercicio10 version 2.py
1,169
4.125
4
#10. Modifica el programa anterior para que en vez de mostrar un mensaje genérico en el caso #de que alguno o los dos números sean negativos, escriba una salida diferenciada para cada #una de las situaciones que se puedan producir, utilizando los siguientes mensajes: #a. No se calcula la suma porque el primer número es...
false
dc7761a6601b2d29f7ef50966814a7a4201f579f
josecaromuentes2019/CursoPython
/manehoExcepciones2.py
429
4.1875
4
import math print('estre programa calcula la Raiz cuadrada de un numero') def raiz(num): if num<0: raise ValueError('No es posible calcular Raices negativas') else: return math.sqrt(num) while True: try: numero = int(input('Digita un numero: ')) print(raiz(numero)) exc...
false
cdaa647a527a20cf851f65ce4df554a3185b920a
annkon22/ex_book-chapter3
/linked_list_queue(ex20).py
1,835
4.1875
4
# Implement a stack using a linked list class Node: def __init__(self, init_data): self.data = init_data self.next = None def get_data(self): return self.data def get_next(self): return self.next def set_data(self, new_data): self.data = new_data...
true
32662139be2cd03f427faaa5a1255fb8fd24b1cd
annkon22/ex_book-chapter3
/queue_reverse(ex5).py
457
4.25
4
#Implement the Queue ADT, using a list such that the rear of the queue #is at he end of the list class Queue(): def __init__(self): self.items = [] def enqueue(self, item): self.items.append(item) def dequeue(self): return self.items.pop(0) my_q = Queu...
true
061acf150e2bea1ec8acbc7ce8d2a4550c408e0e
ChristianDzul/ChristianDzul
/Exam_Evaluation/Question_06.py
506
4.15625
4
##Start## print ("Welcome to the area calculator") ##Variables## length = 0 width = 0 area_square = 0 area_rectangle = 0 ##Getting the values## length = int( input("Insert a value for the lenght \n")) width = int( input("Insert a value for the width \n")) ##Process## if (length == width): area_square = length * wi...
true
5aa2d245d628c79a70360f2c114a4cef537a65e4
dharm0us/prob_pro
/iterate_like_a_native.py
577
4.40625
4
#iterate like a native # https://www.youtube.com/watch?v=EnSu9hHGq5o myList = ["The", "earth", "revolves", "around", "sun"] for v in myList: #Look ma, no integers print(v) #iterator is reponsible for producing the stream #for string it's chars for c in 'Hello': print(c) d = {'a' : 1, 'b' : 2} fo...
false
59890f09a10730dc76f570bd8d186c3cb9364f93
konovalovatanya26/prog_Konovalova
/turtle_new/упр 10.py
337
4.25
4
import turtle t = turtle.Turtle() t.shape('turtle') Number = 100 Step = 5 def circle(Number, Step): for step in range(Number): t.forward(Step) t.left(360/Number) for step in range(Number): t.forward(Step) t.right(360/Number) for _ in range(3): circle(Number, Step...
false