blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
52008b5181e886e0656108dab34c19823d1caa07
brandonbloch/cisc327
/bCommands.py
2,983
4.21875
4
def find_account(number, accounts): """ This function takes in a account number and the master accounts list to check if the specified account number is in the master accounts list. """ for i in range(len(accounts)): if accounts[i][0] == number: return i+1 return 0 def wi...
true
246230d338d105ac5c2b85f151a63818d8b890a7
1gn1z/Python_Ejercicios
/ex005_cadena_inversa.py
824
4.40625
4
# Ejercicio 5. Obtener la representacion inversa de una cadena de caracteres #cadena = input('Ingresa la cadena: ') #print(cadena[::-1]) # Lo logré sin ver el tutorial :3 <3 # De aquí pa' abajo el codigo del tutorial. # Con un ciclo for iteraremos la cadena cadena = 'Python' # Con RANGE definimos que empiece desde...
false
77cee1eae648b4d90ce87bfd203332c8f49fd0c8
Mb01/Code-Samples
/algorithms/sorting/heapsort.py
1,886
4.25
4
#!/usr/bin/env python import random LENGTH = 100 data = [random.randint(0,100) for _ in range(LENGTH)] def heapsort(lst): def swap(lst, a, b): """given a list, swap elements at 'a' and 'b'""" temp = lst[a] lst[a] = lst[b] lst[b] = temp def siftdown(lst, start, en...
true
e02e83c6c26a6e38a6451a1f2fff180be829c9d2
krei/scripts
/dectobin.py
255
4.1875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- decimals = int(input("Введите натуральное число: ")) binars = "" while decimals > 0: y = str(decimals % 2) binars = y + binars decimals = int(decimals / 2) print(binars)
false
1c676ba9bb43be453458060ce539fa12e31e645b
brianaguirre/CS3240
/lab3/lab3_part1.py
1,642
4.28125
4
__author__ = 'BrianAguirre' #USER CREATION user_name = "" password = "" data = {} print("This program takes in usernames and password.") print("If at any point you wish to quit, enter an empty string.") user_name = input("Please enter the first user name:") password = input("Enter a password for " + user_name + ":")...
true
58d8e5da962370d21564be1b4e891a64abfb26da
underwaterlongs/codestorage
/Project_Euler/P3_LargestPrimeFactor.py
1,362
4.15625
4
""" The prime factors of 13,195 are 5,7,13,29. What is the largest prime factor of a given number ? We can utilize Sieve of Eratosthenes to find the prime factors for N up to ~10mil or so efficiently. General pseudocode for sieve: initialize an array of Boolean values indexed by 2 to N, set to True i = 2 for i to ...
true
05f7b9c287e7acf3a1534243c4cb7b96cdf5d916
felipem0ta/furry-potato
/Python/Cousera_Google Automation/Crash Course/coursera.py
791
4.1875
4
""" função que conta quantas vezes uma letra aparece em um texto. """ def count_letters(text): result = {} #incializando um dicionario vazio for letter in text: #percorre o texto passado if letter not in result: result[letter] = 0 #inicializa a contagem da letra com 0 se não estiver no dic...
false
1044ae5fa1dcff182100ef9f352d2985e2ee924a
Roy-Chandan/Roy-world
/Range1.py
685
4.15625
4
def user_choice(): choice = 'Wrong' accept_range = range(0,10) within_range = False while choice.isdigit() == False or within_range == False: choice = input ("Enter a number between 1-10: ") if choice.isdigit() == False: print ("Please enter a numb...
true
2cd2cee48549e357234920cd03528ecad6b1c5ba
kvega/potentialsim
/src/potentialsim.py
1,020
4.28125
4
#!/usr/bin/python3 import pylab import random """ Generates a text file of values representing the coordinates of n particles in a potential. """ # Create the Particle Class class Particle(object): """ Representation of a simple, non-interacting, massive particle (assumes point-like, does not model charg...
true
861a99afac2f93a6163847d6a9bdc57b21136b19
jflow415/mycode
/dict01/marvelchar01.py
1,290
4.21875
4
#!/usrbin/env python3 marvelchars = { "Starlord": {"real name": "peter quill", "powers": "dance moves", "archenemy": "Thanos"}, "Mystique": {"real name": "raven darkholme", "powers": "shape shifter", "archenemy": "Professor X"}, "She-Hulk":{ "real name": "jennifer walters", "powers": "super...
true
7830f2711cd16350747357b1639b0f72d2974a68
RasikKane/problem_solving
/python/00_hackerrank/python/08_list_comprehension.py
631
4.375
4
""" Let's learn about list comprehensions! You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n. Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n. Here, 0 <= i <=x , 0 <=j <=y, 0 <= k <=z. Please use lis...
true
51ac5fba05dea57ebbc98fc66092876f2e867b82
NoraIlisics/FirstRep
/for.py
924
4.34375
4
#Write a program which sums the integers from 1 to 10 using a for loop # (and prints the total at the end). total = 0 for i in range(1,11): total += i print(total) #Can you think of a way to do this without using a loop? total2 = sum(range(1,11)) print(total2) #Write a program which finds the factorial of a g...
true
57ddd657bd402e1b4666223f51ad8efcc17a070f
Nevashka/Project-Euler
/palindrome.py
591
4.1875
4
#Problem 4: Find the largest palindrome made from the product of two 3-digit numbers. def largest(digits): ''' (int) -> int return the largest palindrome from the product of the numbers with the given number of digits palindrome(2) -> 9009 ''' first = 10**(digits-1) last = (10**digits)-1 ...
true
b6de5d4434c5d21dbbafe799879b02b43278c2ec
davidlbyrne/cybersecurity
/assignment2/des_cbc.py
2,882
4.15625
4
#!/usr/local/bin/python3 # Assignment2 - Assignment 2, due November 7, 2018: Problem 6.1 # in the lecture notes. You may import the following packages from # Python libraries: import sys import binascii from Crypto.Cipher import DES from Crypto import Random def checkpad(plaintext): length= len(plaintext) ...
true
72e11ac47280c2ff079353f3e92a744fb16de490
sabasharf123/word-frequency
/word-frequency-starter.py
2,824
4.21875
4
#set up a regular expression that can detect any punctuation import re punctuation_regex = re.compile('[\W]') #open a story that's in this folder, read each line, and split each line into words #that we add to our list of storyWords storyFile = open('short-story.txt', 'r') #replace 'short-story.txt' with 'long-story.t...
true
80c4ac318f00b8cc10a938cfc432f09763e00871
AngelmunozQ/An
/Clases/examen3.py
1,552
4.125
4
#1 """def Calcu (num1,num2,num3): Z=(num1*num2*num3) f=(num1/num2/num3) W=(num1**num2**num3) print(f"{Z},{f},{W}") print(""" #1. Multiplicacion,Potencia y Division. #2.Salir """) Eleccion = (input("seleccione una opcion : ")) if Eleccion == "1": a = int(input("ingresa numero : ")) y = int(...
false
aec85ea6f687ec7516c577d5ddd58ed90f72e18f
tigerjoy/SwayamPython
/old_programs/cw_17_06_20/year.py
471
4.15625
4
year=int(input("enter year :")) if year%100==0: print("it is a centennial year") if year%400==0: print("it is a leap year") else: print("it is not a leap year") elif year%4==0: print("it is a leap year") else: print("it is not a leap year") # Alternative # if (year % 100 == 0) and (year % 400 == 0):...
true
571a5322ed3b18be4a319ffa3a14a9541b6f08d3
tigerjoy/SwayamPython
/old_programs/cw_2021_01_16/dictionary_exercise.py
639
4.1875
4
dict_users={} for i in range(1,11): # Enter username of user 1: username=input("Enter username of user {}:".format(i)) password=input("Enter password of user {}:".format(i)) dict_users[username]=password print("Enter log in details:") username=input("Enter username of user :") password=input("Enter password o...
true
3b51f2f0f0267366f5c1b246267ca3c10105cf9b
tigerjoy/SwayamPython
/old_programs/cw_2021_01_16/list_exercise.py
623
4.15625
4
list1 = [] list2 = [] size1 = int(input("Enter the size of list 1: ")) print("Enter elements in list 1") for i in range(size1): item = int(input("Enter element {}: ".format(i + 1))) list1.append(item) size2 = int(input("Enter the size of list 2: ")) print("Enter elements in list 2") for i in range(size2): ite...
true
12d9d1eb684dad8946f5c66c30eb5faec45c3f72
tigerjoy/SwayamPython
/old_programs/cw_2020_10_22/list_q15.py
264
4.34375
4
size=int(input("Enter size of a list:")) arr=[] for i in range(0,size): item=int(input("Enter element {}:".format(i+1))) arr.append(item) largest=arr[0] for i in range(1,size): if(arr[i]>largest): largest=arr[i] print("Largest element is:",largest)
true
2cc2a7b4d5e441bdd774cdd94d14d54257b2c91e
tigerjoy/SwayamPython
/old_programs/cw_2020_10_22/list_q16.py
269
4.25
4
size=int(input("Enter size of a list:")) arr=[] for i in range(0,size): item=int(input("Enter element {}:".format(i+1))) arr.append(item) smallest=arr[0] for i in range(1,size): if(arr[i]<smallest): smallest=arr[i] print("smallest element is:",smallest)
true
cb7ec04d9e47007ae26eb6a0dbeddf298c13ce90
tigerjoy/SwayamPython
/cw_2021_06_19/sum_factor_q11.py
253
4.1875
4
def sum_of_factor(num,f=1): if f>num//2: return(num) elif(num%f==0): return (f+sum_of_factor(num,f+1)) else: return (sum_of_factor(num,f+1)) num=int(input("Enter a number:")) print("Sum of factors of", num ,"is",sum_of_factor(num))
false
8c8c861daf4fb6f0c70eb776d8563907dda10f35
Yuchen-Yan/UNSW_2017_s2_COMP9021_principle_of_programming
/labs/lab_1/my_answer/celsius_to_fahrenheit.py
435
4.1875
4
# Written by Yuchen Yan for comp9021 lab 1 question1 ''' Prints out a conversion table of temperatures from Celsius to Fahrenheit degrees, with the former ranging from 0 to 100 in steps of 10. ''' min_temperature = 0 max_temperature = 100 step = 10 print('Celsius\tFahrenheit') for celsius in range(min_temperature,...
true
20e61a14ba04a69c1095840c5b33ff936f6a8d3b
vpiyush/SandBox
/python-samples/rangeOp.py
330
4.15625
4
# sequnce of numbers 0 to 8 for temp in range(9): print(temp) # sequnce of numbers 0 to 8 # range (start, stop) for temp in range(5, 9): print(temp) # sequnce of numbers 0 to 8 # range (start, stop, step) for temp in range(1, 9, 2): print(temp) #typecasting to list oddlist = list(range(1, 19, 2)) print...
true
27a48c5d309c06a6730df859139245bec6106a37
sureshanandcse/Python
/listex.py
693
4.34375
4
# Creating a List with the use of multiple values l= ["Sairam", "Engineering", "College"] print("\nList containing multiple values: ") print(l[0]) print(l[2]) s=l[1] print("s= ",s) print("s[2] =" ,s[2]) print(len(l)) """ list = [ 'abcd', 786 , 2.23, 'john', 70.26 ] list[0]='suresh' # list is mutab...
true
995a812fcfa31f6ba0ca9b8cf48bba04e6ff1a66
codekyz/learn-algorithm
/algorithm_with_python/Doit/old/2_8.py
733
4.1875
4
# reverse sort of mutable sequence element from typing import Any, MutableSequence def reverse_array(a: MutableSequence) -> None: n = len(a) for i in range(n//2): a[i], a[n-i-1] = a[n-i-1], a[i] if __name__ == '__main__': print('reverse sort of array element') nx = int(input('enter number of ...
false
125c4341943e9781fc9ee60b35e6beb13717c4aa
peggybarley/Ch.03_Input_Output
/3.0_Jedi_Training.py
1,568
4.375
4
# Sign your name: Peggy Barley # 1.) Write a program that asks someone for their name and then prints their name to the screen? print() name = str(input("What is your name?")) print("Hello,", name,"!") print() # 2. Write a a program where a user enters a base and height and you print the area of a triangle. print(...
true
7ee6a48e8387a0d45ea82cf44b3e7b679dfcc503
kongxilong/python
/mine/chaptr3/readfile.py
341
4.3125
4
#!/usr/bin/python3 'readTextFile.py--read and display text file' #get file name fname = input('please input the file to read:') try: fobj = open(fname,'r') except: print("*** file open error" ,e) else: #display the contents of the file to the screen. for eachline in fobj: print(eachline,)...
true
6c9b1f856e9c1abb350336b26b76f48a87a9f1bb
antwork/pynote
/source/str.py
1,872
4.25
4
# encoding:utf-8 # len(str) s = 'hello China' print(len(s)) # # capitalize # Return a capitalized version of S, i.e. make the first character # have upper case and the rest lower case. print('big city'.capitalize()) # Big city #encode:utf-8 # # casefold # out: **********************value**********************...
true
42db40859935dc3bfca4f40ccb32ba90abf8e3b6
boksuh/Jump_to_Python
/02/02-3.py
970
4.1875
4
# -*- coding: utf-8 -*- """ @author: Bokyung Suh 점프 투 파이썬 """ odd = [1, 3, 5, 7, 9] a = [1, 2, 3] print(a) print(a[0]) print(a[0] + a[2]) print(a[-1]) a = [1, 2, 3, ['a', 'b', 'c']] print(a[0]) print(a[-1]) print(a[3]) print(a[-1][0]) a = [1, 2, 3, 4, 5] print(a[0:2]) print(a[:2]) print(a[2:]) a = [1, 2, 3] b ...
false
a988f35e8376fcd9c82ee7b463fab10240abb1fe
n0execution/prometheus-python
/lab3_1.py
321
4.3125
4
import sys a = float(sys.argv[1]) #a is the first argument b = float(sys.argv[2]) #b is the second argument c = float(sys.argv[3]) #c is the third argument if (a + b > c) & (a + c > b) & (b + c > a) : print("triangle") #two sides > than the other else : print("not triangle") #two sides <= than the other ...
false
8416779fee766e6ad1dbbf23bc88cdd02c7a7706
n0execution/prometheus-python
/lab5_3.py
635
4.40625
4
""" function for calculating superfibonacci numbers it is a list of whole numbers with the property that, every n term is the sum of m previous terms super_fibonacci(2, 1) returns 1 super_fibonacci(3, 5) returns 1 super_fibonacci(8, 2) returns 21 super_fibonacci(9, 3) returns 57 """ def super_fibonacci(n, m) : #chec...
true
39a3ba15e6a0fe148f4977ccb5db70ad5142e2fe
n0execution/prometheus-python
/lab7_4.py
1,866
4.34375
4
import datetime, calendar """ function for displaying definite month of definite year $ print create_calendar_page(1) '-------------------- MO TU WE TH FR SA SU -------------------- 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31' $ print create_calendar_page() '--------...
false
5cf0406aa64a6679f4aea84a4662d819dad13d4a
TaylorKolasinski/hackerrank_solutions
/strings/pangrams.py
1,122
4.3125
4
# Difficulty - Easy # Problem Statement # Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly because it is a pangram. ( pangrams are sentences constructed by using every letter of the alphabet at lea...
true
8c31f4a29804ccecb16daedd837a65ea8fd375bb
JAT117/Notes
/CSCE4910/PythonExamples/TexBoxWidget.py
827
4.25
4
#!/usr/bin/env python3 import tkinter as tk from tkinter import ttk # Create instance win = tk.Tk() # Add a title win.title("Python GUI") #Handles Button Clicked def clickMe(): #When clicked, change name of button. ...
true
ff0020378e4521727e26a70d4e1657ed17854576
Bascil/python-data-structures-code-challenge
/17.py
1,086
4.3125
4
# Dictionaries ''' Are key value pairs Are associative arrays like Java Hashmap Dicts are unordered ''' x = {'pork' : 25.3, 'beef': 33.8, 'chicken': 22.4 } print(x) x = dict([('pork', 25.3), ('beef', 33.8), ('chicken', 22.4)]) print(x) x = dict(pork = 25.3, beef = 33.8, chicken = 22.4) print(x) # Add or update x['s...
false
674c75a565efdf149d612db8fead1899d1e5336e
vedk21/python-playground
/Intermediate/OOP/Abstraction/abstraction.py
710
4.1875
4
# Abstraction (hiding the details of operation but availabling the interface open) class Car: def __init__(self, name, color, year): self.name = name self.color = color self._year = year # _ represents it understood as private member def drive(self): print('driving {self.name} a car of color {self...
true
104cc6f2a2c4044a905c748603f3998535f84b0f
taylorak/python-demo
/03-if-statement/if_statement.py
767
4.1875
4
''' Working with if-then statements ''' def if_else(correct): "Checks if correct is true or not" if correct: print("true statement") else: print("false statement") if_else(True) if_else(False) def check_nums(num1, num2): ''' Checks which number is greater ''' if num1 > n...
true
f325e2ecd71b06b20c57d57bcf31148c0d76cadf
joamho-luiz/notas-python
/cohdigo/aula07.py
782
4.1875
4
# DESAFIO 005 """n1 = int(input('Digite um número inteiro: ')) print('Antes do {} temos {} e depois o {}.'.format(n1, n1-1, n1+1))""" # DESAFIO 006 """n2 = int(input('Digite um número inteiro: ')) print('{} elevado ao quadrado é: {}.'.format(n2, n2**2)) print('{} elevado ao cubo é: {}.'.format(n2, n2**3)) print('A rai...
false
2e1e275dd7191f8b18fe73af0a8d7cde49c95289
gaurangalat/SI506
/Gaurang_DYU2.py
1,163
4.3125
4
#Week 2 Demonstrate your understanding print "Do you want a demo of this week's DYU?\nA. Yes B. Not again\n" inp = raw_input("Please enter your option: ") #Take input from user if (inp =="B" or inp =="b"): print "Oh well nevermind" elif(inp == "A" or inp =="a"): #Check Option print "\nHere are a few comic...
true
8db034fea3cc39b02329ea5246f5a526caa3f88d
Ktulu1/Learning_Python3_The_Hard_Way
/ex20-1.py
1,555
4.15625
4
# import argv from library sys from sys import argv # setup variables for argv script, input_file = argv # define a function that prints the entire contents of the file def print_all(f): print(f.read()) # define a function that seeks to the begining of the file def rewind(f): f.seek(0) # define a fuction th...
true
9f04f14496b13a8a9b851f6758bf9b0dfb62c46a
Ktulu1/Learning_Python3_The_Hard_Way
/ex16.py
1,209
4.28125
4
# load argv from the sys library from sys import argv # define variables for argv script, filename = argv # echo some text with a varaible in it print(f"We're going to erase {filename}.") print("If you don't want that, hit CTRL-C (^C).") print("If you want that, hit RETURN.") # set the prompt input("?") # echo some...
true
fdaae9577fa0821a143ca185cc1019d03bcf5202
Nathnos/probabilistic_battleships
/game/board_setup.py
1,920
4.1875
4
""" Main game functions """ import numpy as np from game.game_tools import ( get_direction, get_boat_size, get_random_direction, get_random_position, ) def can_place(grid, boat, position, direction): """ grid : numpy array boats : represented by an integer position : tuple (x, y) ...
true
221c0daa1d412fc285fd01b8386202029931e2d0
arnab-arnab/Python-Course
/06.Chapter 6/Question 4.py
211
4.15625
4
text=input("Enter the text:\n") a=len(text) print("Length is:",a) if(a<10): print("The length is less than 10") if(a>10): print("The length is greater than 10") if(a is 10): print("The length is 10")
true
f1e5cca8210d307dbe84e01717b19d11ee7298f9
arnab-arnab/Python-Course
/04.Chapter 4/Question_3.py
403
4.25
4
print("Enter three elements to be stored in tuple") a1=input("Enter the 1st element: ") a2=input("Enter the 2nd element: ") a3=input("Enter the 3rd element: ") tupl=(a1,a2,a3) print(tupl) print("Which of the element of the tuple would you try to change\n") print("0\t1\t2\n") a4=input("Enter the index value from th...
true
6002071aa47b871e3cfb4121562fcc334392ebf3
arnab-arnab/Python-Course
/05.Chapter 5/02_Dictionary_Methods.py
1,239
4.375
4
myDict={ "Fast":"In a quick manner", "Arnab":"A coder", "Marks":[1,2,5], "Li":(3,44,6), "Number": 5, "anotherDict":{"Devesh":"Doggy", "Sneha":"Bitch", "Deborshi":"Cow", "Sex_Position":69 } } # DICTIONARY METHODS pri...
true
7edb376678fb9e3a64e821b0f5fee8beab517875
arnab-arnab/Python-Course
/08.Chapter 8/03_factorial.recursion.py
585
4.375
4
''' fact=int(input("Enter the number till which you need factorial:\n")) product=1 for i in range(1,fact+1): product=product*i print(product) *****************************A NORMAL FACTORIAL PROGRAM ABOVE********************************* ''' def fact_recr(n): if(n is 1 or n is 0): return 1 return n...
false
f7ed51b9039ee4b5488431c519be8027e383b5e6
markkampstra/examples
/Python/fizzbuzz.py
1,620
4.25
4
#!/usr/bin/python # FizzBuzz by Mark Kampstra # # Write a program that prints the numbers from 1 to 100. # But for multiples of 3 print "Fizz" instead of the number and for the multiples of five print "Buzz". # For numbers which are multiple of both 3 and 5, print "FizzBuzz". # import string class FizzBuzz: '''The...
true
ea3cd26f2804b5ac8850ea448d8dcb23f9e1cca9
dbozic/useful-functions-exploration
/column_unique_values.py
1,252
4.71875
5
def column_unique_values(data, exclusions): """ This function goes through each column of a dataframe and prints how many unique values are in that column. It will also show what those unique values are. The function is particularly useful in exploratory data analysis for quick understandi...
true
ae172af54bc2698ce83bedd94416e22847593e60
QkqBeer/PythonSubject
/面试练习/29.py
1,205
4.1875
4
# __author__ = "那位先生Beer" # # # def divide( dividend, divisor ): # """ # :type dividend: int # :type divisor: int # :rtype: int # """ # flag = 0 # dividendn = abs( dividend ) # divisorn = abs( divisor ) # while dividendn > 0: # if dividendn >= divisorn: # dividen...
false
69c059b8b6f1f9665fa8857a9e039c5bb4ba2c45
mengbinsu/Core_Python_Programming
/ch6/Exam/6.3.py
638
4.34375
4
#!/usr/bin/env python import string def des_sort_numstr_by_decimal(numstr): numlist = numstr.split(',') for i in range(0, len(numlist)): numlist[i] = int(numlist[i]) numlist.sort() numlist.reverse() return numlist def des_sort_numstr_by_dictionary(numstr): numlist = numstr.split(',') ...
false
2d00ae0f6dae836d393953e41555dd6b9d130f7a
anhnguyendepocen/Python_learning
/mypolygon.py
986
4.28125
4
#!/usr/bin/python # Filename:mypolygon.py from swampy.TurtleWorld import * import math world = TurtleWorld() bob = Turtle() print bob def square(t, dist): for i in range(4): fd(t,dist) lt(t) bob.delay = 0.01 def polygon(t, dist, n): for i in range(n): fd(t,dist) lt(t, 360.0/...
false
45af716bb44964e643e8bf989626a735719dbdca
judyohjo/Python-exercises
/Python exercise 12 - List.py
396
4.3125
4
''' Exercise 12 - Get the smallest number from each list and create a new list and print that new list. ''' list1 = [1, 3, 5, 0, 2, 3] list2 = [3, 5, 3, 56, 7, 22] list3 = [67, 34, 24, 15, 88, 99] newlist = [] smallest1 = min(list1) smallest2 = min(list2) smallest3 = min(list3) newlist.append(smallest...
true
fbaf080f19aea0424908dfa870cf4213753b719a
judyohjo/Python-exercises
/Python exercise 11 - Input.py
209
4.21875
4
''' Exercise 11 - Input a number and print the number of times of "X" (eg. if number is 3, print... X XX XXX) ''' num = int(input("Input a number: ")) for i in range(1, num+1): print(i*"X")
true
a05605bc741df904178fa79706fc90b7bedd50bf
schappidi0526/IntroToPython
/20_IterateOnDictionary.py
811
4.65625
5
grades={'Math': 100, 'Science': 80, 'History': 60, 'English': 50} grades['Biology']=70 #To print just keys for key in grades: print(key) #To print keys along with their values for key in grades: print(key,grades[key]) for key in grades.keys(): print(key,grades[key]) ...
true
eb63068b4b356aa525322e418921c6b23f681c6b
schappidi0526/IntroToPython
/22_Update&DeleteDictionary.py
1,088
4.3125
4
#Merge/Update dictionary dict1={'Math':99, 'science':98, 'history':33} dict2={'telugu':88, 'hindi':77, 'english':99, 'Math':69}#If you have same keys in both dictionaries,values will be updated dict1.update(dict2) print (dict1) dict2.update(dict1) print(sorted(...
true
9a403dad3118c5410b09b4969f8e2ff2f7fb41f1
problems-forked/Dynamic-Programming
/0_1 Knapsack/Programmes/main(14).py
1,149
4.15625
4
def find_target_subsets(num, s): totalSum = sum(num) # if 's + totalSum' is odd, we can't find a subset with sum equal to '(s + totalSum) / 2' if totalSum < s or (s + totalSum) % 2 == 1: return 0 return count_subsets(num, int((s + totalSum) / 2)) # this function is exactly similar to what we have in 'C...
true
e8394e8222e225d194d080a264743172b11a28b9
Rhapsody0128/python_learning
/base/03.for.py
383
4.25
4
students=["bonny","jack","rose"] for student in students : print(student) print("hello !") # 建立一個students串列 # 告知python從students串列中取出名字,並將取出的名字存到student變數內 # 印出student變數取到的名字 # 跳出迴圈並印出hello # *迴圈內執行的東西要記得縮排,若不是迴圈內要執行的東西則不用縮排 !
false
1e9c999f99c01c8289e891f0abc516ce901213b4
Rhapsody0128/python_learning
/base/08.input.py
1,377
4.5
4
# input()函式會讓程式暫停,等待使用者輸入一些文字,python在取得使用者輸入文字後,會把我們輸入的文字存到一個變數內 # * 一般的input()函式 name = input("please enter your name : ") print("hello,"+name) # 因為name是字串所以可以直接跟"hello,"字串相加f # * 用int()來取得輸入的字串 age = input("how old are you ?") # 使用者輸入的東西都算是字串 age = int(age) # 將age變數轉成int的型態再傳回age變數中 if age >= 20 : # age變數轉為數值後才可以比...
false
5e98df340cc93a5c839aea8ca82a91c09ed83d3f
dwangnew/euler
/9.py
1,270
4.1875
4
# Special Pythagorean triplet # Problem 9 # A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. import math # while a+b+c <= 1000...
false
6e6b8dbcdd7d5cbfef4c7ae9005cbd2639671f18
fanliu1991/LeetCodeProblems
/38_Count_and_Say.py
1,473
4.21875
4
''' The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n, generate the n-th term of the count-and-say sequen...
true
da22091944898edbfca31ed8919e568a6802d8ec
fanliu1991/LeetCodeProblems
/75_Sort_Colors.py
2,115
4.28125
4
''' Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note: You are not suppose to use the ...
true
0cd58414e3ad8e23d1532ba3509d4e005d9f5cf0
fanliu1991/LeetCodeProblems
/89_Gray_Code.py
1,833
4.25
4
''' The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. For example, given n = 2, return [0,1,3,2]. Its gray code sequence...
true
5a81227b5affe10bfea4b5acabb0dcea57f9ec68
fanliu1991/LeetCodeProblems
/125_Valid_Palindrome.py
1,278
4.1875
4
''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false ''' imp...
true
97de3552794dbc0e04be28659349f09d415702ba
fanliu1991/LeetCodeProblems
/101_Symmetric_Tree.py
2,889
4.25
4
''' Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). Example 1: input: binary tree [1,2,2,3,4,4,3] output: True 1 / \ 2 2 / \ / \ 3 4 4 3 Example 2: input: binary tree [1,2,2,null,3,null,3] output: False 1 / \ 2 2 \ \ 3 3 ''' import ...
true
c95cc386832630e4fee7e56c2ec320cc4abd0978
Darya1501/python
/Раздел 7. Минимумы и максимумы.py
1,663
4.125
4
print("Раздел 7. Минимумы и максимумы") print("Задача 6. Дано целое число N и набор из N целых чисел. Найти номера первого минимального и последнего максимального элемента из данного набора и вывести их в указанном порядке.") print("Решение: ") s = int(input("Введите размер массива: ")) a = [0]*s print("Введит...
false
97d3deb5ca9a1c43dc506e2844df03243be31ffb
mmxm0/IP_Listas_SI1
/locadora_antes_da_Netflix.py
2,379
4.125
4
""" 2 - Houve uma época em que, quando as pessoas queriam assistir um filme, iam até a locadora. Crie uma classe filme que contém os atributos gênero, nome, disp_catalogo. Você deve criar um método que altere a disponibilidade do filme, gets e sets. Em seguida crie uma classe Locadora, essa classe contém uma lista...
false
d0c942747f97ffb0f6f506614ccd7ee46c1caa69
mmxm0/IP_Listas_SI1
/9.py
310
4.34375
4
''' Reverso do número. Faça uma função que retorne o reverso de um número inteiro informado. Por exemplo: 127 -> 721. ''' def reverseNumber(n): n = str(n) return n[::-1] n = int(input("Informe o numero: ")) reverso = reverseNumber(n) print("O reverso do numero informado é:", reverso)
false
a121b4284049a34674c5239c4f487e87381a4234
mmxm0/IP_Listas_SI1
/Listas_9.py
777
4.3125
4
from random import randint '''Faça um programa que crie uma matriz aleatoriamente e guarde em uma lista. As dimensões da matriz deverão ser informadas pelo usuário. O programa deverá imprimir a matriz criada na tela, no formato m x n. Ex: Matriz = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Exibir na tela: 1 2 3 4 5 6 7 ...
false
25b9a16a37807b7edc6392f0227ed06a19bcd556
mmxm0/IP_Listas_SI1
/Jogo_de_Craps.py
2,012
4.1875
4
''' Jogo de Craps. Faça um programa de implemente um jogo de Craps. O jogador lança um par de dados, obtendo um valor entre 2 e 12. Se, na primeira jogada, você tirar 7 ou 11, você um "natural" e ganhou. Se você tirar 2, 3 ou 12 na primeira jogada, isto é chamado de "craps" e você perdeu. Se, na primeira jogada...
false
6bbff894065548d6faf0552fc9b149e8146cb8cb
mmxm0/IP_Listas_SI1
/funcao_embaralhaPalavra.py
675
4.3125
4
'''Embaralha palavra. Construa uma função que receba uma string como parâmetro e devolva outra string com os carateres embaralhados. Por exemplo: se função receber a palavra python, pode retornar npthyo, ophtyn ou qualquer outra combinação possível, de forma aleatória. Padronize em sua função que todos os caracteres...
false
14f5a244dc9462b2e9beda153b8e0b8145d904a5
yusheng88/RookieInstance
/Rookie039.py
832
4.40625
4
# -*- coding = utf-8 -*- # @Time : 2020/6/23 22:52 # @Author : EmperorHons # @File : Rookie039.py # @Software : PyCharm """ https://www.runoob.com/python3/python3-array-rotation.html Python 数组翻转指定个数的元素 例如:(ar[], d, n) 将长度为 n 的 数组 arr 的前面 d 个元素翻转到数组尾部。 """ import pysnooper @pysnooper.snoop() def leftRotate(arr, d, n)...
false
f4ec75527a590154109325705c90c9192b834349
caianne/mc102
/labs/lab20.py
984
4.125
4
# Laboratorio 20 - Sudoku # Funcao: print_sudoku # A funcao imprime o tabuleiro atual do sudoku de forma animada, isto e, # imprime o tabuleiro e espera 0.1s antes de fazer outra modificacao. # Voce deve chamar essa funcao a cada modificacao na matriz resposta, assim # voce tera uma animacao similar a apresentada no ...
false
5c4c4b8c30d09c8a7163d24ff3030fa4b3e0ce34
Shehu-Muhammad/Python_College_Stuff
/Problem4_CupcakeRequest.py
459
4.125
4
# Shehu Muhammad # Problem 4 -Requests the number of cupcakes ordered and displays the total cost # May 7, 2018 orders = int(input("What are the total number of cupcake orders? ")) cost = 0 small = 0.75 large = 0.70 if(orders <= 99 and orders>=1): cost = cost + (orders*small) elif(orders >= 100): cost = cost +...
true
52f5d2791e39104aba5f6cfcc90a29eac4d8a693
Shehu-Muhammad/Python_College_Stuff
/Python Stuff/Rowing.py
543
4.28125
4
#Rowing Program #Shehu Muhammad #February 5, 2018 rower1 = int(input("Input weight of rower one: ")) rower2 = int(input("Input weight of rower two: ")) weight = rower1 + rower2 #if((weight >= 300) and (weight <=400)): #print("You are on the team") #else: #print("You are not on the team") #if((weight >= 300...
false
05228bb597c8d13f1e2e6427a2a307e0abf2ee02
Shehu-Muhammad/Python_College_Stuff
/Python Stuff/Guess.py
1,156
4.125
4
# Guess my number # Shehu Muhammad import random import math random.seed() randomNumber = math.floor(random.random() * 100) + 1 # generates a random number between 1 and 100 guess = 0 # initializes guess to zero count = 0 # initiali...
true
5a1e50c525e772ece7944a9c7609ac8cb5ad79bb
CoderDojoNavan/python
/basics/4_inputs.py
985
4.125
4
"""4: Inputs""" # Sometimes you might want to ask the user a question. To do that, we use # a special function called `input`. Functions are covered in `5-functions.py`. # You can ignore the # pylint comment, it is there to tell tools which analyze # the code that in fact everything is OK with this line. days = 365 ...
true
78b7f69d1513f3d252d07e30f3970be2beec094b
benjaminhuanghuang/dl-study
/keras_first_network.py
2,038
4.78125
5
''' Develop Your First Neural Network in Python With Keras Step-By-Step https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/ The steps you are going to cover in this tutorial are as follows: Load Data. Define Model. Compile Model. Fit Model. E...
true
2265d032ca4fc7148a6ff610e6fdd3d095484c5f
charukiewicz/Numerical-Methods
/convergence.py
1,501
4.125
4
# -*- coding: utf-8 -*- """ @author: Christian Charukiewicz (netid: charuki1) This compares the rates of convergence between the Newton and Secant methods. The program will print output values and display a plot in matplotlib. More info: - http://en.wikipedia.org/wiki/Newton's_method - http://en.wi...
true
23ce65dc8e50e30045618ac6514ec174dd470e53
UskovaKate/Coursework
/2-я часть/3.py
630
4.125
4
#Создать прямоугольную матрицу A, имеющую N строк и M столбцов со случайными элементами. #Найти наименьший элемент столбца матрицы A, для которого сумма абсолютных значений элементов максимальна. import numpy as np N = 6 M = 2 A = np.random.randint(low=-4, high=9, size=(N, M)) print("Матрица:\r\n{}".format(A)) sum =...
false
290f471ddd312bbc70a62082ff334b20ae88f0e0
UskovaKate/Coursework
/2-я часть/2.py
588
4.15625
4
#Создать прямоугольную матрицу A, имеющую N строк и M столбцов со случайными элементами. #Найти наибольшее значение среди средних значений для каждой строки матрицы. import numpy as np N = 6 M = 2 A = np.random.randint(low=-4, high=9, size=(N, M)) print("Матрица:\r\n{}".format(A)) Average = A.mean(axis=1) index = Av...
false
de96cc585410c8356590a971bd86505045a03f9e
azrlzhao/password-safty-check-
/check_password.py
1,724
4.125
4
#Password security check code # # Low-level password requirements: # 1. The password is composed of simple numbers or letters # 2. The password length is less than or equal to 8 digits # # Intermediate password requirements: # 1. The password must consist of numbers, letters or special characters (only: ~!@#$%...
true
ab7b5ff8e907d45ef3cfbec2bb611ada3b68058d
daninick/test
/word_count.py
1,318
4.375
4
import re filename = input(''' This program returns the words in a .txt file and their count in it. Enter a .txt file name: ''') f = open(filename, 'r') # Read the file and convert it to a string text = f.read() # Ignore the empty lines text = text.replace('\n', ' ') # All words in the text are separated by spac...
true
c38e0d609c3414396e23f7ae50b2bf4695477eb6
rrotilio/MBA539Python
/p20.py
482
4.15625
4
validInt = False def doRepeat (str1,int1): i = 0 while (i < int1): print(str1) i = i + 1 print("I like to repeat things.") varStr = str(input("What do you want me to repeat?: ")) while not validInt: try: varInt = int(input("How many times should I repeat it?: ")) if(varInt < 0): print("I can't repeat ...
true
856f36bd79f0866552aa760bd9cea652ee4cfdbb
dwzukowski/PythonDojo
/funwithfunctions.py
2,051
4.625
5
def multiply(list, num): newList = [] for val in list: newList.append(val*num) return newList #we declare a function called layered_multiples which takes one parameter arr def layered_multiples(arr): #we declare a variable called new_array which is an empty list new_array = [] #we insta...
true
a03dbd25a62938ef0ed68df80d0df1df9983125e
dwzukowski/PythonDojo
/comparingArrays.py
1,379
4.3125
4
#we declare a function called compareArrays which takes two parameters, list one and list two def compareArrays(list_one, list_two): #we delcare a variable answer which is string answer = "" #we compare the lengths of teh two lists; if they are not equal the list cannot be the same if len(list_one) != l...
true
d1f1d9a4d2a03bab8643fb8c00c5dcccf7b1462a
dwzukowski/PythonDojo
/classesIntroBike.py
2,318
4.75
5
#we declare a class called bike class Bike(object): #we set some instance variables; the miles variable will start at zero for every instance of this class def __init__(self, price, max_speed): self.price = price self.max_speed = max_speed self.miles = 0 #we declare a method called ...
true
7654c068f8136a957fd0f17a00f00c130c0af639
dwzukowski/PythonDojo
/typeList.py
1,091
4.34375
4
#we declare a function called typeList that takes one paramater, list def typeList(list): newStr = "" sum = 0 #instantiate a for loop for i in range(0,len(list)): if isinstance(list[i], int): sum+=list[i] elif isinstance(list[i], float): sum+=list[i] ...
true
9b9c1fc50ec7de95e4a841f0ae7127678f242e35
EduardoZortea18/PythonExercises
/ex008.py
305
4.125
4
distance = int(input('Type some distance in meters: ')) print('The distance of {} meters is equal to: \n' '{}km \n' '{}hm \n' '{}dam \n' '{}dm \n' '{}cm \n' '{}mm \n'.format(distance, distance/1000, distance/100, distance/10, distance*10, distance*100, distance*1000))
false
8e662865c92c45a66ab05eb834ac525f87863c30
19h61a0507/python-programming-lab
/strpalindrome1.py
205
4.375
4
def palindrome(string): if(string==string[::-1]): print("The string is a palindrome") else: print("Not a palindrome") string=input("enter the string") palindrome(string)
true
bdb456492eb7c89a11f0528f2fa631e76f353031
peiyong-addwater/2018SM2
/2018SM2Y1/COMP90038/quizFiveSort.py
2,748
4.28125
4
def insertionSort(arr): assignment = 0 # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] assignment = assignment +1 # Move elements of arr[0..i-1], that are # greater than key, to one position ahead # of their current position j = ...
true
2113e0f5ecdfabd6c6758fd5989e5b69a7529d3d
moritz2104/LPTHW
/ex07.py
717
4.125
4
print "Mary had a little lamb." # output a string print "Its fleece was white as %s." % 'snow' # outputs a string with a format string --> wie geht das in python 3 ??? print "And everywhere Mary went." print "." * 10 # what'd that do? print "_" * 80 # what'd that do? Na ist doch klar! end1 = "C" end2 = "H" end3 = "E"...
false
9b1f7b2a6b5cf52bd6406563714300f1e32d1f3d
crazywiden/Leetcode_daily_submit
/Widen/LC543_Diameter_of Binary_Tree.py
1,564
4.25
4
""" 543. Diameter of Binary Tree Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. Example: Given a binary tree 1 / \ ...
true
83163acd94774048c6ed331b41da1d5bb8a904ca
crazywiden/Leetcode_daily_submit
/Widen/LC376_Wiggle_Subsequence.py
1,871
4.25
4
""" A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence. For example, [1,7,4,9,2,...
true
628f8ab619e1460c897cdacfb238dd69b0cb94eb
crazywiden/Leetcode_daily_submit
/Widen/LC394_Decode_String.py
1,811
4.15625
4
""" 394. Decode String Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; No extra ...
true
a953d20e0094da3a509afd7ae9a8cda33aeee6cf
crazywiden/Leetcode_daily_submit
/Widen/LC408_Valid_Word_Abbreviation.py
2,325
4.1875
4
""" 408. Valid Word Abbreviation Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains only the following valid abbreviations: ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r...
true
7b98a0b5d9e81cc2d8fc1aca7e1e6e26dd164eae
crazywiden/Leetcode_daily_submit
/Widen/LC71_Simplify_Path.py
1,287
4.28125
4
""" 71. Simplify Path Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path. In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level. For more information, see: Absolute path vs r...
true
94ddc5ac813e101d378660e725d8cf258418e701
elle-johnnie/Arduino_Py
/PythonCrashCourse/fizzbuzz.py
762
4.1875
4
# fizzbuzz in Python 2.7 ## # I just heard about this at a local meetup - thought I'd give it a go. # The rules: # Write a program that prints the numbers from # 1 to 100. But for multiples of three print Fizz instead of the number and for the multiples of five print # Buzz. For numbers which are multiples of both thre...
true
6a26ef4cc53b955a98306b03c895c19e94264020
elle-johnnie/Arduino_Py
/edX_CS_exercises/number_guess_bisect.py
988
4.3125
4
# The program works as follows: you (the user) thinks of an integer between 0 (inclusive) and 100 (not inclusive). # The computer makes guesses, and you give it input - is its guess too high or too low? Using bisection # search, the computer will guess the user's secret number! # edX wk 2 Algorithms # solution attempt ...
true
fd22c3cadbc5f3c79b997c118b6a62b0adebd935
AbnerErnaniADSFatec/Python-Codes
/Abner Ernâni dos Anjos - ADS Turma A - Lista de Exercícios 2/Exercício 4 e 5.py
889
4.15625
4
a= int(input('Digite o 1º número: ')) b= int(input('Digite o 2º número: ')) c= int(input('Digite o 3º número: ')) if a > c and a > b: print('O maior número é o 1º número, %d.' %a) if b > a and b > c: print('O maior número é o 2º número, %d.' %b) if c > b and c > a: print('O maior número é o 3º númer...
false