blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1c551d5fdea25beebc8b9c566d17fc4c23a1c3b1
jimibarra/cn_python_programming
/04_conditionals_loops/04_10_squares.py
237
4.34375
4
''' Write a script that prints out all the squares of numbers from 1- 50 Use a for loop that demonstrates the use of the range function. ''' for num in range(1,51): square = num ** 2 print(f'The square of {num} is {square} ')
true
6bfee747928fa37a7cbcf03d73fd118133f6c930
jimibarra/cn_python_programming
/01_python_fundamentals/01_07_area_perimeter.py
277
4.1875
4
''' Write the necessary code to display the area and perimeter of a rectangle that has a width of 2.4 and a height of 6.4. ''' area = 6.4 * 2.4 perimeter = 2 * (6.4 + 2.4) print(f"The area of the rectangle is {area}") print(f"The perimeter of the rectangle is {perimeter}")
true
d0e9358885e01dee964f826d9302180cb7d3ab90
AmyShackles/LearnPython3TheHardWay
/ex7.py
1,396
4.28125
4
# prints the string 'Mary had a little lamb' print("Mary had a little lamb.") # prints 'Its fleece was white as snow', the {} indicated replacement and 'snow' was the replacement text print("Its fleece was white as {}.".format('snow')) # prints 'And everywhere that Mary went' print("And everywhere that Mary went.") # p...
true
7d9600f2d3b44ba69232a20d4586c61dc48fb8b6
shkyler/gmit-cta-problems
/G00364753/Q2d.py
957
4.375
4
# Patrick Moore 2019-03-05 # This is a script to create a function that finds the max value in a list # using an iterative approach, as directed by Question 2(d) of the # Computational Thinking with Algorithms problem sheet # define a function that takes a list as an argument def max_iter(data): # set the maximum v...
true
9d6e2e6e6d8c55965fe4206b140c78b2ee145772
michaelobr/gamble
/Gamble.py
1,667
4.3125
4
#Short introduction of the purpose of this program print("This short little program will help determine the probability of profitability and ROI from playing 50/50 raffles.") #The number of tickets the user will purchase num_user_tickets = int(input("How many tickets will you purchase? ")) #The total amount of...
true
bca2eb0df154973cc48900b3493b812846429288
Izabela17/Programming
/max_int.py
727
4.25
4
"""If users enters x number of positive integers. Program goes through those integers and finds the maximum positive and updates the code. If a negative integer is inputed the progam stops the execution """ """ num_int = int(input("Input a number: ")) # Do not change this line max_int = num_int while num_int >= 0: ...
true
62f9cca5ef39e633b5a20ffd6afb27772a5291fc
NikolaosPanagiotopoulos/python-examples-1
/Addition.py
225
4.21875
4
#this program adds two numbers num1=input('Enter first number: ') num2=input('Enter second number: ') #Add two numbers sum=float(num1)+float(num2) #display the sum print('The sum of {0} and {1} is {2}'.format(num1,num2,sum))
true
14765ce398a35e4730122fb867cd45d386d19c7f
allysonvasquez/Python-Projects
/2-Automating Tasks/PhoneAndEmail.py
852
4.15625
4
# author: Allyson Vasquez # version: May.15.2020 # Practice Exercises: Regular Expressions # https://www.w3resource.com/python-exercises/re/index.php import re # TODO: check that a string contains only a certain set of characters(a-z, A-Z and 0-9) charRegex = re.compile(r'\d') test_str = str('My name is Allyson and ...
true
a9842c9896f227bb707b36906ec06f6fe93c0fc2
talrab/python_excercises
/fibonacci.py
707
4.3125
4
run_loop = True num_elements = int(input("Please enter the number of elements: ")) if num_elements < 0: run_loop = False while (run_loop): answer = [] for x in range(num_elements): print( "X=" + str(x)) if (x+1==1): answer.append(1) elif (x+1==2): answer.ap...
true
51a4bcb49223b93ebc60b0cce21f4cbde2c5b8da
yankwong/python_quiz_3
/question_1.py
506
4.25
4
# create a list of number from 1 to 10 one_to_ten = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # using list comprehension, generate a new list with only even numbers even_from_one_to_ten = [num for num in one_to_ten if (num % 2 == 0)] # using list comprehension, generate a new list with only odd numbers odd_from_one_to_ten = [num...
true
421ce0dabf326248c65348bd3506e5596570730a
pnthairu/module7_Arrays
/sort_and_search_array.py
2,039
4.3125
4
from array import array as arr from filecmp import cmp # Start Program """ Program: sort_and_Search_array.py Author: Paul Thairu Last date modified: 06/23/2020 You can make a new files test_sort_and_search_array.py and sort_and_search_array.py. In the appropriate directories. For this assignment, you can...
true
0d7b86cad05e0a7391f3eb150175446a58f20c6b
ratneshgujarathi/Encryptor-GUI-
/encrypt_try.py
1,299
4.4375
4
#ceasor cipher method encryption #this is trial module to easy encrypyt the message #c=(x-n)%26 we are ging to follow this equation for encrytion #c is encryted text x is the char n is the shifting key that should be in numbers % is modulus 26 is total alphabets #function for encrytion def encryption(string...
true
a7ca5c75d43d8fbdb082f89d549b1db9959e101a
praveendareddy21/ProjectEulerSolutions
/src/project_euler/problem4/problem4.py
2,395
4.21875
4
''' A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Find the largest palindrome made from the product of two 3-digit numbers. Created on Feb 18, 2012 @author: aparkin ''' from project_euler.timing import timeruns, format...
true
eea1a67f02c852cd6ca7b2997c9bb7ffdff4e7ba
coomanky/game-v1
/main.py
2,848
4.3125
4
#user information print("hello and welcome to (game v2) , in this game you will be answering a series of questions to help inprove your knowledge of global warming ") print (" ") name = input ("What is your name? ") print ("Hello " + name) print(" ") # tutorial def yes_no(question): valid = False while no...
true
52dad76686a481f7218cc435f240c3086897bc37
DesignisOrion/DIO-Tkinter-Notes
/grid.py
467
4.40625
4
from tkinter import * root = Tk() # Creating Labels label1 = Label(root, text="Firstname") label2 = Label(root, text="Lastname") # Creating Text fields entry1 = Entry(root) entry2 = Entry(root) # Arrange in the grid format label1.grid(row=0, column=0) label2.grid(row=1, column=0) # Want to have...
true
39d2367ba2910304e1e50724783ffbd3ece60b0f
divyakelaskar/Guess-the-number
/Guess the number .py
1,862
4.25
4
import random while True: print("\nN U M B E R G U E S S I N G G A M E") print("\nYou have 10 chances to guess the number.") # randint function to generate the random number between 1 to 100 number = random.randint(1, 100) """ number of chances to be given to the user t...
true
356ad2bf5d602c408dd3c44c2e475c5a8379da0a
emorycs130r/Spring-2021
/class_8/lists_intro.py
454
4.25
4
fruits = ['Apple', 'Strawberry', 'Orange'] # Index = Position - 1 # print(fruits[3]) print(type(fruits)) vegetables = [] print(f"Before adding value: {vegetables}") vegetables.append('Brocolli') print(f"After adding value: {vegetables}") # print(vegetables) fruits.append('Kiwi') print(f"Fruits are: {fruits}") f...
true
9af404e0faeff67ace5589e05ecb3fdc9c680104
emorycs130r/Spring-2021
/class_6/temperature_conversion.py
662
4.40625
4
''' Step 1: Write 2 functions that converts celsius to farenheit, celsius to kelvin. Step 2: Get an input from user for the celsius value, and f/k for the value to convert it to. Step 3: Based on the input call the right function. ''' def c_to_f(temp): return (9/5) * temp + 32 def c_to_k(temp): return te...
true
90653fca5369a36f393db2f49b30322080d0a944
emorycs130r/Spring-2021
/class_11/pop_quiz_1.py
458
4.1875
4
''' Create a dictionary from the following list of students with grade: bob - A alice - B+ luke - B eric - C Get input of name from user using the "input()" and use it to display grade. If the name isn't present, display "Student not found" ''' def working_numbers_set(input_list): return list(dict.fromkeys(in...
true
c0cb66d637c94a99eb4255c5991a2fcc0aae122c
vparjunmohan/Python
/Basics-Part-II/program30.py
513
4.125
4
'''Write a Python program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure. Note: A palindrome is a word, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar.''' def rev_number(n): while ...
true
6da942919c4afcaf3e6a219f42c642b4a34761c3
vparjunmohan/Python
/Basics-Part-I/program19.py
334
4.40625
4
'Write a Python program to get a new string from a given string where "Is" has been added to the front. If the given string already begins with "Is" then return the string unchanged.' str = input('Enter a string ') if str[:2] != 'Is': newstr = 'Is' + str print('New string is',newstr) else: print('String un...
true
a73d72582cc340a3c517b4f5ecde7a396175b7cc
vparjunmohan/Python
/Basics-Part-I/program150.py
241
4.1875
4
'Python Program for sum of squares of first n natural numbers.' def squaresum() : sm = 0 for i in range(1, n+1): sm = sm + (i * i) return sm n = int(input('Enter a number ')) print('Sum of squares is',squaresum())
true
55e157e4a5c65734f28ef1a72c3c987732ca8ebc
vparjunmohan/Python
/Basics-Part-I/program7.py
375
4.46875
4
''' Write a Python program to accept a filename from the user and print the extension of that. Sample filename : abc.java Output : java''' filename = input('Enter file name: ') extension = filename.split('.') #split() method returns a list of strings after breaking the given string by the specified separator. print(...
true
b07684fbb0a42f18683a21a8fc4d08abe25c5712
vparjunmohan/Python
/String/program1.py
215
4.15625
4
'Write a Python program to calculate the length of a string.' def strlen(string): length = len(string) print('Length of {} is {}'.format(string, length)) string = input('Enter a string ') strlen(string)
true
b206558992aed8a4b4711787dff8f4933ad1d2ec
vparjunmohan/Python
/Basics-Part-II/program45.py
671
4.15625
4
'''Write a Python program to that reads a date (from 2016/1/1 to 2016/12/31) and prints the day of the date. Jan. 1, 2016, is Friday. Note that 2016 is a leap year. Input: Two integers m and d separated by a single space in a line, m ,d represent the month and the day. Input month and date (separated by a single space)...
true
97cc5bf2f5ebc0790d157a8ad00a2006aa53ca64
AbhishekKunwar17/pythonexamples
/11 if_elif_else condition/unsolved02.py
236
4.21875
4
Write Python code that asks a user how many pizza slices they want. The pizzeria charges Rs 123.00 a slice if user order even number of slices, price per slice is Rs 120.00 Print the total price depending on how many slices user orders.
true
1ac7a9e8d9ee10eeb8e571d3dd6e5698356a1a47
NitinSingh2020/Computational-Data-Science
/week3/fingerExc3.py
1,503
4.28125
4
def stdDevOfLengths(L): """ L: a list of strings returns: float, the standard deviation of the lengths of the strings, or NaN if L is empty. """ if len(L) == 0: return float('NaN') stdDev = 0 avgL = 0 lenList = [len(string) for string in L] for a in lenList: av...
true
80d674fa13606ccecb4943feb34ea9878cf45cca
AutumnColeman/python_basics
/python-strings/caesar_cipher.py
688
4.5625
5
#Given a string, print the Caesar Cipher (or ROT13) of that string. Convert ! to ? and visa versa. string = raw_input("Please give a string to convert: ").lower() cipher_list = "nopqrstuvwxyzabcdefghijklm" alpha_list = "abcdefghijklmnopqrstuvwxyz" new_string = "" for letter in string: if letter == "m": ne...
true
3bac6dcded9f050f8c3d8aff2e2f9f5083310d00
nishesh19/CTCI
/educative/rotateLinkedList.py
1,146
4.1875
4
from __future__ import print_function class Node: def __init__(self, value, next=None): self.value = value self.next = next def print_list(self): temp = self while temp is not None: print(temp.value, end=" ") temp = temp.next print() def rotate(head, rotations): # TODO: Write ...
true
9c091e4e3c4090e276eaad3b8ae15ea5e8fb6654
nishesh19/CTCI
/Arrays and Strings/Urlify.py
721
4.28125
4
# Write a method to replace all spaces in a string with '%20: You may assume that the string # has sufficient space at the end to hold the additional characters, and that you are given the "true" # length of the string. (Note: If implementing in Java, please use a character array so that you can # perform this operatio...
true
6e58c3d2c52524ae138b55a4d4dbaf57512d363b
nishesh19/CTCI
/LinkedList/deletemiddlenode.py
1,892
4.125
4
''' 2.3 Delete Middle Node: 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. EXAMPLE Input: the node c from the linked list a->b->c->d->e->f Result: nothing is returned, but the n...
true
e94f1f07150945766804cb28a1e831429bc880de
L0GI0/Python
/Codes/functions_with_lists.py
919
4.25
4
#!/usr/bin/python3 lucky_numbers = [32, 8, 15, 16, 23, 42] friends = ["Kevin", "Karen", "Jim", "Oscar", "Tom"] print(friends) #append another lists at the end of a list friends.extend(lucky_numbers) print(friends) #adding indivitual elements at the end of given list friends.append("Creed") #adding individual elements...
true
e4434cfa2ff0b2b53664dd678bb0d6c9490e8e67
ibnahmadCoded/how_to_think_like_a_computer_scientist_Chapter_5
/palindrom_checker.py
248
4.21875
4
def is_palindrome(word): """Reverses word given as argument""" new_word = "" step = len(word) + 1 count = 1 while step - count != 0: new_word += word[count * -1] count += 1 return new_word == word
true
0ff0a238da2e48a751d66401f303090375a03ed1
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/14. ALGEBRA/ALGEBRA/StringManipulation.py
733
4.125
4
# https://www.youtube.com/watch?v=k9TUPpGqYTo&list=PL-osiE80TeTt2d9bfVyTiXJA-UTHn6WwU&index=2 # MATH FUNCTIONS in Python: https://docs.python.org/3.2/library/math.html #all key methods related to string manipulation message = "Hello World" print(message[0:3]) #including lower limit, but not including upper li...
true
fa987c3d6e2c2e1dba192beee4cb430cb9d265ce
DZGoldman/Google-Foo-Bar
/problem22.py
2,284
4.40625
4
# things that are true: """ Peculiar balance ================ Can we save them? Beta Rabbit is trying to break into a lab that contains the only known zombie cure - but there's an obstacle. The door will only open if a challenge is solved correctly. The future of the zombified rabbit population is at stake, so Beta ...
true
79a7c011b0ed82c278939fef81f60c4be7c88320
ashutoshfolane/PreCourse_1
/Exercise_2.py
2,030
4.34375
4
# Exercise_2 : Implement Stack using Linked List. class Node: # Node of a Linked List def __init__(self, data=0, next=None): self.data = data self.next = next class Stack: def __init__(self): # Head is Null by default self.head = None # Check if stack is empty def ...
true
6686ad3efa4b2036988196c50b0ab6f56c1903f7
debajyoti-ghosh/Learn_Python_The_Hard_Way
/Exe8.py
527
4.125
4
formatter = "{} {} {} {}" #format can take int as argument print(formatter.format(1, 2, 3, 4)) #.format can take string as argument print(formatter.format('one', 'two', 'three', 'four')) #.format can take boolean as argument print(formatter.format(True, False, True, False)) #.format can take variable as argument pr...
true
72301ec7c64df86bd3500a01d59262d2037866dd
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/10_EvenFactors/Demo.py
411
4.125
4
''' Write a program which accept number from user and print even factors of that number Input : 24 Output: 2 4 6 8 12 ''' def PrintEvenFactors(no): if(no<0): no = -no; for i in range(2,int(no/2)+1): if(no%i == 0): print("{} ".format(i),end = " "); def main(): no = int(...
true
408babae6f2e8b73ff56eaab659d421628c46cab
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/6 Problems on characters/2_CheckCapital/Demo.py
408
4.15625
4
''' Accept Character from user and check whether it is capital or not (A-Z). Input : F Output : TRUE Input : d Output : FALSE ''' def CheckCapital(ch): if((ch >= 'A') and (ch <= 'Z')): return True; else: return False; def main(): ch = input("Enter character:"); result = False...
true
c3c59745e3de6f17d1f404221048e9ce92aed2e3
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/22_DisplayTable/Demo.py
348
4.125
4
''' Write a program which accept number from user and display its table. Input : 2 Output : 2 4 6 8 10 12 14 16 18 20 ''' def PrintTable(num): if(num == 0): return; for i in range(1,11): print(num*i,end = " "); def main(): no = int(input("Enter number: ")); PrintTable(no); if __name_...
true
f31b354b73c09c00f6c797bbefd5e89017b93fe2
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/3_Print_Numbers_ReverseOrder/Demo.py
356
4.15625
4
#Accept a positive number from user and print numbers starting from that number till 1 def DisplayNumbers(no1): if(no1 < 0): print("Number is not positive"); else: for i in range(no1,0,-1): print(i); def main(): no1 = int(input("Enter number: ")); DisplayNumbers(no1); if...
true
c40119ce76ad55a08ee28a35e120940d643a2b49
DMSstudios/Introduction-to-python
/input.py
726
4.28125
4
#first_name = input('enter your first name: ') #second_name = input('enter your first name: ') #print( f'My name is:' first_name, second_name') #print(f"My name is,{first_name},{second_name}") #print("My name is {} {}" .format(first_name,second_name)) taskList = [23, "Jane", ["Lesson 23", 560, {"currency": "KES"}]...
true
7a1ae6018cb2d4f2eba4296c4a1e928de77f9089
Watersilver/cs50
/workspace/pset6/mario/less/mario.py
390
4.125
4
# Draws hash steps from left to right. Last step is double as wide as others from cs50 import get_int # Gets height by user height = -1 while height < 0 or height > 23: height = get_int("Height: ") # Prints half pyramid # Iterate rows for i in range(height): # Iterate collumns for j in range(height + 1):...
true
78cc32c777d2be27d9a280fd1b8478b02d2d78d2
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_03/005.2-pizza-order-nested-conditional.py
1,149
4.25
4
# 🚨 Don't change the code below 👇 print("Welcome to Python Pizza Deliveries!") size = input("What size pizza do you want? S, M, or L ") add_pepperoni = input("Do you want pepperoni? Y or N ") extra_cheese = input("Do you want extra cheese? Y or N ") # 🚨 Don't change the code above 👆 # Write your code below this li...
true
70c1be0fa061a29d265589d2fc8390769d219330
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_03/001.flow-if-else-conditional.py
277
4.28125
4
print("Can you the rollercoaster!?") height = int(input("What is your height in cm? ")) ''' #pseudo code if condition: do this else: do this ''' if height >= 125: print("Get on board and ridet he rollercoaster!!!") else: print("sorry not good enough kid!")
true
a8d94cc1c75e67f5f965b11f2ae74973f4147c6a
thakopian/100-DAYS-OF-PYTHON-PROJECT
/BEGIN/DAY_04/04.1-day-4-2-exercise-solution.py
1,817
4.3125
4
# https://repl.it/@thakopian/day-4-2-exercise#main.py # write a program which will select a random name from a list of names # name selected will pay for everyone's bill # cannot use choice() function # inputs for the names - Angela, Ben, Jenny, Michael, Chloe # import modules import random # set varialbles for in...
true
ae31c6cde30707ffccaf9bc0ed9eb70756f11514
xc13AK/python_sample
/week_v2.0.py
655
4.46875
4
#!/usr/bin/python3.4 #-*- coding:UTF-8 -*- import datetime #get the feature day from input year=int(input("enter the year:")) month=int(input("enter the month:")) day=int(input("enter the day:")) new=datetime.date(year,month,day) print("the day is %s-%s-%s"%(new.year,new.month,new.day)) weekday=int(new.weekday()) ...
true
3b105b43f202b9ca5f35fe8a65a3e5ce7ca4815c
RandomStudentA/cp1404_prac
/prac_04/lists_warmup.py
984
4.34375
4
numbers = [3, 1, 4, 1, 5, 9, 2] # What I thought it would print: 3 # What it printed: 3 print(numbers[0]) # What I thought it would print: 2 # What it printed: 2 print(numbers[-1]) # What I thought it would print: 1 # What it printed: 1 print(numbers[3]) # What I thought it would print: 2 # What it printed: [3, 1, ...
true
c67eee77631f9ef0d3a325eadeaab4039f3d8b1b
Systematiik/Python-The-Hard-Way
/ex15_1.py
429
4.21875
4
# reading textfiles by user input # open() opens file when in same directory # read() reads file from sys import argv # takes argument and puts under variable txt and function open, opens filename filename = input("Give me a text file to read (.txt): ") txt = open(filename) print(f"Here's your file {filenam...
true
ad8927d675907b661391b785026adaae2f33d3bd
Systematiik/Python-The-Hard-Way
/ex15.py
702
4.15625
4
#reading textfiles by passing args and user input #open() opens file when in same directory #read() reads file from sys import argv script, filename = argv #takes argument and puts under variable txt and function open, opens filename txt = open(filename) print(f"Here's your file {filename}: ") print(txt....
true
9c738875350bec148a14096eec94605fe89c99b0
vibhorsingh11/hackerrank-python
/04_Sets/02_SymmetricDifference.py
467
4.3125
4
# Given 2 sets of integers, M and N, print their symmetric difference in ascending order. The term symmetric difference indicates # those values that exist in either M or N but do not exist in both. # Enter your code here. Read input from STDIN. Print output to STDOUT a, b = (int(input()), input().split()) c, d = (int...
true
7276c10f1e342e0f6ca8170a299fc4471cd955a6
menasheep/CodingDojo
/Python/compare_arrays.py
1,165
4.15625
4
list_one = [1,2,5,6,2] list_two = [1,2,5,6,2] if list_one == list_two: print True print "These arrays are the same!" else: print False print "These arrays are different. Womp womp." # ***** list_one = [1,2,5,6,5] list_two = [1,2,5,6,5,3] if list_one == list_two: print True print "These array...
true
0dfe39b515dc391753d29b540d6af13abefd8269
yshshadow/Leetcode
/201-250/211.py
2,515
4.1875
4
# Design a data structure that supports the following two operations: # # void addWord(word) # bool search(word) # search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter. # # Example: # # addWord("bad") # addWord("dad") # addWord...
true
9137c399473cded62f26e36e512433eb4faaa00f
yshshadow/Leetcode
/1-50/48.py
1,614
4.125
4
# You are given an n x n 2D matrix representing an image. # # Rotate the image by 90 degrees (clockwise). # # Note: # # You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. # # Example 1: # # Given input matrix = # [ #...
true
b99592d95dcd3f2ce168808da0f08c2b5a83da5d
yshshadow/Leetcode
/51-100/94.py
1,376
4.125
4
# Given a binary tree, return the inorder traversal of its nodes' values. # # For example: # Given binary tree [1,null,2,3], # 1 # \ # 2 # / # 3 # return [1,3,2]. # # Note: Recursive solution is trivial, could you do it iteratively? # Definition for a binary tree node. class TreeNode(object): de...
true
c73e65896ce89c0ae540e9330a0214a0a5ba5a93
yshshadow/Leetcode
/51-100/88.py
1,074
4.21875
4
# Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. # # Note: # You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. The number of elements initialized in nums1 and nums2 are m and n respectively. # class...
true
310b99e9b68a2f81323c619977371e3638fc66b1
yshshadow/Leetcode
/300-/572.py
1,583
4.21875
4
# Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants. The tree s could also be considered as a subtree of itself. # # Example 1: # Given tree s: # # 3 ...
true
b1868ddb16d474b647edabf6aa4d8233a6d6fde4
yshshadow/Leetcode
/101-150/103.py
1,115
4.15625
4
# Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). # # For example: # Given binary tree [3,9,20,null,null,15,7], # 3 # / \ # 9 20 # / \ # 15 7 # return its zigzag level order trav...
true
584b822e45b7cb26ccb8e5cacc66cdb8eae399a4
yshshadow/Leetcode
/251-300/261.py
1,396
4.125
4
# Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. # # Example 1: # # Input: n = 5, and edges = [[0,1], [0,2], [0,3], [1,4]] # Output: true # Example 2: # # Input: n = 5, and edges = [[0,1], [1,2], [2,3...
true
ee7a31838dbba2216f509bfd2a764b6d825cbe4a
jamiezeminzhang/Leetcode_Python
/_Google/282_OO_Expression_Add_Operators.py
1,717
4.1875
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 22 10:57:57 2016 282. Expression Add Operators Total Accepted: 7924 Total Submissions: 33827 Difficulty: Hard Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so ...
true
f791001ef212e94de7adbf9df8df4812bc198622
jamiezeminzhang/Leetcode_Python
/others/073_Set_Matrix_Zeroes.py
1,863
4.21875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 28 10:55:49 2016 73. Set Matrix Zeroes Total Accepted: 69165 Total Submissions: 204537 Difficulty: Medium Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A strai...
true
442531f67bbcb62c307af612b26aa1d4d12d5bcf
gkalidas/Python
/practice/censor.py
658
4.3125
4
#Write a function called censor that takes two strings, text and word, as input. #It should return the text with the word you chose replaced with asterisks. #For example: #censor("this hack is wack hack", "hack") #should return: #"this **** is wack ****" #Assume your input strings won't contain punctuation or upper cas...
true
6ae7d434d182efebea2ee20dd122860f6bafde8b
TamaraJBabij/ReMiPy
/dictOps.py
550
4.15625
4
# -*- coding: utf-8 -*- # Applies a function to each value in a dict and returns a new dict with the results def mapDict(d, fn): return {k: fn(v) for k,v in d.items()} # Applies a function to each matching pair of values from 2 dicts def mapDicts(a, b, fn): return {k: fn(a[k], b[k]) for k in a.keys()} # Adds...
true
085f60472146523cbf36d36e75ba002cba379e10
nachoba/python
/introducing-python/003-py-filling.py
2,302
4.59375
5
# Chapter 3 : Py Filling: Lists, Tuples, Dictionaries, and Sets # ------------------------------------------------------------------------------ # Before started with Python's basic data types: booleans, integers, floats, and # strings. If you thinks of those as atoms, the data structures in this chapter # are like m...
true
209d380eeb75040a3911371e2b1297f210c66adb
berketuna/py_scripts
/reverse.py
253
4.40625
4
def reverse(text): rev_str = "" for i in range(len(text)): rev_str += text[-1-i] return rev_str while True: word = raw_input("Enter a word: ") if word == "exit": break reversed = reverse(word) print reversed
true
e1752393679416438c2c0c1f1d4015d3cc776f58
Jaredbartley123/Lab-4
/Lab 4.1.3.8.py
783
4.21875
4
#lab 3 def isYearLeap(year): if year < 1582: return False elif year % 400 == 0: return True elif year % 100 == 0: return False elif year % 4 == 0: return True else: return False def daysInMonth(year, month): leap = isYearLeap...
true
a8d29b3e2247885d8dd9648343f7b0ba27b83a4f
sathappan1989/Pythonlearning
/Empty.py
579
4.34375
4
#Starting From Empty #Print a statement that tells us what the last career you thought of was. #Create the list you ended up with in Working List, but this time start your file with an empty list and fill it up using append() statements. jobs=[] jobs.append('qa') jobs.append('dev') jobs.append('sm') jobs.append('...
true
f04c7247ba0b372240ef2bc0f118f340b0c9054b
angela-andrews/learning-python
/ex9.py
565
4.28125
4
# printing # Here's some new strange stuff, remember type it exactly. # print the string on the same line days = "Mon Tue Wed Thu Fri Sat Sun" # print Jan on the same line as and the remaining months on new lines months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" print("Here are the days: ", days) print("Here are t...
true
c73358f413572fdfa0e1f309c4d0e762e50c5ef2
angela-andrews/learning-python
/ex33.py
1,268
4.40625
4
# while loops i = 0 numbers = [] while i < 6: print(f"At the top is {i}") numbers.append(i) i = i + 1 print("Numbers now: ", numbers) print(f"At the bottom i is {i}") print("The numbers: ") for num in numbers: print(num) # convert while-loop to a function def test_loop(x): i = 0 ...
true
49bb1b18646aa0aad8ec823f7206ccb08709e36a
rojit1/python_assignment
/q9.py
247
4.375
4
# 9. Write a Python program to change a given string to a new string where the first # and last chars have been exchanged. def exchange_first_and_last(s): new_s = s[-1]+s[1:-1]+s[0] return new_s print(exchange_first_and_last('apple'))
true
62ed4994bb2ff26ee717f135a50eddff151e0643
rojit1/python_assignment
/q27.py
298
4.21875
4
# 27. Write a Python program to replace the last element in a list with another list. # Sample data : [1, 3, 5, 7, 9, 10], [2, 4, 6, 8] # Expected Output: [1, 3, 5, 7, 9, 2, 4, 6, 8] def replace_last(lst1, lst2): return lst1[:-1]+lst2 print(replace_last([1, 3, 5, 7, 9, 10], [2, 4, 6, 8]))
true
4f9ff83562f99c636dee253b7bfdbac93f46facc
rojit1/python_assignment
/functions/q3.py
263
4.46875
4
# 3. Write a Python function to multiply all the numbers in a list. # Sample List : (8, 2, 3, -1, 7) # Expected Output : -336 def multiply_elements(lst): ans = 1 for i in lst: ans *= i return ans print(multiply_elements([8, 2, 3, -1, 7]))
true
7b0614ad3f05e76bb8ca6400bc9e230f130c3d5e
xala3pa/Introduction-to-Computer-Science-and-Programming-with-python
/week4/Problems/L6PROBLEM2.py
960
4.1875
4
def oddTuples(aTup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' ans = () index = 1 for c in aTup: if index % 2 != 0: ans += (c,) index += 1 return ans def oddTuples2(aTup): ''' aTup: a tuple returns: ...
true
6b588b64560ceacfba4cbe1676eae2d565a28358
bshep23/Animation-lab
/Animation.py
1,388
4.15625
4
# ------------------------------------------------- # Name: Blake Shepherd and Lilana Linan # Filename: Animation.py # Date: July 31th, 2019 # # Description: Praticing with animation # # ------------------------------------------------- from graphics import * import random class Fish: ...
true
baefdc82a2d2af26940678bd040c871350cc6a77
swang2017/python-factorial-application
/factorial.py
390
4.15625
4
try: input_number = int(raw_input("please enter an integer\n")) except ValueError: print("Hey you cannot enter alphabets") except FileNotFound: print("File not found") else: print("no exceptions to be reported") # result = 1 # for index in range (1, input_number+1): # result = result * index # # ...
true
2b7470c9569abd1a45a8ab79b20e9f82418dc941
savithande/Python
/strings1.py
1,290
4.4375
4
# single quote character str = 'Python' print(str) # fine the type of variable print(type(str)) print("\n") # double quote character str = "Python" print(str) # fine the type of variable print(type(str)) print("\n") # triple quote example str = """Python""" print(str) # fine the type of variable print(type(str)...
true
a2fb730cc784a3720dc845069b9a0e1a4821adbe
jovian34/j34_simple_probs
/elementary/05sum_multiples/sum_of_multiples.py
1,239
4.1875
4
# http://adriann.github.io/programming_problems.html # Write a program that asks the user for a number n and prints # the sum of the numbers 1 to n # Modify the previous program such that only multiples of three or # five are considered # in the sum, e.g. 3, 5, 6, 9, 10, 12, 15 for n=17 def get_number_from_user(): ...
true
b29e7eba5620eb7d8c54715543b62cae65aaeee4
yashgugale/Python-Programming-Data-Structures-and-Algorithms
/NPTEL Course/Concept Practices/inplace_scope_exception2.py
1,222
4.1875
4
L1 = [10, 20 ,30] print("Global list L: ", L1) def f1(): L1[2] = 500 print("L1 from function on in place change is is: ", L1) print("\nShallow copy of L1 to L2") L2 = L1 L2.append(600) print("Lists L1 and L2 are: L1:", L1, "L2: ", L2) print("\nDeep copy of L1 to L3") L3 = L1.copy() ...
true
9e750b872b0d154f74f64353e71b0bdeb7e4f122
nguyeti/mooc_python_10_app
/OOP/example.py
1,880
4.21875
4
class Machine: def __init__(self): print("I am a Machine") class DrivingMachine(Machine): def __init__(self): print("I am a DrivingMachine") def start(self): print("Machine starts") class Bike(DrivingMachine): def __init__(self, brand, color): self.brand = brand # __at...
true
eb2b71845ab019e7fa8131669bf3777e6d93c3d5
nguyeti/mooc_python_10_app
/ex1_c_to_f.py
541
4.1875
4
""" This script converts C temp into F temp """ # def celsiusToFahrenheit(temperatureC): # if temperatureC < -273.15: # print("That temperature doesn't make sense!") # else: # f = temperatureC * (9/5) + 32 # return f temperatures = [10, -20, -289, 100] def writer(temperatures): """T...
true
1f90807c81934fd38d38dd8bd5e42102813efa86
c18441084/Python
/Labtest1.py
1,056
4.375
4
#Function to use Pascal's Formula def make_new_row(old_row, limit): new_row = [] new_list = [] L=[] i=0 new_row = old_row[:] while i < limit: new_row.append(1) long = len(new_row) - 1 j=0 h=0 if i ==0: new_list = new_row[:] ...
true
d0092057d615ba0067f48a07be80c37e423b0cd9
bachns/LearningPython
/exercise24.py
278
4.3125
4
# Write a Python program to test whether a passed letter is a vowel or not. def isVowel(v): vowels = ("u", "e", "o", "a", "i") return v in vowels vowel = input("Enter a letter: ") if isVowel(vowel): print("This is a vowel") else: print("This isn't a vowel")
true
ece0d3f409b258a7a098917b0a865f2569c8eb10
bachns/LearningPython
/exercise27.py
255
4.15625
4
# Write a Python program to concatenate all elements in a list into # a string and return it def concatenate(list): conc_str = "" for number in list: conc_str += str(number) return conc_str print(concatenate([3, 4, 1000, 23, 2]))
true
60fe76e0b3bd43e87dde6e7e7d77ad4d5108c326
bachns/LearningPython
/exercise7.py
315
4.25
4
# Write a Python program to accept a filename from the user and print # the extension of that. # Sample filename : abc.java # Output : java filename = input("Enter file name: ") parts = filename.rsplit(".", 1) print("Extension:" + parts[-1]) index = filename.rfind(".") + 1 print("Extension:" + filename[index:])
true
c3a0e29d457803d6bbae306b86c2ed98e476d77d
bachns/LearningPython
/exercise21.py
334
4.25
4
# Write a Python program to find whether a given number (accept from the user) # is even or odd, print out an appropriate message to the user def check_number(number): if number % 2: return "This is an odd number" return "This is an even number" number = int(input("Enter a number: ")) print(check_nu...
true
a2bc4a35e26f590c738178bdaffac36e42b56993
hitendrapratapsingh/python_basic
/user_input.py
229
4.28125
4
# input function #user input function name = input("type your name") print("hello " + name) #input function type alwase value in string for example age = input("what is your age") #because herae age is string print("age: " + age)
true
750900f9be03aac96ec39601a667b6c3948c0ad3
injoon5/C3coding-python
/2020/04/22/02.py
388
4.125
4
height =int(input("your height : ")) if height<110: print("Do not enter!") if height>= 110: print("have a nice time!") if height == 110: print("perfect!") if height != 110: print("Not 110.") if 100 <= height <110: print("Next year~") print("Booltype = ", height< 110,height >= 110, heigh...
true
c1a3c8305447e8ef79212e07731b4744759074f7
shakibaSHS/pythonclass
/s3h_1_BMI.py
245
4.15625
4
weight = int(input('input your weight in kg\n weight=')) height = float(input('input your height in meter\n height=')) def BMI(weight , height): B = weight / (height ** 2) return B print(f'Your BMI is= {BMI(weight , height)}')
true
b2b54b45e806acff0d0d7efee18c0bf5b6b4d0b0
abhishek5135/Python_Projects
/snakewatergun.py
1,550
4.125
4
import time import random def turn(num): player_1=0 player_2=0 listcomputer=['snake','water','gun'] computer=random.choice(listcomputer) num2=0 while(num2!=num): print("snake","water","gun") players_inpu = input("Player 1 Enter your choice from above ") print...
true
16cf1423d8a7840f49b7ad206f0f8b9f5104a514
meet29in/Sp2018-Accelerated
/students/mathewcm/lesson04/trigrams.py
1,217
4.125
4
#!/usr/bin/env Python """ trigrams: solutions to trigrams """ sample = """Now is the time for all good men to come to the aid of the country""" import sys import random words = sample.split() print(words) def parse_file(filename) """ parse text file to makelist of words """ with open(filename) as i...
true
3580488590a479d85b7e0bce53567e00608b2d61
ShadowStorm0/College-Python-Programs
/day_Of_The_Week.py
824
4.34375
4
#Day of Week List Week = ['I can only accept a number between 1 and 7. Please try again.', 'Sunday', 'Monday', 'Tuesday', 'Wedensday', 'Thursday', 'Friday' ,'Saturday'] #Introduce User to Program print('Day of the Week Exercise') print('Enter a number for the day of the week you want displayed.') #Input prompt / Inpu...
true
1eb61779347687b166f28a48fb2a69747482c8fe
LuckyLub/crashcourse
/test_cc_20190305.py
2,316
4.3125
4
'''11-1. City, Country: Write a function that accepts two parameters: a city name and a country name. The function should return a single string of the form City, Country , such as Santiago, Chile . Store the function in a module called city _functions.py. Create a file called test_cities.py that tests the function you...
true
c4a6190da0cdbfc05b981df0e3db311bc1ca8ec7
yashsf08/project-iNeuron
/Assignment2-python/program-one.py
481
4.1875
4
""" 1. Create the below pattern using nested for loop in Python. * * * * * * * * * * * * * * * * * * * * * * * * * """ from math import ceil def draw_pattern(data): upper_limit = ceil(data/2) print(upper_limit) lower_limit = 0 for i in range(upper_limit): print('*'*(i+1)) for i in range(...
true
251975745094bce828e72eb2571e38a470aae3a1
vladskakun/TAQCPY
/tests/TestQuestion12.py
595
4.125
4
""" 12. Concatenate Variable Number of Input Lists Create a function that concatenates n input lists, where n is variable. Examples concat([1, 2, 3], [4, 5], [6, 7]) ➞ [1, 2, 3, 4, 5, 6, 7] concat([1], [2], [3], [4], [5], [6], [7]) ➞ [1, 2, 3, 4, 5, 6, 7] concat([1, 2], [3, 4]) ➞ [1, 2, 3, 4] concat([4, 4,...
true
604eb41c794380ba4cc3b4542518b7246889f582
vladskakun/TAQCPY
/tests/TestQuestion19.py
918
4.5
4
""" 19. Oddish vs. Evenish Create a function that determines whether a number is Oddish or Evenish. A number is Oddish if the sum of all of its digits is odd, and a number is Evenish if the sum of all of its digits is even. If a number is Oddish, return "Oddish". Otherwise, return "Evenish". For example, oddish_or_e...
true
c86585ae6baf8cd8772c752f335e161ce6382f38
vladskakun/TAQCPY
/tests/TestQuestion24.py
753
4.15625
4
""" 24. Buggy Uppercase Counting In the Code tab is a function which is meant to return how many uppercase letters there are in a list of various words. Fix the list comprehension so that the code functions normally! Examples count_uppercase(['SOLO', 'hello', 'Tea', 'wHat']) ➞ 6 count_uppercase(['little', 'lower...
true
bef9c39d7a11dbedc7633555a0b6c370384d737f
HakimZiani/Dijkstra-s-algorithm
/dijkstra.py
2,356
4.28125
4
#---------------------------------------------------------------------- # Implementation of the Dijkstra's Algorithm # This program requires no libraries like pandas, numpy... # and the graph DataStructure is a dictionary of dictionaries # # Created by [HakimZiani - zianianakim@gmail.com] #-----------------------------...
true
faa19462725653c83f971c0ca8717b085e16973d
eishk/Udacity-Data-Structures-and-Algorithms-Course
/P0/Task4.py
1,188
4.3125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) calls_caller = set() calls_called = set() t...
true
8318d4a5b9e442193b267dd7e045f60adabfe243
ramendra-singh/Practice
/DataStructure/Strings/secondMostChar.py
1,400
4.1875
4
''' Program to find second most frequent character Given a string, find the second most frequent character in it. Expected time complexity is O(n) where n is the length of the input string. Examples: Input: str = "aabababa"; Output: Second most frequent character is 'b' Input: str = "geeksforgeeks"; Output: Second m...
true
be9b32579e460a7b44864ba89cd6161fbf03eff5
bmosc/Mindtree_TechFest_2015
/fractals/koch snow flake curve.py
879
4.125
4
#!/usr/bin/python from turtle import * def draw_fractal(length, angle, level, initial_state, target, replacement, target2, replacement2): state = initial_state for counter in range(level): state2 = '' for character in state: if character == target: state2 += replac...
true