blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
eac159ff8c50faa733d1ecba742828e1eac76858
Mr-OMD/bz304-system-programming-midterm
/ikinci.py
1,355
4.28125
4
#1030530259 #ÖMER MERT DEMİREL print("Çeviriciye Hoşgeldin!") veri=input("\nLütfen yazınız: ") #takes input from user print(yazi:="\nverinin uzunluğu", len(veri), "birim") #with help of WALRUS operator we can calculate lenght in print secenek=input("\nveriyi neye dönüştürmek istersiniz?(LÜTF...
false
561f8099654f1753fcf261095177d7b599aae3ea
bmoretz/Daily-Coding-Problem
/py/dcp/problems/dynamic/staircase.py
1,115
4.4375
4
'''Number of ways to climb a staircase. There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. For example, if N is 4, then there are 5 unique ways: 1, 1,...
true
fd30b62e24e537c9d9aecda7c5684e2a48bae4a6
bmoretz/Daily-Coding-Problem
/py/dcp/leetcode/linkedlist/deep_copy_random.py
2,173
4.125
4
''' 138. Copy List with Random Pointer. A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. The Linked List is represented in the input/output as a list of n nodes. Each node is represented as a pair of [...
true
d86beb66b939aef66b3dda13f1c67910396c4284
bmoretz/Daily-Coding-Problem
/py/dcp/leetcode/matrix/diagonal_traverse.py
1,070
4.125
4
''' 498. Diagonal Traverse. Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,4,7,5,3,6,8,9] Explanation: Note: The total number of elements of the gi...
true
7f9c125e8e64b1db69cd0725ff1ab8a5d70e385a
bmoretz/Daily-Coding-Problem
/py/dcp/problems/recursion/triple_step.py
1,034
4.28125
4
""" Triple Step. A child is running up a staircase with n steps and can hop either 1 step, 2 steps or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs. """ def triple_step1(n): def triple_step(n): if n < 0: return 0 if n == 0: ...
true
b3c7f5e853458690c0528815b3dcf4b763569829
bmoretz/Daily-Coding-Problem
/py/dcp/problems/math/rand_5n7.py
1,391
4.3125
4
""" Rand7 from Rand5. Implement a method rand7() given rand5(). That is, given a method that generates a random number between 0 and 4 (inclusive), write a method that generates a random number between 0 and 6 (inclusive). """ from random import randrange def rand5(): return randrange(0, 5) """ rand7 1 simple ...
true
3e2b3173d94ca20e83dadb4dea98d4b181823e5e
bmoretz/Daily-Coding-Problem
/py/dcp/problems/stack_queue/queue_of_stacks.py
747
4.21875
4
""" Queue of Stacks. Implement a MyQueue class which implements a queue using two stacks. """ from .stack import Stack class my_queue1(): def __init__(self): self.data = Stack() self.top = None def enqueue(self, item): if item is None: return self.data.push(item) if self.top ...
true
38a0300e0534dafcde09dbb4aadc78d83aa3f576
astikagupta/HW04
/HW04_ex08_12.py
442
4.25
4
# Structure this script entirely on your own. # See Chapter 8: Strings Exercise 12 for guidance # Please do provide function calls that test/demonstrate your function def rotate_word(x,y): for i in x: z = ord(i) w = z+y print chr(w), def main(): x = raw_input("enter the string:") y = int(raw_input("en...
true
f7c7428ea359a51853286191f0a33900cfcb1a98
marshall159/travelling-Salesman
/cities.py
2,514
4.1875
4
def read_cities(file_name): # no unit tests """ Read in the cities from the given `file_name`, and return them as a list of four-tuples: [(state, city, latitude, longitude), ...] Use this as your initial `road_map`, that is, the cycle Alabama -> Alaska -> Arizona -> ... -> Wyoming...
true
247d50c60eaf082d50dc124c9383cf8ed3af9be0
1666202295/test
/knowledge/python_map.py
1,635
4.28125
4
# python 中的字典 相当于java中的map 数据结构为key-values # 保存加菲猫的信息并进行存取操作 # 数组使用大括号声明 格式为{"key":"value","key":"value"...} 相当于json myCat = {"name": "Garfield", "color": "orange", "size": "fat"} # 取值使用 中括号 包裹key的形式 print("My cat's name is :", myCat["name"]) # 通过 中括号 包裹key = value 进行字典的赋值 myCat["city"] = "Xiamen" print(myCat) # 修...
false
408fe1cb12b633f09f4a21b8801c678c5f3b021c
verilogtester/pyalgo_love
/TREE_traversal_Iterative_approach.py
2,371
4.34375
4
# Python program to for tree traversals (This is Iterative Approach) # A class that represents an individual node in a # Binary Tree class Node: def __init__(self,key): self.left = None self.right = None self.val = key # A function to do inorder tree traversal # def iter_printInorde...
true
0bd775286b5335f1ff414be9f32c36cb95a08a89
gopinathrajamanickam/PythonDS
/isAnagram.py
940
4.125
4
# Validate Anagram # given two strings as input Check if they can be considered anagrams # i.e the letters in those stringss to be rearranged to form the other def isAnagram(str1,str2): # if the letter freq count is same for given strings it can be called anagrams result = 'Not Anagrams' freq_dict = {} ...
true
a45e3ad473e925a83e631efb7890d5b952de5120
njgupta23/LeetCode-Challenges
/array/rotate-arr.py
601
4.125
4
# Rotate Array # Given an array, rotate the array to the right by k steps, where k is non-negative. # Example 1: # Input: [1,2,3,4,5,6,7] and k = 3 # Output: [5,6,7,1,2,3,4] # Explanation: # rotate 1 steps to the right: [7,1,2,3,4,5,6] # rotate 2 steps to the right: [6,7,1,2,3,4,5] # rotate 3 steps to the right: [5,...
true
2d3f1e2d5077308ba207b3a2334863a3a97240e7
hostjbm/py_gl
/T2. OOP/Class decorator/func_decoratoration_by_class.py
508
4.21875
4
# Basic example of decorator defined by class class decorator(): def __init__(self, func): print(10) self.func = func def __call__(self, *args): print('Called {func} with args: {args}'.format( func=self.func.__name__, args=args)) print(self, args) return sel...
true
efadbaf73428bcfd21f780a19e642b166187c8d7
Maulik5041/PythonDS-Algo
/Recursion/power_of_a_number.py
219
4.375
4
"""Power of a number using Recursion""" def power(base, exponent): if exponent == 0: return 1 else: return base * power(base, exponent - 1) if __name__ == '__main__': print(power(2, 3))
true
2669d1f73ba380e65ae02213e498b1c4933325c7
Maulik5041/PythonDS-Algo
/Interview Prep 1/Stacks, Queues and Deques/queue_implementation.py
731
4.3125
4
"""Implement a Queue""" class Queue: def __init__(self): self.queue = [] def size(self): return len(self.queue) def is_empty(self): return self.size() == 0 def enqueue(self, data): self.queue.insert(0, data) def dequeue(self): if self.is_empty(): ...
false
7d9d43833516f1d63cac72274c64df2f2eed1a53
poojamadan96/code
/function/factUsingRecursive.py
219
4.375
4
#factorial using recursive function = Fucntion which calls itself num=int(input("Enter no. to get factorial ")) def fact(num): if num==1: return 1 else: return num*fact(num-1) factorial=fact(num) print(factorial)
true
4c674205b17034de9aceb8207607ad0e06e4ac6a
ssilverch/study
/pythonProject/day7/test4.py
666
4.1875
4
def main(): list1 = ['orange','apple','zoo','internationalizetion','blueberry'] list2 = sorted(list1) #sorted函数返回列表排序后的拷贝不会修改传入的列表 #函数的设计就应该想sorted函数一样尽可能不产生副作用 list3 = sorted(list1,reverse=True) #通过key关键字参数指定根据字符串长度进行排序而不是默认的字母表顺序 list4 = sorted(list1,key=len) print(list1) print(lis...
false
8488fe451236b0a386f4a6b27d9908d5ecd27f74
VPoint/PythonExperiments
/Labs/Labo2.py
1,461
4.125
4
from math import sqrt #################### Excercise 1 ########################## print ("*************Division des entiers*************") x = int(input("Taper un nombre: ")) y = int(input("Et un autre: ")) print("Le division de", x, "par", y, "est", x//y, "avec", x%y,"qui reste.") #################### Excercise 2 ##...
false
89e7001639f286cbf0b2548e6d9f305014c34da7
Sammybams/30-days-of-code-Intermediate-May
/Day 7.py
1,409
4.34375
4
def my_cars(array): """ You come to the garage and you see different cars parked there in a straight line. All the cars are of different worth. You are allowed to choose any amount of cars and they will be yours. The only condition is that you can't select 2 cars that are parked beside each other. ...
true
f247b7b39e29eb00ccec00eff7350942bce88bbf
lucianahb/marketplace-tech-start
/.vscode/20.12.04/poo-basico.py
1,054
4.15625
4
class Pessoa: nome = 'luciana' sobrenome = 'barbosa' idade = 25 #quando quero que outras pessoas usem minha classe #devo criar uma variável pra ela p = Pessoa() print(p) #só que assim só vai pegar onde tá na memória, então: print(p.nome) print('...............\n') #Maaaas, por padrão, não defino valores pr...
false
f981a1ee2c36b151e2834ec47d8d97069c536991
rithwikgokhale/SimpleCalculator
/PA1_Question1.py.py
1,042
4.1875
4
#Python Script to solve quadratic equations and give the solutions print ("Quadratic Equations: ax^2+bx+c = 0") a = int(input("Enter the coefficients of a: ")) b = int(input("Enter the coefficients of b: ")) c = int(input("Enter the coefficients of c: ")) d = b**2-4*a*c # this is the discriminant for the enter...
true
28c4462f2efdd143096fb430d96ac12ba94af4f0
JoshKallagunta/ITEC-2905-Lab-1
/Lab1.py
276
4.28125
4
name = input("What is your name? ") birthMonth = input("What month were you born?") print("Hello " + name + "!") count = len(str(name)) print("There are " + str(count) + " characters in your name!") if birthMonth == "August": print("Happy birthday month!") else: ""
true
74f94a7bdd8d2ab3d45348c299f6cd1f0aa97e50
carpepraedam/data_structures
/sorting/Bubble_Sort/python/bubble.py
1,256
4.15625
4
def comparator(val_a, val_b): """ Default comparator, checks if val_a > val_b @param {number} val_a @param {number} val_b @return {bool} : True if val_a > val_b else False """ return val_a > val_b def bubble(l, comparator=comparator): """ Bubble sort a given list @param {list} ...
true
db56a2db15dd354a3e2b832f7be1887d2b139433
Donal-Murphy/EP305-Computational-Physics-I
/Labwork/cone_area(5_3_19)/cone_area.py
1,493
4.40625
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 5 14:04:56 2019 @author: Donal Murphy Description: returns the surface area of a cone given its height and radius """ #this program calculates the surface area of a cone given the radius and height import numpy as np #needed for pi #------------------...
true
06e04411c77035b2330f2a17f7ad5e17a3f04a33
mfjimenezmoreno/eLOAD_Bipotentiostat
/Python app/SortingTuples.py
268
4.21875
4
c = {'a':10,'b':1,'c':22} #A supercompressed way to sort a dictionary by highest values #items returns keys and values as tuples, then the for iteration flips the tuples value/key, and finally sorted function takes place print(sorted([ (v,k) for k,v in c.items() ]))
true
6c933cbcfe6e2d9906565bf68e69e89c1cb4c5dd
k8thedinosaur/labs
/weather.py
2,410
4.25
4
# # Lab: PyWeather # # Create a program that will prompt a user for city name or zip code. # Use that information to get the current weather. Display that information # to the user in a clean way. # ## Advanced # # * Also ask the user if they would like to see the results in C or F. import requests package = { "A...
true
982dec507c2d8ca14d0ed5f664c84cd716642019
k8thedinosaur/labs
/dice.py
1,414
4.53125
5
# # Lab: Dice # ##### Goal # Write a simple program that, when run, prompts the user for input then prints a result. # ##### Instructions # Program should ask the user for the number of dice they want to roll as well as the number of sides per die. # #### Documentation # 1. [Compound statements](https://docs.python.org...
true
ab8e9333def4ba513e483f127020ff6941a8afcb
bj1570saber/muke_Python_July
/chapter_4_data_structure/4-1-basic_list_tuple.py
1,496
4.3125
4
#List example: students= ['Jerry','Tom','Adm',10, True] print(students) print('students[0]:%s' %(students[0])) # Jerry print('students[-1]:%s' %(students[-1]))#True print('students[-2]:%s' %(students[-2]))#10 students.append('Jack')#append() print('students[-2]:%s' %(students[-2]))#True print(students)# ['Jerry', 'Tom'...
false
4d3032fabf76ce4f7fc4eb1b7467b811ec879d8b
wendeel-lima/Logica-de-Programacao
/15-06/listas.py
2,642
4.5
4
# Lista é uma variável composta assim como as tuplas, porém com algumas diferenças, vamos ver as caracteristicas de uma lista em python: # Ao invés de serem representadas com (), são representadas com [] lista = [1,2,3,4] print(lista) # Para criar uma lista vazia, faça: vazia_um = [] # ou vazia_dois = list() # A...
false
5ab59ee03b72e01cfea5efdd98fe3afce1e7594e
wendeel-lima/Logica-de-Programacao
/16-06/ex01lista.py
1,758
4.375
4
# 01 - Dada a lista l = [5, 7, 2, 9, 4, 1, 3], escreva um programa que imprima as seguintes informações: #l = [5, 7, 2, 9, 4, 1, 3] # # a) tamanho da lista. # print(f"O tamano da lista é de {len(l)} posições") # # b) maior valor da lista. # print(f"O Maior valor da lista é: {max(l)} ") # # c) menor valor da lista. # p...
false
3a028d9759a1129eac81d21d78ed4e753487763e
yenext1/python-bootcamp-september-2020
/lab5/exercise_5.py
1,059
4.21875
4
print("Lets make a Arithmetic Progression!") a1 = int(input("Choose the first number (a1)")) d = int(input("Great! choose the number you and to add (d)")) n = int(input("How many numbers should we sum? (n)")) sum = (n/2)*(2*a1+(n-1)*d) print(f" The sum of the numbers in the serie is {sum}") """ Uri's comments: =====...
true
ebc1c450857f3035e6129f58627a982dfffa224f
JaromPD/Robot-Finds-Kitten-Project
/rfk/game/shared/point.py
1,943
4.4375
4
class Point: """A distance from a relative origin (0, 0). The responsibility of Point is to hold and provide information about itself. Point has a few convenience methods for adding, scaling, and comparing them. Attributes: _x (integer): The horizontal distance from the origin. _y (in...
true
af932265190463ccbfc52464566f72485309411f
patvdc/python
/01-basics/06-functions/10_lambda.py
442
4.46875
4
print("lambda +") x = lambda a : a + 10 print(x(5)) print("lambda *") x = lambda a, b : a * b print(x(5, 6)) print("lambda +") x = lambda a, b, c : a + b + c print(x(5, 6, 2)) # usage in another function (nested function) print("nested lambda using lambda double") def multiply(n): return lambda a: a * n double=...
true
d56e4c53f4e447580df9fef8b4316aeee3b89148
liugongfeng/CS61A
/mentor03.py
834
4.25
4
### Question 3 """Given some list lst, possibly a deep list, mutate lst to have the accumulated sum of all elements so far in the list. If there is a nested list, mutate it to similarly reflect the accumulated sum of all elements so far in the nested list. Return the total sum of lst. Hint: The isinstance function ...
true
98ca46e5fe4de5e72d047032373e0399f89c3c4a
lcc19941214/python-playground
/src/basic/character.py
1,252
4.15625
4
# coding=utf-8 # Normal Input print(100) print(3.1415926897) print('100') print('hello') print('你好') print(u'你好'.encode('utf8')) print('line 1\nline 2') print(r'line 1\n line 2') # method `u` means to describe an unicode symbol # method `r` means not to excape the code # ASCII print(ord('A')) print(chr(65)) # lengt...
false
694a88042531009e706c7524edf0d5aa33152b3d
lcc19941214/python-playground
/src/features/iteration.py
1,372
4.21875
4
# coding=utf-8 from collections import Iterable ''' list这种数据类型虽然有下标,但很多其他数据类型是没有下标的\ 但是,只要是可迭代对象,无论有无下标,都可以迭代,比如dict就可以迭代 ''' # iterate a dict print('\n# iterate a dict') d = {'name': 'Lily', 'age': 25} for key in d: print('dict d has a property %s and its value is %s' % (key, d.get(key))) # detect wether an ob...
false
54d5983b9ea33ecd84e16af3e5f41bcd569bd798
devmohit-live/Prep
/Maths/prime_numbers_inRange.py
951
4.1875
4
import math def primeNumer(n) -> list: ''' Sieve Of Erathosthenes Algorithm to find numers within the range are prime or not, here we just jump to the next multiples of the current number in an array and make it False, we explicitly make the 0 and 1 False, this alogorithm help us to solve this O(N) task in ...
true
2bc921e8e92091742cadfd34d86a0d9ad01a57f2
sonalgupta06cs/Python_Projects
/PythonBasicsProject/listExercises.py
816
4.28125
4
# find the largest number in a list numbers = [3, 6, 11, 2, 8, 4, 10] maxNum = numbers[0] for number in numbers: if number > maxNum: maxNum = number else: continue print("max number is ", maxNum) # Remove the duplicates from the list - 1 numbersList1 = [2, 2, 4, 6, 3, 4, 6, 1] uniques = [] cou...
true
631a1183574d0d8a6cef80da7a8edf209052b24c
sonalgupta06cs/Python_Projects
/PythonProjectBasics2/loopsExcercises.py
741
4.125
4
print("-----------ForLoopExercise----------------") # add the price and sum the total amount prices = [10, 20, 30] total = 0 for price in prices: total += price print(f'total is {total}') print("----------ForLoopExerciseToPrint'F'-----------------") numbers = [5, 2, 5, 2, 2] for number in numbers: print(number...
true
033054b27f059ea4a505bf79329116aa692b78f3
millenagena/Python-Scripts
/aula06 - desafio 004 analise, numeros, letras etc.py
499
4.15625
4
a = input('Type something: ') print('The primitive type of this value is: {}'.format(type(a))) print('Does it have only numbers? {}'.format(a.isnumeric())) print('Does it have only letters? {}'.format(a.isalpha())) print('Does it have only numbers and letters? {}'.format(a.isalnum())) print('Does it have only spaces?...
true
8a6b2a226d1188f7b9ab30d192d843bdbdad0e78
leandromjunior/Codewars
/duplicate encoder/duplicateEncoder.py
611
4.1875
4
# The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character # appears only once in the original string, or ")" if that character appears more than once in the original string. # Ignore capitalization when determining if a character is a duplicate....
true
37008caf6079ac122daf822f483f3cdc26420a38
mfcust/operators_comments
/operators_comments.py
1,360
4.6875
5
###Operators and comments### ###You can write comments like this!!### '''Or if your comments span multiple lines, like this and this and this, you can use three single quotes to comment out large blocks of code.''' #1) Write a comment below by using the '#' symbol. #2) Write a multi-line comment below by usin...
true
85fb92186a54ee75f8d14ca7ede685782bc3fdc6
gkl1107/Python-algorithm
/alice_words.py
1,189
4.25
4
''' Write a program that creates a text file named alice_words.txt containing an alphabetical listing of all the words, and the number of times each occurs. ''' word_dict = {} with open("alice_in_wonderland.txt") as file: line = file.readline() while line: no_punct = "".join([char for char in line if char.isalpha...
true
23751a9b31c21edd67b5b54342f3a8dfb299c517
gkl1107/Python-algorithm
/alphabet_cipher.py
867
4.625
5
#!/usr/bin/python ''' A function that implements a substitution cipher. the function takea two parameters, the message you want to encrypt, and a string that represents the mapping of the 26 letters in the alphabet. ''' import string def cipher(message, str_mapping): upperCase_mapping = str_mapping.upper() ...
true
8e6a6b7a3f5f3fd341079d6e0435ffb0e4f2e477
weikuochen/LeetCode
/LeetCode_000009.py
937
4.21875
4
""" Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of using extra space. You could also try reversing an integer. However, if you...
true
4a841929d8277ce9ebdc78055bf26752aea6e4b2
yarosmar/beetroot-test-repo
/calculator.py
667
4.1875
4
def calculate(): operation = input() number_1 = int(input()) number_2 = int(input()) if operation == '+': print('{} + {} = '.format(number_1, number_2)) print(number_1 + number_2) elif operation == '-': print('{} - {} = '.format(number_1, number_2)) print(numb...
true
f988f37a28f4994bcb69f3db84cb3f5777c249c4
BabaYegha/pythonExercises
/week-02/unique.py
315
4.15625
4
def unique(uniqList): unique_list = [] for x in uniqList: if x not in unique_list: unique_list.append(x) for x in unique_list: print(x) numbers = [1, 11, 34, 11, 52, 61, 1, 34] print("Original list: [1, 11, 34, 11, 52, 61, 1, 34]") print("Unique list: ") unique(numbers)
true
f88b4c5f5238bb699783ef2b678e4d7f0ff5dedd
jilesingh/LearnPythonTheHardWay
/chapter1/ex20.py
1,096
4.3125
4
# -*- coding utf-8 -*- # This code is written and run using Python Version 3.6.8 from sys import argv script, input_file = argv def print_all(f): print (f.read()) def rewind(f): f.seek(0) def print_a_line(line_count, f): print (line_count, f.readline()) current_file = open(input_file) print ("First l...
true
f48ca78c0c9e5b0d8b91d87f757ea0cf57e462f4
jilesingh/LearnPythonTheHardWay
/chapter1/ex16.py
1,194
4.3125
4
# -*- coding utf-8 -*- # This code is written and run using Python Version 3.6.8 from sys import argv script, filename = argv print ("We are going to erase %r." % filename) print ("If you don't want that, hit CTRL+C") print ("If you do want that, hit Return") input("?") print ("Openeing the file.....") target = open...
true
43e02df282c080a98b9ce55772a3e1ef9ea403d3
Kushalchg/Rock-Paper-and-Scissors-game
/rock_paper_scissors.py
1,215
4.1875
4
import random choice_list = ['rock','scissors','paper'] computer_input = random.choice(choice_list) user_input = (input("enter your choice: ")) if (computer_input=="rock" and user_input=="scissors"): print("computer choice: "+computer_input) print("you loose") elif(computer_input ==...
false
111c6397fbda31698130e27bdfe8a30565a50d95
shivamkalra111/Tkinter-GUI
/buttons.py
379
4.15625
4
from tkinter import * root = Tk() def click(): mylabel = Label(root, text = "Clicked the button!!") mylabel.pack() #click the button again and again the text comes up multiple times #can also use x color codes mybutton = Button(root, text = "Click me", padx = 50, pady = 50, command = click, fg = 'y...
true
2c9fd4e0e74f12b7c7da6595cae99190eaa597e2
Marklar9197/Python-Project
/game.py
1,166
4.1875
4
#This program takes a random number between 1 and 10 and asks the user to guess it. import random random_num = random.randint(1,10) print(random_num) # Being used for testing purposes guess = int(input("What is my number? > ")) small_num = int(input('Lower > ')) large_num = int(input('Higher > ')) replay = input...
true
3679332415ce1d8a521b3521ceeb59298d0d1aab
eightweb/LifeisShort
/2分支,循环,条件,枚举/条件控制.py
667
4.3125
4
""" 条件控制 if else 循环控制 for 分支 while """ # 如果是真 执行代码块 python中 无{}包裹这代码块, 是通过缩进来控制代码块 # 例子1: # mood = True # if mood: # print('是True') # else: # print('是False') # 例子2: # userName = 'taowang' # password = '123' # print('please input Name and pass') # user_Name = input() # 请输入的功能 返回的类型是str # user_pass = ...
false
abd61a3dfe88daaa4391d938ee532666d0b85701
eightweb/LifeisShort
/5函数/c4.py
1,583
4.28125
4
''' 函数参数: 必须参数 关键字参数: 不比关心函数的形参的顺序, 调用时, 指定实参对应的是形参的哪个 ''' def Summation(num1, num2): return num1 + num2 c = Summation(num2 = 10, num1 = 30) # 使用的是关键字参数, 不比考虑形参的顺序位置 ''' 默认参数 ''' def defaultDef(num1, num2 = 10): return num1 + num2 c = defaultDef(2) # 当不传的时候 num2 默认是10 ''' 可变参数: 随...
false
438f7cc6adcccec59265e134a0392a68b1068b22
saharul/csa-ver-1.0
/getfuturedate.py
346
4.15625
4
from datetime import date import datetime from dateutil.relativedelta import relativedelta def main(): today = date.today() threemonths = datetime.datetime.now() + relativedelta(months=3) print("Today's date is ", today) print("3 months from today ", threemonths.strftime("%Y-%m-%d")) if __name__ ==...
false
1eda22930e4ea80cce1894da1b9ffdf3f3a71fab
ranjithmanda/solaris
/B1/solaris_samples/count_words.py
585
4.1875
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 5 09:16:38 2020 @author: gupta count number of times each word occurred in given string. find count of each digits in given number. find specific digit found in given number. """ # this program is incomplete. need to explain further. given_str = "this is a good day , ...
true
ca59919a9b447c2d7b0db5cf2bde7257a684d3b9
mattdix27/miniprojects
/dijkstra.py
2,055
4.125
4
import sys ''' Graph with multiple nodes as well as edges with lengths Find the shortest distance to any node ''' graph = { 'a':[{'b':4},{'c':8},{'d':7}], 'b':[{'a':4},{'e':12}], 'c':[{'a':8},{'d':2},{'e':3}], 'd':[{'a':7},{'c':2},{'f':10}], 'e':[{'b':12},{'c':3},{'g':18}], 'f':[{'d':10},{'g':20}], 'g':...
true
0daa638eb46824a06007d0d220b3763f0450c926
Disha-Shivale/Exceptionhandling
/regex1.py
483
4.53125
5
import re s = "Hello from Python, This is Reg Expression" i = re.search("^Hello", s) # ^Starts with if (i): print("String Match!") else: print("No match") #Example 2 i = "Hello from Python" print() #Find all lower case characters alphabetically between "a" and "m": x = re.findall("[a-z]", i) print(x) print() ...
true
d23c30395aa9e2fa29c169e4f3313d2204fae50d
fmcooley/TTA_Projects
/Python/item_62_datetime_drill/FC_Datetime_Drill_rev1.py
1,075
4.125
4
#!/usr/bin/python2.7 # Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) # Student: Freeman Cooley # Python Course Item 62 # Drill: Pydrill_Datetime_27_idle # http://stackoverflow.com/questions/13866926/python-pytz-list-of-timezones # http://www.guru99.com/date-time-and-datetime-classes-in-python.html # imp...
false
d6e502c150a837f17610cfdc88ef536c99363e1c
mohammadasim/python-course
/Errors _and_exceptions/homework.py
1,354
4.15625
4
# Problem 1 # Handle the exception thrown by the code below by using try and except blocks def square_root(): for i in ['a','b','c']: try: print(i**2) except TypeError as wrong_list_items: print('Wrong list items provided. Please provide either int or floating point') ...
true
ede487fdcd22575b67b235343dd5c69bc8a094e8
mohammadasim/python-course
/while_loops.py
396
4.15625
4
x = 0 while x < 5: print('The value of x is {}'.format(x)) x += 1 else: print( 'X is not less than 5') # break, continue, pass # We can use break, continue and pass statements in our loops to add additional functionality for various cases # break: Breaks out of the current closest enclosing loop. # continu...
true
1c0844e3c04f201687718b037286e60a567a7cc0
mohammadasim/python-course
/python_generators/generator.py
2,410
4.71875
5
''' We have learned how to cerate functions with def and the return statement. Generator functions allow us to write a function that can send back a value and then later resume to pick up where it left off. This type of function is a generator in Python, allowing us to generate a sequence of values over time. The main...
true
31981e597b9583b5423ca38a8e78c3ac5012e239
mohammadasim/python-course
/variables.py
622
4.3125
4
# Python is dynamically typed, it means that we can assign any type of value to a variable. # Unlike Java which is statically typed. Which means we have to declare the type of the variable and can only # assign that type of value to it. a = 5 print a a = a + a print a a = 'b' # We can use the type function to determi...
true
e3caadd4da05454be2fc7540c9374bb8689ab210
mohammadasim/python-course
/ood_class_object_attributes.py
1,413
4.1875
4
class Dog(): # Class Objject Attributes # These are the same for all instances of a Class # These are identical to Static attributes in Java species = 'mammal' # Constructor of the class with three arguments # We can provide default values for these attributes and they will be overwritten if the values is ...
true
fe51c43cf891d8ab1ade5c71756e538d392ba738
beckytrantham/PythonI
/lab3.py
297
4.125
4
#Reads the temperature in F from the keyboard, then prints the equivalent in C. #Formula C = 5 / 9 * (F - 32) temp = raw_input('What is the temperature in degrees Fahrenheit? ') ftemp = float(temp) ctemp = 5.0 / 9.0 * (ftemp - 32) print 'The temperature is {} degrees Centigrade.' .format(ctemp)
true
3736232377d04f29abb3edd4c3cbf1f592f01ed2
YektaAkhalili/Practice_Python
/Ex2.py
707
4.125
4
num = int(input("Give me a number, and I'll tell you if it's even or odd: ")) def decision(n): if n % 2 == 0: if n % 4 == 0: print("Even & Divisble by 4.") else: print("Even number.") else: print("Odd number.") decision(num) print("Now ...
false
3447720ec6cde0cfe9f375462a2c4d69f0488775
theLoFix/30DOP
/Day24/Day24_Excercise02.py
457
4.25
4
# Below you'll find a divide function. Write exception handling so that we catch ZeroDivisionError exceptions, TypeError exceptions, and other kinds of ArithmeticError. def divide(a, b) try: print(a / b) except ZeroDivisionError: print("Cannot divide by zero") except TypeError: print("Both values must be numb...
true
9bbe017ba0c1efb455de424cb1a234a408bb5bfa
theLoFix/30DOP
/Day10/Day10_Excercise01.py
778
4.3125
4
# Inside the tuple we have the album name, the artist (in this case, the band), the year of release, and then another tuple containing the track list. # Convert this outer tuple to a dictionary with four keys. tuple1 = ( "The Dark Side of the Moon", "Pink Floyd", 1973, ( "Speak to Me", "Breathe", "On ...
true
525bc17db7c6eae600218137c3c8586e5d5dc78f
theLoFix/30DOP
/Day07/Day07_Excercise1.py
464
4.25
4
# Ask the user to enter their given name and surname in response to a single prompt. Use split to extract the names, and then assign each name to a different variable. For this exercise, you can assume that the user has a single given name and a single surname. answer = (input("Please provide your first and last name....
true
dd3c094d86d37d4ced4dfcf7c89f057547ab04f4
vinayvarm/programs
/venv/LeapYear.py
683
4.25
4
# year = int(input('enter year')) # # def checkleap(): # # if year%4==0 and(year%100!=0 or year%400==0) : # print('leap year') # else: # print('not leap year') # # checkleap() month= input('enter month') month = month.strip().lower() def checkdaysformonth(): if month=='jan' or month=='marc...
false
630f6ca3b741a9ee4a9dc01b3cbabc122927e93c
esinayyildiz/linear_nonlinear_regression
/ps0_1_a.py
1,177
4.125
4
import matplotlib.pyplot as plt import numpy as np def main(): #my main method #variable for regression x = np.array([31,33,31,49,53,69,101,99,143,132,109]) y = np.array([705,540,650,840,890,850,1200,1150,1700,900,1550]) x=x[:,np.newaxis] y=y[:,np.newaxis] # size of the dataset ...
false
7d760eb55f99e40f16d5264b5be50fb5cb2b2e6b
league-python/Level0-Module1
/_03_if_else/_3_tasty_tomato/tasty_tomato.py
665
4.375
4
from tkinter import * import tkinter as tk window_width = 600 window_height = 600 root = tk.Tk() canvas = tk.Canvas(root, width=window_width, height=window_height, bg="#DDDDDD") canvas.grid() # 1. Ask the user what color tomato they would like and save their response # You can give them up to three choices # 2...
true
2e5cb49890b56e5253d1e61b494dce3b18b61d52
azegun/python_study
/chap05/lamda/lamda3.py
496
4.21875
4
""" def power(item): return item * item """ """ 여러번 사용할 시, 선언해서 사용 power =lambda x :x * x under_3 = lambda x: x < 3 """ """ def under_3(item): return item < 3 """ list_input_a = [1, 2, 3, 4, 5] #map 함수 #1번 사용할 시, 람다 바로 수식 output_a = map(lambda x :x * x, list_input_a) print(list(output_a)) #filter output_b ...
false
d28e288c8f8bda49d0291861c5bfaea407761818
wenyan666/wenyan-python
/ex18.py
930
4.40625
4
# -*- coding:UTF-8 -*- # this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print "arg1:%r, arg2: %r." % (arg1, arg2) # OK, that *args is actually pointless, we can just do this def print_two_again(arg1, arg2): print "arg1:%r, arg2:%r" % (arg1, arg2) # or just type one argu...
true
d746b68a08610c3e5ddc4b953ca0335c248a3b59
PRai0409/code1
/first.py
2,271
4.28125
4
#PROGRAM 1 print("PROGRAM 1") fname =input("Enter any filename :") print("Output :") op=fname.split(".") #print(type(op)) print("filename : ",op[0]) print("extension : ",op[1]) #PROGRAM 2 print("\nPROGRAM 2") fnum = int(input("Enter first number :")) #print(type(fnum)) snum = int(input("Enter second number :")) total...
true
29eaffb27ed811d9e2ebc82927281793be6f2b7e
shubham-ricky/Python-Programming---Beginners
/Vowels.py
1,404
4.125
4
""" a) Write a function getVowels that takes in an utterance as argument and returns the vowels (A, E, I, O, U) in uppercase. Sort your list according to the sequence of the alphabets in your vowels. b) Write the function countChars that takes in an utterance and a character as arguments, and call the function to r...
true
d514c8d421a394644d686512f387f5ca2e54ddd8
Robert-Siberry/IntroToGit
/numberguess2.py
492
4.21875
4
print("The Guessing Game") import random number=random.randint(1,9) guess=0 counter=0 while guess!=number and guess!="exit": guess=input("Please guess a number between 1 and 9: ") if guess == "exit": break guess = int(guess) counter=counter+1 if guess < number: print("Thats too low!"...
true
98f6a84e85c8e12b4c2fdba7a0560dcc53ce0fae
zhane98/studying
/lesson21.py
310
4.40625
4
# string formatting/interpolation = %s inside of a string to mark where we want other strings inserted. # E.g: name = 'Calvin' place = 'KFC' time = '8 pm' # how to add pm food = 'chicken' print("Hello %s, you are invited to a party at %s at %s. Please bring %s." %(name, place, time, food))
true
f6e1ed77f1e44b905af6895e212f34c3ec828a14
zhane98/studying
/codewars2.py
998
4.3125
4
# RETURNING STRINGS # Make a function that will return a greeting statement that uses an input; # your program should return, "Hello, <name> how are you doing today?". def greet(name): #Good Luck (like you need it) return "Hello, " + name + " how are you doing today?" print(greet('Zhané')) #calling the func...
true
4047d09aecce5353fe31ce6586ddd951731b4ece
papan36125/python_exercises
/concepts/Exercises/dictionary_examples.py
778
4.25
4
# empty dictionary my_dict = {} # dictionary with integer keys my_dict = {1: 'apple', 2: 'ball'} # dictionary with mixed keys my_dict = {'name': 'John', 1: [2, 4, 3]} # using dict() my_dict = dict({1:'apple', 2:'ball'}) # from sequence having each item as a pair my_dict = dict([(1,'apple'), (2,'ball')]) my_dict = ...
false
cff7967a402d750c2faa69b8a61ccff2c1952e4f
papan36125/python_exercises
/concepts/Exercises/implicit_type_conversion.py
237
4.15625
4
num_int = 123 num_flo = 1.23 num_new = num_int + num_flo print("datatype of num_int:",type(num_int)) print("datatype of num_flo:",type(num_flo)) print("Value of num_new:",num_new) print("datatype of num_new:",type(num_new))
false
80920c05b76e207f324ac356382c239a1975d48f
papan36125/python_exercises
/concepts/Exercises/tuples_example_2.py
930
4.28125
4
my_tuple = (4, 2, 3, [6, 5]) # we cannot change an element # If you uncomment line 8 # you will get an error: # TypeError: 'tuple' object does not support item assignment #my_tuple[1] = 9 # but item of mutable element can be changed # Output: (4, 2, 3, [9, 5]) my_tuple[3][0] = 9 print(my_tuple) # tupl...
false
9b1e159cf387cbf25cf0950cdd8194a21d45bea3
nayan-pradhan/python
/stack.py
2,154
4.1875
4
# Nayan Man Singh Pradhan # Stack Class class Stack: # initialize stack def __init__(self, stack_size): self.array = [None] * stack_size self.stack_size = stack_size self.top = 0 # bool to check if stack is empty or not def isEmpty (self): print("Stack is empty? -> ", ...
true
262c8c4d6e135d5e7c18bea7efe5f5ad968006c0
kauserahmed/rock_paper_scissors_game
/rock_paper_scissors_game.py
1,282
4.1875
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) ...
false
5ee0fc5ac97c785c83ae956918ac9b85b66f1f0e
BryantLuu/daily-coding-problems
/15 - pick a random number from a stream given limited memory space.py
1,088
4.15625
4
""" Good morning. Here's your coding interview problem for today. This problem was asked by Facebook. Given a stream of elements too large to store in memory, pick a random element from the stream with uniform probability. Upgrade to premium and get in-depth solutions to every problem. If you liked this problem, fe...
true
846a9d273b15a562439a612c84ea911381a3d446
BryantLuu/daily-coding-problems
/12 - N steps generic fib.py
1,088
4.21875
4
""" Good morning. Here's your coding interview problem for today. This problem was asked by Amazon. There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. ...
true
fe1e91d58da2d16bb07a1cacc30639f60d250bc6
vishnuster/python
/guess the number.py
320
4.125
4
#This program will ask you to guess a number import random a=random.randint(1,20) while True: b=int(input("Guess the number")) if (b < a): print("You have entered less") elif(b > a): print("You have entered greater") else: print("You have guessed it right. It's",b) continue
true
cbe00582a3809efa45860c4cec2cc93f16cc25a7
vishnuster/python
/Validating_Postal_Codes.py
698
4.1875
4
"""A postal code must be a number in the range of (100000,999999). A postal code must not contain more than one alternating repetitive digit pair. Alternating repetitive digits are digits which repeat immediately after the next digit. In other words, an alternating repetitive digit pair is formed by two equal digit...
true
b0cd6913d7348dae9d6ac6decd54597410edc4ae
MrAnonymous5635/ICS-201d
/quiz_answers.py
528
4.3125
4
name = "Dave" print(f"Hello, {name}") print("Hello, {}!".format(name)) print("Hello, " + name + "!") # --------2----------- m = 1 x = 2 b = 3 y = m * x + b print(f"When x is {x}, y is {y}") # ----3----- length = 2 width = 3 area = length * width perimeter = length * 2 + width * 2 print(f"Area: {area}, Perimeter:...
false
28064a9d6b548dcbafbfa320f92f8ed73a089749
abhinavramkumar/basic-python-programs
/divisors.py
465
4.25
4
# Create a program that asks the user for a number and then prints out a list # of all the divisors of that number. (If you don’t know what a divisor is, # it is a number that divides evenly into another number. # For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) number = int(input("Find divisors f...
true
c510831fdef3482c6394535297180366c2d7741a
Did-you-eat-my-burrito/employee_class_homework
/main.py
2,344
4.25
4
from employee_class import Employee print("*==================================*") print("* 1. show employee list *") print("* 2. add employee *") print("* 3. update employee *") print("* 4. delete employee *") print("* 5. quit app *") print("...
true
4b3ba75135a3c8bcdb993db2b2f7bdd946aa6916
sol83/python-simple_programs_5
/Parameters & Return/print_multiple.py
807
4.6875
5
""" Print multiple Fill out print_multiple(message, repeats), which takes as parameters a string message to print, and an integer repeats number of times to print message. We've written the main() function for you, which prompts the user for a message and a number of repeats. Here's a sample run of the program: $ py...
true
b78d609b110056b35c2273ef9c9324a650e4be75
ashishvista/geeks
/geekforgeeks/merge_sort.py
1,106
4.125
4
# User function Template for python3 def mergeSort(arr): new_arr = divide(arr, 0, len(arr) - 1) for i in range(len(new_arr)): arr[i] = new_arr[i] def divide(arr, low, high): if low == high: return [arr[low]] mid = int((low + high) / 2) sub1 = divide(arr, low, mid) sub2 = divid...
false
2f61edad23612fdfe7e9a3194f4dfc035f934db8
Yehuda1977/DI_Bootcamp
/Week9/Day2/Exercises.py
1,809
4.1875
4
# Exercise 1 : Built-In Functions # Python has many built-in functions, and if you do not know how to use it, you can read document online. # But Python has a built-in document function for every built-in functions. # Write a program to print some Python built-in functions documents, such as abs(), int(), raw_input()....
true
0a4ef8ad261499611af95096cc162f3cea0b6d9d
Yehuda1977/DI_Bootcamp
/Week7Python/Day2Feb15/dailychallengematrix.py
1,766
4.59375
5
# Hint: Look at the remote learning “Matrix” videos # The matrix is a grid of strings (alphanumeric characters and spaces) with a hidden message in it. # To decrypt the matrix, Neo reads each column from top to bottom, starting from the leftmost column, select only the alpha characters and connect them, then he replac...
true
0ac723f1b6026fb1b19cedad93ebeda3ceb2ab3c
Yehuda1977/DI_Bootcamp
/Week6Python/Day2Feb8/dailychallenge.py
1,348
4.59375
5
# 1. Using the input function, ask the user for a string. The string must be 10 characters long. # If it’s less than 10 characters, print a message which states “string not long enough” # If it’s more than 10 characters, print a message which states “string too long” # 2. Then, print the first and last characte...
true
7cd999d480f77e97259a6da7716217ca42dac450
cdt-data-science/cdt-tea-slides
/2015/theo/optimisation/cost_functions/Cost_Function.py
2,685
4.40625
4
__author__ = 'theopavlakou' class Cost_Function(object): """ An abstract class that provides the interface for cost functions. In this context, a cost function is not a function of the data points or the targets. It is purely a function of the parameters passed to it. Therefore, a cost function...
true
7c2886dc4ba552d982ff8e3883ad142ade94bed6
prayasshrivastava/Python-Programming
/Name&age.py
382
4.21875
4
# Create a program that asks the user to enter their name and their age #Print out a message that will tell them the year that they will turn 95 years old. #!/usr/bin/python3 import datetime name=input("Enter your name: ") age =int(input("Enter your age: ")) z=95-age x=datetime.datetime.now() y=(x.year) p=y+z print(n...
true
76d67af4f0e2a8874364d84b659a70a0771c67fb
Greesha1337/python_basic_11.05.2020
/hw5/hw5_task5/task5.py
890
4.15625
4
# Lesson 5 HomeWork - Task 5 """ Создать (программно) текстовый файл, записать в него программно набор чисел, разделенных пробелами. Программа должна подсчитывать сумму чисел в файле и выводить ее на экран. """ while True: try: with open('numbers.txt', 'w+') as file: numbers = input('Введите ч...
false