blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
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
3cf7f0e66b8c81c56c8b362fc05f000c243e9249
HimNG/CrackingTheCodeInterview
/2.2/2.2/_2.2.py
1,480
4.15625
4
class Node: def __init__(self,data): self.data=data self.next=None class linkedlist : #count=0 def __init__(self): self.head=None def insert_at_begin(self,data): node=Node(data) node.next=self.head self.head=node # kth last element with rec...
false
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
d6dffc62229cbd1851ed4bfd7b3244313576eb59
elim168/study
/python/basic/function/09.partial_test.py
404
4.15625
4
# 测试partial函数 # functools的partial函数可以把一个函数的某些参数固定住,然后返回新的函数。比如下面把int函数的base参数固定为2返回new_int函数,之后new_int都以二进制对字符串进行整数转换。 import functools new_int = functools.partial(int, base=2) print(new_int('111')) # 7 print(new_int('1110')) # 14 print(new_int('1110101')) # 117
false
dccdeed268be18dba9142290de732b5e20ad30c8
elim168/study
/python/basic/numpy/test02_array.py
498
4.125
4
import numpy # 创建一维的数组,基于一维的列表 ndarray = numpy.array([1, 2, 3, 4, 5, 6]) print(ndarray) print(type(ndarray)) # <class 'numpy.ndarray'> # 创建二维的数组,基于二维的列表。三维/四维等也是类似的道理 ndarray = numpy.array([[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7]]) print(ndarray) # 通过ndmin指定最小维度 ndarray = numpy.array([1, 2, 3], ndmin=5...
false
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
37eb9929352029c4ae42099cda1d8b29103a9f9d
myke-oliveira/curso-em-video-python3
/desafio22.py
734
4.40625
4
''' Crie um programa que leia o nome completo de uma pessoa e mostre: O nome com todas as letras maiúsculas. O nome con todas minusculas. Quantas letras ao todo (sem considerar espaços). Quantas letras tem o primeiro nome.''' print('Digite o nome completo da pessoa: ') nome = input().strip() print() print(...
false
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
5cd3edd9cbce8aa65769a8dd142828c072390537
jovian34/j34_simple_probs
/elementary/07mult_table/mult_table.py
372
4.1875
4
# http://adriann.github.io/programming_problems.html # Write a program that prints a multiplication table for numbers up to 12. multi_table_12 = [] for x in range(1, 13): multi_table_row = [] for y in range(1, 13): multi_table_row.append(x * y) multi_table_12.append(multi_table_row) for i in range...
false
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
bcae10b007172a57dac0121a7a84feff564c60d6
nguyeti/mooc_python_10_app
/date_time.py
790
4.34375
4
from datetime import datetime, timedelta import time # Basic date operation now = datetime.now() yesterday = now - timedelta(days=1) lastYear = datetime(2016,3,8,0,0,0,0) # create a datime object with (year, month, day, hour, minute, seconds, milliseconds) print(str(now)) print(str(yesterday) + ' ***** \n') # convert...
false
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
4dcaabf16d2a0e0354d9954ee3b05306f19d1591
goonming/Programing
/5_9.py
504
4.40625
4
#creating and accessing and modifying a dict #ereate and print Dict emptyDict={} print "the value of emptyDict is :", emptyDict #creat and print Dict with initial values Dict={'Name':'chenming','age':100} print "this is chen ming: ", Dict #accessing and modifying the Dict age_2= raw_input("please input a age: ") Dic...
false
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
29791d166ecc57376e54f0ae83edebaae75acc2b
haema5/python_algorithms_and_structures
/hw07_01.py
932
4.125
4
# -*- coding: utf-8 -*- # 1. Отсортировать по убыванию методом «пузырька» одномерный целочисленный массив, # заданный случайными числами на промежутке [-100; 100). Вывести на экран исходный # и отсортированный массивы. from random import randint MIN = -100 MAX = 99 ARRAY_LEN = 10 def bubble_sort(array): n = 1 ...
false
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
ac68226a997c7c29a695f8a7f980010eeb5c2ae8
satyam4853/PythonProgram
/Functional-Programs/Quadratic.py
613
4.15625
4
""" * Author - Satyam Vaishnav * Date - 21-SEP-2021 * Time - 10:30 PM * Title - Quadratic """ #cmath module using to compute the math function for complex numbers import cmath #initalize the variables taking from UserInput. a=float(input("Enter the value of a: ")) b=float(input("Enter the value of b: ")...
true
2c6536e36c175fde978191d7041a56f0320d8d15
WOWOStudio/Python_test
/Xin/game/maze_game/tortoise.py
1,531
4.1875
4
#小乌龟模型 from turtle import Turtle class Tortoise(Turtle): def __init__(self,maze_list,start_m,start_n,end_m,end_n): Turtle.__init__(self) self.maze_list = maze_list self.m = start_m self.n = start_n self.end_m = end_m self.end_n = end_n self.hideturtl...
false
e2c667ae64facebd8546107afb9b1774a9576914
Mayym/learnPython
/1-OOP/03.py
1,772
4.21875
4
class Student(): name = "May" age = 20 def say(self): self.name = "zym" self.age = 22 print("My name is {0}.".format(self.name)) print("My age is {0}.".format(self.age)) def say_again(s): print("My name is {0}.".format(s.name)) print("My age is {0}.".for...
false
3b24e2a04e23058ab07b84286471a9fcb5df678e
luzonimrod/PythonProjects
/Lessons/MiddleEX1.py
250
4.125
4
#Write a Python program to display the current date and time. Sample Output : #Current date and time : #14:34:14 2014-07-05 from datetime import date today=date.today() ti=today.strftime("%d/%m/%Y %H:%M:%S") print("current date and time :\n " + ti)
true
7683518c723464172d103ab63ba4d1264c95ec4e
bipinaghimire/lab4_continue
/dictionary/fourtytwo.py
227
4.5625
5
''' .Write a Python program to iterate over dictionaries using for loops. ''' dict={1:'cow',2:'tiger',3:'lion',4:'monkey'} for i in dict: print(i) for j in dict.values(): print(j) for k in dict.items(): print(k)
false
f8551faa26b591b1ee0d4325d236a87da3e5ad6e
imshawan/ProblemSolving-Hackerrank
/30Days-OfCode/Dictionaries and Maps.py
469
4.125
4
# Day 8: Dictionaries and Maps # Key-Value pair mappings using a Map or Dictionary data structure # Enter your code here. Read input from STDIN. Print output to STDOUT N=int(input()) phoneBook={} for _ in range(N): name,contact=input().split() phoneBook[name]=contact try: while(True): check=str...
true
50ac0dc6dfbe3a6dff8fb85eb0788936e75e9845
hericlysdlarii/Respostas-lista-de-Exercicio
/Questao4.py
266
4.15625
4
# Faça um Programa que verifique se uma letra digitada é vogal ou consoante. letra = str(input("Digite uma letra: ")) if ((letra == 'a') or (letra == 'e') or (letra == 'i') or (letra == 'o') or (letra == 'u')): print("Vogal") else: print("Consoante")
false
5fddff1509c6cdd53ecf20c4230f1db35f769544
tawrahim/Taaye_Kahinde
/Kahinde/chp6/tryitout (2).py
1,912
4.125
4
print "First Question:" firstname="Kahinde" lastname="Giwa" print "Hello,my name is,",firstname,lastname print "\n\n\n" print "**************************\n" firstname=raw_input("Enter your first name please:") lastname=raw_input("Now enter your lastname:") print "You entered",firstname,"for your firstname," pr...
true
77ef1a85e93549c28e6eeef9fdeeeab5a1365350
tawrahim/Taaye_Kahinde
/Taaye/chp4/dec-int.py
1,346
4.625
5
print "Question #1, Try it out" print"\n" print'This is a way to change a string to a float' string1=12.34 string="'12.34'" print 'The string is,',string point= '12.34' formula= float(string1) print "And the float is,",point print 'We use this formala to change a string into a float, the formula is,', formul...
true
07566268fa1ca3f0e66a41f8fc4d6f758fdaa9d0
tawrahim/Taaye_Kahinde
/Kahinde/chp8/looper_tio.py
1,077
4.125
4
#Kainde's work,Chapter 8,tryitout,question1 number=int(raw_input("Hello, what table should I display? Type in a number:")) print "Here is your table:" for looper in range(number): print looper, "*",number,"=",looper*number print "\n*************************************" #Chapter 8,tryitout,question2 ...
true
89ba7658b45e09a370813e75845e4009e9d4fa28
TrinityChristiana/py-classes
/main.py
882
4.15625
4
# **************************** Challenge: Urban Planner II **************************** """ Author: Trinity Terry pyrun: python main.py """ from building import Building from city import City from random_names import random_name # Create a new city instance and add your building instances to it. Once all buildings ar...
true
a2ca245925c0c9fd9408ba5d5ca109c655d9af56
rashmitallam/PythonBasics
/tables_2_to_n.py
271
4.25
4
#WAP to accept an integer 'n' from user and print tables from 2 to n n=input('Enter an integer:') for x in range(2,n+1): print("Table of "+str(x)+":\n") for y in range(1,11): z = x*y print(str(x)+"*"+str(y)+"="+str(z)) print('\n')
false
a2e72fc8db97045e7b33c13ec8d40eb9dcb37ca6
lokeshom1/python
/datetransformer.py
682
4.21875
4
month = eval(input('Please enter the month as a number(1-12): ')) day = eval(input('Please enter the day of the month : ')) if month == 1: print('January', end='') elif month == 2: print('February', end='') elif month == 3: print('March', end='') elif month == 4: print('April', end='') elif month ==...
true
311ab08d466143062b58036743236330b0c92f57
khamosh-nigahen/linked_list_interview_practice
/Insertion_SLL.py
1,692
4.5625
5
# Three types of insertion in Single Linked List # ->insert node at front # ->insert Node after a given node # ->insert Node at the tail class Node(object): def __init__(self, data): self.data = data self.nextNode = None class singleLinkedList(object): def __init__(self): ...
true
a157d4775a860a6be525c7308aed0773f5dd926b
eugenialuzzi/UADE
/PROGRA1_TP1_ej6.py
842
4.125
4
#Escribir dos funciones para imprimir por pantalla cada uno de los siguientes patrones #de asteriscos. def ImprimirCuadrado(n): """Imprime un cuadrado de asteriscos. Recibe la cantidad de filas y columnas nxn, e imprime el cuadrado de asteriscos""" for i in range(n): for j in range(n): ...
false
2f69c84b0517375ad6e4591ca8ad4dab9279d708
AkashKadam75/Kaggle-Python-Course
/Boolean.py
716
4.125
4
val = True; print(type(val)) def can_run_for_president(age): """Can someone of the given age run for president in the US?""" # The US Constitution says you must "have attained to the Age of thirty-five Years" return age >= 35 print("Can a 19-year-old run for president?", can_run_for_president(19)) print("C...
true
ef8b9904bbaf95f0ee8e7b53ecff67ae4b2593c9
huboa/xuexi
/oldboy-python18/day04-函数嵌套-装饰器-生成器/00-study/00-day4/生成器/生成器.py
1,807
4.28125
4
#生成器:在函数内部包含yield关键,那么该函数执行的结果是生成器 #生成器就是迭代器 #yield的功能: # 1 把函数的结果做生迭代器(以一种优雅的方式封装好__iter__,__next__) # 2 函数暂停与再继续运行的状态是由yield # def func(): # print('first') # yield 11111111 # print('second') # yield 2222222 # print('third') # yield 33333333 # print('fourth') # # # g=func() # print(g) #...
false
8c4f19f7f6a830f31d76d64251ee6bcc0c46366d
huboa/xuexi
/oldboy-python18/day07-模块补充-面向对象/self/05-继承/组合.py
1,585
4.25
4
class OldboyPeople: school = 'oldboy' def __init__(self,name,age,sex): self.name=name self.age=age self.sex=sex def eat(self): print('is eating') class OldboyStudent(OldboyPeople): def __init__(self,name,age,sex): OldboyPeople.__init__(self,name,ag...
false
86eb98601768f42b58559422e47e2b3d516d3bdd
huboa/xuexi
/oldboy-python18/day07-模块补充-面向对象/00-tt/day7/继承/继承.py
2,485
4.53125
5
#继承的基本形式 # class ParentClass1(object): #定义父类 # pass # # class ParentClass2: #定义父类 # pass # # class SubClass1(ParentClass1): #单继承,基类是ParentClass1,派生类是SubClass # pass # # class SubClass2(ParentClass1,ParentClass2): #python支持多继承,用逗号分隔开多个继承的类 # pass # # # # # print(SubClass1.__bases__) # print(SubClass2.__b...
false
fe0628d501eaa9391b229991a3dfaf1940ff0751
huboa/xuexi
/oldboy-python18/day03-函数-file/00-day3/函数参数.py
2,026
4.3125
4
#形参:在定义函数时,括号内的参数成为形参 #特点:形参就是变量名 # def foo(x,y): #x=1,y=2 # print(x) # print(y) #实参:在调用函数时,括号内的参数成为实参 #特点:实参就是变量值 # foo(1,2) #在调用阶段实参(变量值)才会绑定形参(变量名) #调用结束后,解除绑定 #参数的分类 #位置参数:按照从左到右的顺序依次定义的参数 #位置形参:必须被传值,并且多一个不行,少一个也不行 #位置实参:与形参按照位置一一对应 # def foo(x,y): # print(x) # p...
false
2fa86da40002d7a92e3dd06c3643c3cf76d8f91c
huboa/xuexi
/oldboy-python18/day08-接口-网络/00-day8/封装.py
2,931
4.15625
4
#先看如何隐藏 class Foo: __N=111111 #_Foo__N def __init__(self,name): self.__Name=name #self._Foo__Name=name def __f1(self): #_Foo__f1 print('f1') def f2(self): self.__f1() #self._Foo__f1() f=Foo('egon') # print(f.__N) # f.__f1() # f.__Name # f.f2() #这种隐藏需要注意的问题: #1:这种隐藏只是一种语法上变形操作...
false
052744e05cac11301014d1c33f8bc99e41c023c0
huboa/xuexi
/oldboy-python18/day03-函数-file/00-day3/可变长参数.py
2,575
4.15625
4
#可变长参数指的是实参的个数多了 #实参无非位置实参和关键字实参两种 #形参必须要两种机制来分别处理按照位置定义的实参溢出的情况:* #跟按照关键字定义的实参溢出的情况:** # def foo(x,y,*args): #nums=(3,4,5,6,7) # print(x) # print(y) # print(args) # foo(1,2,3,4,5,6,7) #* # foo(1,2) #* #*args的扩展用法 # def foo(x,y,*args): #*args=*(3,4,5,6,7) # print(x) # print(y) # print(args...
false
3a5ba0d910522c04787252d6a8afc8e8cae27952
AdamsGeeky/basics
/04 - Classes-inheritance-oops/51-classes-descriptor-magic-methods.py
2,230
4.25
4
# HEAD # Classes - Magic Methods - Building Descriptor Objects # DESCRIPTION # Describes the magic methods of classes # __get__, __set__, __delete__ # RESOURCES # # https://rszalski.github.io/magicmethods/ # Building Descriptor Objects # Descriptors are classes which, when accessed through either getting, sett...
true
2b4ee967304815ea875dfc6e943a298df143ef48
AdamsGeeky/basics
/04 - Classes-inheritance-oops/05-classes-getters-setters.py
784
4.34375
4
# HEAD # Classes - Getters and Setters # DESCRIPTION # Describes how to create getters and setters for attributes # RESOURCES # # Creating a custom class # Class name - GetterSetter class GetterSetter(): # An class attribute with a getter method is a Property attr = "Value" # GETTER - gets values for at...
true
6f45acaeec134b92f051c4b43d100eeb45533be4
AdamsGeeky/basics
/02 - Operators/10-membership-operators.py
1,363
4.59375
5
# HEAD # Membership Operators # DESCRIPTION # Describe the usage of membership operators # RESOURCES # # 'in' operator checks if an item is a part of # a sequence or iterator # 'not in' operator checks if an item is not # a part of a sequence or iterator lists = [1, 2, 3, 4, 5] dictions = {"key": "valu...
true
57e6b0b5cbb90562a02251739653f405b8237114
AdamsGeeky/basics
/03 - Types/3.1 - InbuiltTypes-String-Integer/05-integer-intro.py
952
4.15625
4
# HEAD # DataType - Integer Introduction # DESCRIPTION # Describes what is a integer and it details # RESOURCES # # int() is a function that converts a # integer like characters or float to a integer # float() is a function that converts a # integer or float like characters or integer to a float # Work...
true
b04ae7f2eea4a5301c9439e4403403599358a05f
AdamsGeeky/basics
/04 - Classes-inheritance-oops/54-classes-overwriting.py
1,525
4.375
4
# Classes # Overriding # Vehicle class Vehicle(): maneuver = "Steering" body = "Open Top" seats = 4 wheels = 4 start = 0 end = 0 def __init__(self, maneuver, body, seats, wheels): self.maneuver = maneuver self.body = body self.seats = seats self.wheels = whe...
true
a0f7967a83d0876a37cc74dd8c3c3dc8e1f2eaf3
AdamsGeeky/basics
/01 - Basics/33-error-handling-try-except-intro.py
1,137
4.1875
4
# HEAD # Python Error Handling - UnNamed Excepts # DESCRIPTION # Describes using of Error Handling of code in python # try...except is used for error handling # # RESOURCES # # 'try' block will be be executed by default # If an error occurs then the specific or # related 'except' block will be trigered # ...
true
a30f5ca5fac728d808ef78763f16ca54290765f6
AdamsGeeky/basics
/01 - Basics/11-flowcontrol-for-enumerate-loops.py
1,129
4.78125
5
# HEAD # Python FlowControl - for loop # DESCRIPTION # Describes usage of for loop in different ways # for different usages # # 'for' loop can iterate over iterable (sequence like) or sequence objects # Result provided during every loop is an index and the relative item # # RESOURCES # # # USAGE # 1 # # for i...
true
0640d7d0149ef291a99d472edcaf9e6d6c80ebe4
AdamsGeeky/basics
/01 - Basics/50-datatypes-type-conversion.py
2,961
4.5625
5
# HEAD # Python Basics - Conversion of Data Types # DESCRIPTION # Type Conversion # DESCRIPTION # Describes type conversion methods (inter-conversion) available in python # # RESOURCES # # These function can also be used to declare specific types # When appropriate object is used, these functions can be # use...
true
ee34a13657d64a8f3300fdf73e34362ad5a49206
AdamsGeeky/basics
/04 - Classes-inheritance-oops/17-classes-inheritance-setters-shallow.py
1,030
4.46875
4
# HEAD # Classes - Setters are shallow # DESCRIPTION # Describes how setting of inherited attributes and values function # RESOURCES # # Creating Parent class class Parent(): par_cent = "parent" # Parent Init method def __init__(self, val): self.par_cent = val print("Parent Instantiated ...
true
f96d6651e41ca733e06d7b0346137a65688cd20a
RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2-
/Reading_list_INTs_Exception.py
816
4.21875
4
def Assign(n): try: return(int(n)) except ValueError: # Managing Inputs Like 's' print("Illegal Entery\nRetry..") n=input() # Asking User to Re-entry Assign(n) # Calling the Same function,I correct input entered..Integer will be Returned,Else..Calling Recursively return(int(n)) #Ret...
true
da0158c1a20f3cf8a521b342fd4315bb5672100d
curiosubermensch/python-autodidacta
/wily.py
290
4.125
4
#while es un ciclo indefinido def whily(): n=int(input("ing numero positivo:")) while n<0: print("error de ingreso") n=int(input("ing numero positivo:")) print("el numero positivo ing es: ",n) def whilyBreak(): n=int(input("ing numero positivo:")) if n<0: break print()
false
d673103b6d9361916427652b337b9fbbf1fe7eae
cnkarz/Other
/Investing/Python/dateCreator.py
1,743
4.21875
4
# -*- coding: utf-8 -*- """ This script writes an array of dates of weekdays as YYYYMMDD in a csv file. It starts with user's input, which must be a monday in the same format Created on Wed Jan 25 07:36:22 2017 @author: cenka """ import csv def displayDate(year, month, day): date = "%d%02d%02d" % (year, month, da...
true
b3ee3c37efe6d97d32869f14d6e5bba5e9e8fc91
bglogowski/IntroPython2016a
/students/Boundb3/Session05/cigar_party.py
594
4.125
4
#!/usr/bin/env python """ When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Return True if the party with the given values ...
true
c81670473d618bdb663d88d94f54980e3f0b563c
rohitgupta29/Python_projects
/Data_Structures/4.Hexadecimal_output.py
337
4.1875
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 10 16:46:47 2020 @author: infom """ def hex_output(): decnum = 0 hexnum = input('Enter a hex number to convert: ') for power, digit in enumerate (reversed(hexnum)): decnum += int(digit,16) * (16 ** power) print(decnum) ...
false
73a241b1ba5d6337a93fe53fdfdb85815953d13e
AaryaVora/Python-Level-1-2
/hw3.py
266
4.125
4
fnum = int(input("Please enter a number: ")) snum = int(input("Please enter a number: ")) if fnum == snum : print("Both numbers are equal") elif fnum < snum: print("Second number is greater") else: print("First number is greater than the second number")
true
e61e0925cb261ff53f4a3ce9cf90314a3d9c4ed9
Harrison-Z1000/IntroProgramming-Labs
/labs/lab_03/pi.py
1,077
4.34375
4
# Introduction to Programming # Author: Harrison Zheng # Date: 09/25/19 # This program approximates the value of pi based on user input. import math def main(): print("This program approximates the value of pi.") n = int(input("Enter the number of terms to be summed: ")) piApproximation = approximate(n)...
true
1b2dea794f55fab9398ec2fcbf258df7007f0f90
yash95shah/Leetcode
/swapnotemp.py
284
4.28125
4
''' know swapping works on python without actually using temps ''' def swap(x, y): x = x ^ y y = x ^ y x = x ^ y return (x, y) x = int(input("Enter the value of x: ")) y = int(input("Enter the value of y: ")) print("New value of x and y: " + str(swap(x, y)))
true
ca312b4e02650221b6bb5f34871ef12f45ad98d9
yash95shah/Leetcode
/sumwithoutarith.py
411
4.3125
4
''' Sum of two integers without actually using the arithmetic operators ''' def sum_without_arith(num1, num2): temp_sum = num1 ^ num2 and_sum = num1 & num2 << 1 if and_sum: temp_sum = sum_without_arith(temp_sum, and_sum) return temp_sum n1 = int(input("Enter your 1st number: ")) n2 = int(i...
true
3962ed28f3ccc7d4689d73f5839bc6d016e43736
Juhkim90/Multiplication-Game-v.1
/main.py
980
4.15625
4
# To Run this program, # Press Command + Enter import random import time print ("Welcome to the Multiplication Game") print ("Two Numbers are randomly picked between 0 and 12") print ("Try to Answer ASAP. If you do not answer in 3 seconds, You FAIL!") score = 0 ready = input("\n...
true
442554266ce87af7740511669163b8c575a96950
OliviaParamour/AdventofCode2020
/day2.py
1,553
4.25
4
import re def load_file(file_name: str) -> list: """Loads and parses the input for use in the challenge.""" input = [] with open(file_name) as file: for line in file: parts = re.match(r"^(\d+)-(\d+) ([a-z]): (\w+)$", line) input.append((int(parts.group(1)), int(parts.group(...
true
1b120b65333495c5bd98f63e0e016942b419a708
DarshAsawa/ML-and-Computer-vision-using-Python
/Python_Basics/Roll_Dice.py
413
4.28125
4
import random no_of_dices=int(input("how many dice you want :")) end_count=no_of_dices*6 print("Since you are rolling %d dice or dices, you will get numbers between 1 and %d" % (no_of_dices,end_count)) count=1 while count==1 : user_inp=input("Do you want to roll a dice : ") if user_inp=="yes" or user_inp=="y" or use...
true
f1d228b0afac00ffc567698775fc594b8e2b1069
nischalshk/pythonProject2
/3.py
385
4.3125
4
""" 3. Write code that will print out the anagrams (words that use the same letters) from a paragraph of text.""" print("Question 3") string1 = input("Enter First String: ") string2 = input("Enter Second String: ") sort_string1 = sorted(string1.lower()) sort_string2 = sorted(string2.lower()) if sort_string1 == so...
true
e838332cbe89a89c11746c421c6b284c0c05af94
jkfer/LeetCode
/Find_Largest_Value_in_Each_Tree_Row.py
1,117
4.15625
4
""" You need to find the largest value in each row of a binary tree. """ # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None root = TreeNode(1) root.left = TreeNode(3) root.right = TreeNode(2) root.left.left = TreeNode...
true
1d79865e5d1a2ce727eff4c55c8ddd8cd22dee65
liyaozr/project
/base/day6/02while的使用.py
1,598
4.21875
4
""" ============================ Author:柠檬班-木森 Time:2020/1/6 20:47 E-mail:3247119728@qq.com Company:湖南零檬信息技术有限公司 ============================ """ """ 需求:打印100白hello python """ # 定义一个变量来计数,记录打印了多少遍hello python i = 0 while i < 100: i = i + 1 print("这是第{}遍打印:hello python".format(i)) # ----------------------...
false
ee1f838de3652e533b1600bce3fa33f59ad8d26d
Yasune/Python-Review
/Files.py
665
4.28125
4
#Opening and writing files with python #Files are objects form the class _io.TEXTIOWRAPPER #Opening and reading a file myfile=open('faketext.txt','r') #opening options : #'r' ouverture en lecture #'w' ouverture en ecriture #'a' ouverture en mode append #'b' ouverture en mode binaire print type(myfile) content=myfile...
true
688c1740371fdc204941281724563f4c813b2ab7
Introduction-to-Programming-OSOWSKI/2-9-factorial-beccakosey22
/main.py
208
4.21875
4
#Create a function called factorial() that returns the factorial of a given variable x. def factorial(x): y = 1 for i in range (1, x + 1): y = y*i return y print(factorial(5))
true
27c08ed8c4d0b80c7039144a170f6375b6daba3f
Spuntininki/Aulas-Python-Guanabara
/ex0060.py
493
4.15625
4
#Programa que lê um numero inteiro positivo qualquer e mostra seu fatorial from math import factorial n = int(input('Digite um número: ')) f = factorial(n) print('O fatorial de {} é {} '.format(n, f)) '''c = n fator1 = n resultado = n * (n-1) for c in range(1, n-1): n -= 1 resultado = resultado * (n-1) print('...
false