blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
92614454c9999c233b15ab0632e1979a0bf12ab9
rajesh-06/p243_assignment_2
/A2_q1b.py
1,351
4.46875
4
#To get the distance between 2 points def distance(x1, x2, y1, y2): if((x2-x1)>=0 and (y2-y1)>=0): return ((x2-x1)+(y2-y1)) elif((x2-x1)<=0 and (y2-y1)>=0): return ((x1-x2)+(y2-y1)) elif((x2-x1)<=0 and (y2-y1)<=0): return ((x1-x2)+(y1-y2)) elif((x2-x1)>=0 and (y2-y1)<=0): return ((x2-x1)+(y1-y2)) sum=0 n...
true
8385b2b48343cb5f0a05bfee4019caae8818dcd6
afrantisak/rubiks
/util.py
462
4.125
4
def reverse_turn(turn): flip = { 'F': 'Fi', 'Fi': 'F', 'R': 'Ri', 'Ri': 'R', 'L': 'Li', 'Li': 'L', 'U': 'Ui', 'Ui': 'U', 'D': 'Di', 'Di': 'D', 'B': 'Bi', 'Bi': 'B', } if turn in flip: return flip[st...
false
5d9715b4afdbfaa7d627b2cb89012aa4a6e30f2f
codingtrivia/PythonLabs
/Intermediate/Lab3/Lab3.py
323
4.3125
4
# Using recursion, print only even numbers in descending order. For e.g. if I say, print_down(10), output would be: # 10 # 8 # 6 # 4 # 2 # You will need to do a slight modification in the code we wrote for print_up_down in our class today. # Hint: Use % operator def print_down(n): #<your code here> print_down(1...
true
614fdacddcea190226dedcb8fb9b30843d69f916
khadak-bogati/python_project
/LAB3.py
1,930
4.46875
4
print('When we set one variable B equal to A;\n both A and B are referencing the same list in memory:') # Copy (copy by reference) the list A A =["Khadak Bogati",10,1.2] B = A print('A:',A) print('B:',B) print('Initially, the value of the first element in B is set as hard rock. If we change the\n first element in A ...
true
7dbfb9f5fbeaf8bc2dafd2003f3c0403140858db
khadak-bogati/python_project
/TypeerrorAndValueError.py
350
4.34375
4
myString = "This String is not a Number" try: print("Converting myString to int") print(1/0) print("String # " + 1 + ": "+ myString) myInt = int(myString) print(myInt) except (ValueError, TypeError) as error: print("A ValueError or TypeError occureed.") except Exception as error: print("Some other type of error...
true
396bdb1c3d00ef1c113ee7195ef1a754320b1a7b
khadak-bogati/python_project
/Function.py
2,605
4.5625
5
print("===========================================") print('An example of a function that adds on to the parameter a prints and returns the output as b:') def add(a): b = a + 1 print(a, 'if you add one', b) return(b) add(2) ........................ output =========================================== An example of a...
true
4e2481ad72e8ecb600b9df438b9bda347be000e4
GabrieleMaurina/workspace
/python/stackoverflow/calculator.py
581
4.34375
4
print("Welcome to my calculator programme!") while True: # try: operator = input("Enter a operator (+,-,* or /): ") num_1 = int(input("Enter the first number: ")) num_2 = int(input("Enter the second number: ")) q = input('Press Q to quit to the programme...') if operator ==...
true
29c5b22e47aee010b7c4cb60cf8e66d8a72feb77
otomobao/Learn_python_the_hard_way_
/ex3.py
670
4.46875
4
#Showing what i am doing print "I will now count my chickens:" #Showing hens and caculate the number print "Hens", 25.0+30.0/6.0 #Showing roosters and the caculate the number print "Roosters",100.0-25.0*3.0%4.0 #Showing what i am going to do next print "Now I will count the eggs:" #Caculate the number and print prin...
true
335828ec29ec2bc55cedaba7f7b57529d3ed88b2
macluiggy/Python-Crash-Course-2nd-edition-Chapter-1-11-solutions
/CHAPTER 5/5-6. Stages of Life.py
265
4.21875
4
age=22 if age<2: person='a baby' elif age>=2 and age<4: person='a toddler' elif age>=4 and age<13: person= 'a kid' elif age>=13 and age<20: person='a teenager' elif age >=20 and age<65: person='an adult' else: person='an elder' print(f'The person is {person}')
false
2f8267f4d241dee5f2bf8ea05b5d4a53ebbd4fb1
codinglzc/liaoxuefengLearnPython
/build_in_module_itertools.py
2,000
4.25
4
# coding=utf-8 # itertools # Python的内建模块itertools提供了非常有用的用于操作迭代对象的函数。 # 首先,我们看看itertools提供的几个"无限"迭代器: import itertools # 因为count()会创建一个无限的迭代器,所以下面代码会打印自然数序列,根本停不下来,只能按Ctrl+C退出。 natuals = itertools.count(1) for n in natuals: print n # cycle()会把传入的序列无限重复下去: cs = itertools.cycle('ABC') # 注意字符串也是序列的一种 for c in cs...
false
bc5980fdfcd37b51dd917a31fd2ba10aba46cc04
SayantaDhara/project1
/printPositiveNo.py
261
4.15625
4
list1 = [] n = int(input("Enter number of elements : ")) print("Enter list terms") for i in range (0,n): elem = int(input()) list1.append(elem) print("Positive numbers are:") for num in list1: if num >= 0: print(num, end = " ")
true
e6f3ccfd56db33391bac8c893832ccb0b5891f6a
shabbirkhan0015/python_programs
/s2.py
280
4.25
4
m=[[]*3 for i in range(3)] l=[] for i in range(3): for j in range(3): x=int(input("enter an element")) m[i].append(x) print(m) for i in range(3): l.append(max(m[i])) print("largest element" ) print(max(l)) print("smallest element" ) print(min(l))
false
4a890456ce83401f6e3408d5c75d5f839a064ece
ConquestSolutions/Conquest-Extensions
/GetStarted/01-BasicCodeSamples/1.1-BasicCodeSamples.py
1,119
4.34375
4
########## # # THIS SCRIPT IS A LITTLE BASIC PYTHON IN THE CONTEXT OF THE CONQUEST EXTENSIONS CONSOLE # Copy this code into a console bit by bit from the top down to see how it all works. # ########## #Declare variable (change to your favourite number!) variable = 37 #Return variable print 'Variable: ' + str(variable...
true
e609a51428b4d0526be7f16f6c11132035c38ff7
jwebster7/sorting-algorithms
/merge_sort.py
2,009
4.4375
4
def mergeSort(lst): ''' 1. Split the unsorted list into groups recursively until there is one element per group 2. Compare each of the elements and then group them 3. Repeat step 2 until the whole list is merged and sorted in the process * Time complexity: The worst-case runtime is O(nlog(n)) ...
true
0895e45d8c44983ac75833f7c051ec28f26d32e4
mlopezqc/pymiami_recursion
/exercise1.py
1,364
4.59375
5
""" Exercise 1: Write a recursive function count_multiples(a, b) that counts how many multiples of a are part of the factorization of the number b. For example: >>> count_multiples(2, 4) # 2 * 2 = 4 1 >>> count_multiples(2, 12) # 2 * 2 * 3 = 12 2 >>> count_multiples(3, 11664) 6 >>> This send the stat...
true
bcf713e9bbad134c881bf7f1ce293a46a1b3725c
idristuna/python_exercises
/in_out_exercise/q8.py
325
4.25
4
#! /usr/bin/python3 #using string.format to dispaly the data below totalMoney = int(input("Enter totalMoney")) quantity = int(input("Enter quantitiy")) price = int(input("Enter price")) statement1 = "I have {0} dollars so I can buy {1} football for {2:.2f} dollars " print(statement1.format(totalMoney, quantity, pri...
true
04422bb36c79b62d156c21baf162e166a39e0222
pratyushagnihotri03/Python_Programming
/Python Files/14_MyTripToWalmartAndSet/main.py
202
4.125
4
groceries = {'cereal', 'milk', 'starcrunch', 'beer', 'duct tpe', 'lotion', 'beer'} print(groceries) if 'milk' in groceries: print("You have already a milk") else: print("Oh yea, you need milk")
true
78881030afd3c76d3e4bab9a4d69e72767ef4cf5
deltonmyalil/PythonInit
/classDemo.py
1,038
4.40625
4
class Students: def __init__(self,name,contact): #to define attribs of the class use def __init__(self,<attribute1>,<attribute2>,...) self.name = name self.contact = contact #name and contact are attribs and they are to be defined like this #once attribs are defined, you have to define the meth...
true
9ba11952aebc8ecf80527af333763082d15ff2f5
deltonmyalil/PythonInit
/numericFunctions.py
389
4.34375
4
#minimum function print(min(2,3,1,4,5)) numbers = [x for x in range(10)] #list generation print(numbers) print("the minimum is {0}".format(min(numbers))) #prints the minimum in numbers using format function print("The minimum is",(min(numbers)),"thank you") #max function print("The maximum value is {0}".format(max(nu...
true
f5d0698a74866606d1010c83ad6b335415995b94
nmoya/coding-practice
/Algorithms/queue.py
1,044
4.1875
4
#!/usr/bin/python import random import linkedlist class Queue(): def __init__(self): ''' A queue holds a pointer to a list. The elements are inserted at the end and removed from the front. (FIFO). ''' self.start = linkedlist.List() self.size = 0 def __repr__(self): _l...
true
9ecad439ee39051487c0aa70e3a014f2b684389a
gkerkar/Python
/code/ada_lovelace_day.py
977
4.25
4
#!/bin/python3 import math import os import random import re import sys # # The function is expected to return an INTEGER. # The function accepts INTEGER year as parameter. # import calendar def ada(year): # Get October week days. oct_weeks = calendar.monthcalendar(year, 10) ada_first_week = oct_w...
true
098a0d9ea413dfcef9301f73650acb2142cd0935
HissingPython/sandwich_loopy_functions
/Sandwich 8.py
2,386
4.46875
4
#Do you want a sandwich or not? def yes_no_maybe (answer): while True: if answer.upper() == 'Y' or answer =='N': break else: print ("Please enter 'Y' or 'N'.") answer = input ("Do you want to order a sandwich? (Press 'Y' for Yes and 'N' for No): ")...
true
1dad422ce571ed3d24cd85c0c1c0e6273213fa6e
TOMfk/discover
/project1/rili.py
2,032
4.1875
4
def is_leap_year(year): """ 判断闰年 :param year: :return: """ return year % 4 == 0 and year % 100 != 0 or year % 400 == 0 def get_num_of_days_in_month(year, month): """ 获得每月的天数 :param year: :param month: :return: """ if month in (1, 3, 5, 7, 8, 10, 12): return ...
false
b480d970bf562a300ef1c05db6b06c15c0b580d7
adclleva/Python-Learning-Material
/automate_the_boring_stuff_material/06_Lists/list_methods.py
1,349
4.53125
5
# Methods # A method is the same thing as a function, except it is “called on” a value. # For example, if a list value were stored in spam, you would call the index() list method (which I’ll explain next) on that list like so: spam.index('hello'). # The method part comes after the value, separated by a period. # index...
true
d2f5afeaf363d8566d343a7be28a469d3990f198
adclleva/Python-Learning-Material
/automate_the_boring_stuff_material/07_Dictionaries/dictionary_data_type.py
2,480
4.53125
5
# The Dictionary Data Type # Like a list, a dictionary is a collection of many values. # But unlike indexes for lists, indexes for dictionaries can use many different data types, # not just integers. Indexes for dictionaries are called keys, # and a key with its associated value is called a key-value pair. # Diction...
true
a7d36e5aeefa0964601ae213b2029c5c6bcdedbe
bashbash96/InterviewPreparation
/LeetCode/Facebook/Medium/49. Group Anagrams.py
1,483
4.125
4
""" Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: strs = ["eat","tea","tan","ate","nat","ba...
true
0ab6cb2ca6a679b9692f841f095074e3d0e0bf4b
bashbash96/InterviewPreparation
/LeetCode/Facebook/Medium/1762. Buildings With an Ocean View.py
1,552
4.53125
5
""" There are n buildings in a line. You are given an integer array heights of size n that represents the heights of the buildings in the line. The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Formally, a building has an ocean view if all ...
true
bca11339ec5f1b4604f5d2aba56878720c3ac9da
bashbash96/InterviewPreparation
/LeetCode/Facebook/Easy/21. Merge Two Sorted Lists.py
1,227
4.1875
4
""" Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists. Example 1: Input: l1 = [1,2,4], l2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: l1 = [], l2 = [] Output: [] Example 3: Input: l1 = [], l2 = [0] Output: [0] Const...
true
86d82f81e410a7eb16c98b250d5e60c659da5a26
VladOsiichuk/python_base_public
/lesson_7/array_generators.py
1,821
4.125
4
def get_only_digits_array(arr): """ :param arr: list of some values :return: list of values which are digits """ print(arr) """ Дана функція еквівалентна наступним рядкам output_array = list() for n in arr: if isinstance(n, int) or (isinstance(n, str) and n.isdigit()): ...
false
17db529c69a7dddc44ab85fcccc698cc136ef774
VladOsiichuk/python_base_public
/lesson_9/iterate_in_dict.py
233
4.28125
4
people_years = {"Andriy": 18, "Olena": 22, "Iryna": 19} for key in people_years: print(key) for value in people_years.values(): print(value) for name, year in people_years.items(): print(f"{name} is {year} years old")
false
9dc4874947764da50df7f064e85a48f8da0e1427
allisongorman/LearnPython
/ex6.py
975
4.46875
4
# The variable x is a string with a number x = "There are %d types of people." % 10 # The variable is a string binary = "binary" # The variable is a string do_not = "don't" # The variable is a string that contains to string variables (1) y = "Those who know %s and those who %s." % (binary, do_not) # Display e...
true
864ca61914c5ed4fc07f60ac7809d780d0d1ead9
prkuna/Python
/24_Slicing_ListComprehension_Multi_Input.py
704
4.15625
4
# Let us first create a list to demonstrate slicing # lst contains all number from 1 to 10 lst = list(range(1,11)) print(lst) # below list has number from 2 to 5 lst1_5 = lst[1:5] print(lst1_5) # below list has numbers from 6 to 8 lst5_8 = lst[5:8] print (lst5_8) # below list has numbers from 2 to 10 l...
true
15b3aa68352d4d0e61561fba36d67a3313b73d10
prkuna/Python
/33_Operator_All.py
710
4.40625
4
# Here all the iterables are True so all # will return True and the same will be printed print (all([True, True, True, True])) # Here the method will short-circuit at the # first item (False) and will return False. print (all([False, True, True, False])) # This statement will return False, as no # True ...
true
f3677abd9e2f6cfd571168968da284db06a3264e
dmonisankar/pythonworks
/DataScienceWithPython/sample_python_code/iteration/iteration2.py
949
4.75
5
# Create an iterator for range(3): small_value small_value = iter(range(3)) # Print the values in small_value print(next(small_value)) print(next(small_value)) print(next(small_value)) # Loop over range(3) and print the values for i in range(3): print(i) # Create an iterator for range(10 ** 100): googol googol ...
true
4dbdc22f0297113db71b3be921e829e7a0af9cfc
naaeef/signalflowgrapher
/src/signalflowgrapher/common/geometry.py
1,897
4.1875
4
import math # taken from: # https://stackoverflow.com/questions/34372480/rotate-point-about-another-point-in-degrees-python def rotate(origin, point, angle): """ Rotate a point counterclockwise by a given angle around a given origin. The angle should be given in radians. """ ox = origin[0] oy...
true
6571604b6d7c0da12ec7ca49c79f22e25f58031e
michaelnakai/PythonProject
/print.py
1,327
4.375
4
# Demonstration of the print statement # Other information # print("Hello World") # print('Hello World') # print("I can't do it") # print('Michael sure "tries"') # # Escape Characters # print('This is the first line \nThis is the second line') # # print integer and an integer string # print(35) # print('35') # # Co...
true
7e77da4149037d49b2d915cbf27689ff01f8dde4
laraib-sidd/Data-Structures-And-Algortihms
/Data Structures/Array/Merge Array.py
788
4.21875
4
""" Shortcut way def mergesortedarr(a,b): x=a+b x.sort() return x a=[1,2,3,4] b=[3,7,9,12] qw=mergesortedarr(a,b) print(qws) """ # In interview we must solve only like this def mergesortarray(arr1, arr2): ''' Function to implement merge ''' if len(arr1) == 0 or len(arr2) == 0: return arr1 + a...
false
387646766e4bfb174e1007b4586aa5a178149a50
laraib-sidd/Data-Structures-And-Algortihms
/Data Structures/Array/String reverse.py
505
4.34375
4
''' Function to reverse a string. Driver Code: Input : "Hi how are you?" Output : "?uoy era woh iH" ''' def reverse(string): """ Function to reverse string """ try: if string or len(string) > 2: string = list(string) string = string[::-1] string = "".join(st...
true
c982cc2c3ae1d0c70ed0ba17f0535bc9f0b349d6
onkar444/Tkinter-simple-projects
/Rock_Paper_Scissors_Game.py
2,363
4.3125
4
#importing the required libraries import random import tkinter as tk #create a window for our game window=tk.Tk() window.title("Rock Paper Scissors") window.geometry("400x300") #now define the global variables that we are going to #use in our program USER_SCORE=0 COMP_SCORE=0 USER_CHOICE="" COMP_CHOICE="" ...
true
95171efb5910f91d9862c370014134e18dffbadc
ucsd-cse8a-w20/ucsd-cse8a-w20.github.io
/lectures/CSE8AW20-01-09-Lec2-Functions/functions.py
351
4.15625
4
# takes two numbers and returns the sum # of their squares def sum_of_squares(x, y): return x * x + y * y test1 = sum_of_squares(4, 5) test2 = sum_of_squares(-2, 3) # NOTE -- try moving test1/test2 above function definition? # takes two strings and produces the sum # of their lengths def sum_of_lengths(s1, s2):...
true
a49d236fd70cf2c4c6456a1a36972143b7de6ae7
sttagent/impractical-python-projects
/PigLatin/pig_latin.py
460
4.125
4
def convert_to_pig_latin(word): is_vowel = test_if_vowel(word[0]) if is_vowel: converted_word = word + 'way' else: partitioned_word = word.partition(word[0]) converted_word = partitioned_word[2] + partitioned_word[1] + 'ay' return converted_word def test_if_vowel(letter): ...
false
ebfa533261b02fe4b7799167b266d177eb1ba818
luismmontielg/project-euler
/euler001.py
737
4.1875
4
print """ Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ------------------------------------------------------------------------------ 1 + 2 + 3 + 4 + ... +...
true
bcb419aeccdb8d5d2b4187f501dd7b1a23be5f9c
shen-huang/selfteaching-python-camp
/19100104/imjingjingli/d3_exercise_calculator.py
1,538
4.3125
4
# 定义函数 def add(x, y): """ 加法运算 parameter x: 被加数 parameter y: 加数 return x + y: 和 """ return x + y def subtract(x, y): """ 减法运算 parameter x:被减数 parameter y:减数 return x - y:差 """ return x - y def multiply(x, y): """ 乘法运算 parameter x:被乘数 parameter y:乘数 return x *...
false
44e1e5c8fc57a96622c7bc7a0037e985091566eb
shen-huang/selfteaching-python-camp
/19100102/jynbest6066/d3_exercise_calculator.py
668
4.15625
4
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") calculator = input("Enter choice(1/2/3/4):") num1 = int(input("Enter first n...
false
35bcd5fe3a3bd0ad94cba7ac9ed045010c1b820f
shen-huang/selfteaching-python-camp
/19100304/lllp1736/d3_exercise_calculator.py
725
4.15625
4
#简易版本计算器 # 加 def add(x, y): return x + y # 减 def subtract(x, y): return x - y # 乘 def multiply(x, y): return x * y # 除 def divide(x, y) return x / y print("选择对应的运算方式") print("1.加") print("2.减") print("3.乘") print("4.除") choice = input("输入(1/2/3/4):") num1 = int(input("输入第一个数字")) num2 = int(input("输入...
false
848266fdc465abc24c86f094f45b2fdc7c825a5a
shen-huang/selfteaching-python-camp
/exercises/1901050117/1001S02E03_calculator.py
365
4.15625
4
operator=input('enter your operator(+、-、*、/): ') number_1=input('enter your first number: ') number_2=input('enter your second number: ') a=int (number_1) b=int (number_2) #addition print("{}+{}={}".format(a,b,a+b)) #subtraction print("{}-{}={}".format(a,b,a-b)) #multiplication print("{}*{}={}".format(a,b,a*b)) #divi...
false
d3663009bc284e80647393c9de19544fc90bec96
shen-huang/selfteaching-python-camp
/19100303/Luchen1471/d3_exercise_calculator.py
671
4.125
4
# Fibonacci series: #a, b = 0, 1 #print('\nThe fibonacci series is:') #while a<100: # print(a, end=" ") # a, b=b, a+b #print('...\n') print('\nHello! I\'d like to help you to do the math homework. Feel free to try me!') x=float(input("Please tell me a float number here:")) #A=input("please tell me what kind of o...
false
60d6ca3d2a88bd66ab05ed6a179a52c5256a71ec
shen-huang/selfteaching-python-camp
/exercises/1901100258/1001S02E03_calculator.py
480
4.1875
4
operator = input('Please enter an operator (+, -, *, /) : ') first_number = input('Please enter the first number : ') second_number = input('Please enter the second number : ') a = int(first_number) b = int(second_number) if operator == '+': print(a, '+', b, '=', a + b) elif operator == '-': print(a, '-', b, ...
true
d7996d9ef1923366651cf33969e97933e7222297
shen-huang/selfteaching-python-camp
/exercises/1901100017/1001S02E03_calculator.py
875
4.15625
4
# calculator # filename 1001S02E03_calculator.py firstchoice = 1 calculatchoice = 0 while firstchoice == 1: print("this is a calculator program 1. use calculator 2. end") firstchoice = int(input("what is your choice ")) if firstchoice == 1: print("I can do 1. plus 2. minus 3. multiply 4. divi...
true
040f0149ae74fa525eae37ac866dece09fb1fdd8
shen-huang/selfteaching-python-camp
/19100304/yeerya/d3_exercise_calculator.py
757
4.1875
4
def add(x,y): """相加""" return x+y def subtract(x,y): """相减""" return x-y def multiply(x,y): """相乘""" return x*y def divide(x,y): """相除""" return x/y print("请选择运算:") print("1、相加") print("2、相减") print("3、相乘") print("4、相除") choice=input("请输入你的选择(1/2/3/4):") num1=int(input("请输入第一个数字:")) num...
false
fdaa0f8d2e6dd84e15cd207cd4c11163acb07371
shen-huang/selfteaching-python-camp
/exercises/1901100148/1001S02E03_calculator.py
1,274
4.3125
4
# 这是单行注释 ''' 这是 多行注释 注释的作用只是方便我们理解代码,并不参与执行 ''' """ 这也是 多行注释 """ # 计算器确定三个输入值,分别是运算符、运算符左边的数字和右边的数字 # 把内置函数 input 接收的 输入字符 赋值 给 变量 operator=input('请输入运算符(+、-、*、/):') # input里面的字符串的作用是在等待输入的时候进行提示 first_number=input('请输入第一个数字:') second_number=input('请输入第二个数字:') a=int(first_number) # int(first_number) 在这里的作用是 把 str...
false
d080f97ad8eceef9ba2b6f15771f54c3a2036cf7
shen-huang/selfteaching-python-camp
/exercises/1901010074/1001S02E03_calculator.py
864
4.15625
4
def add(num1,num2): return num1 + num2 def subtract(num1,num2): return num1 - num2 def multiply(num1,num2): return num1 * num2 def divide(num1,num2): return num1 / num2 print("please select operation -\n" \ "1. ADD\n" \ "2. Subtract\n" \ "3. Multiply\n" \ "4. Divide \n" ...
false
ad287d0f899615c6bc9d13c813b564133633c76a
shen-huang/selfteaching-python-camp
/19100301/Xuzhengfu/d5_exercise_array.py
917
4.21875
4
# 三、数组操作,进制转换 # 1、…… # 2、将数组 [0,1,2,3,4,5,6,7,8,9] 翻转 numbers = [0,1,2,3,4,5,6,7,8,9] numbers.reverse() # 3、翻转后的数组拼接成字符串 num_str_list = [str(num_str) for num_str in numbers] # 使用list comprehension生成列表 numbers_str = "".join(num_str_list) # Join all items in the list "num_str_list" into the stri...
false
b12a49beb2e4b3c5bcd812c463bcc9e70282f0e6
shen-huang/selfteaching-python-camp
/exercises/1901100030/1001S02E05_array.py
943
4.25
4
# day5 字符串练习 # 2019年7月9日 # 陈浩 学号 1901100030 #对列表进行翻转 sample_list = [0,1,2,3,4,5,6,7,8,9] #print(sample_list) #<<<<<<< master #======= #reversed_list = sample_list.reverse() #>>>>>>> master sample_list.reverse() reversed_list = sample_list print(reversed_list) #拼接字符串 #<<<<<<< master #join_str="" #for i in reversed_lis...
false
d222aaea0d8a9ede5eb11cbb905686340b2d6a29
shen-huang/selfteaching-python-camp
/exercises/1901080011/1001S02E03_calculator.py
966
4.25
4
def add(x,y): return x+y def subtract(x,y): return x-y def multiply(x,y): return x*y def divide(x,y): return x/y first_num = float(input("Enter first number: ")) second_num = float(input("Enter second number: ")) operator = input("Enter operator: ") if operator=='+': result = add(first_nu...
true
d769a1c83e5fbdb58f580f374d440da392baa762
shen-huang/selfteaching-python-camp
/exercises/1901080001/1001S02E03_calculator.py
759
4.1875
4
# 流程图:定义函数-输入数值-输入运算操作-输入数值-输出结果 # 定义加法、减法、乘法、除法的运算操作函数 def add( x, y): return x + y def sub( x, y): return x - y def multi( x, y): return x*y def div( x, y): return x/y num1 = input('请输入第一个数字:') opt = input('请选择要进行的运算操作相关数字(1、加 2、减 3、乘 4、除):') num2 = input('请输入第第二个数字:') opt = int(opt) num1 = int(...
false
0886f4ae059aa95e703646c7bdcb7a19eed5b78a
shen-huang/selfteaching-python-camp
/exercises/1901050061/1001S02E03_calculator.py
2,535
4.375
4
output = 0 num1 = "" operation = "" num2 = "" ''' In python, user input on the command line can be taken by using the command input(). Putting in a string (optional) as a paramter will give the user a prompt after which they can input text. This statement returns a string with the text the user typed, so it needs to ...
true
8e9a7834b813a54fea009d051dca97d670c8a40b
shen-huang/selfteaching-python-camp
/19100302/7Lou/d3_exercise_calculator.py
447
4.28125
4
#加减乘除计算器 # 思路:分三步输入 计算 输出 #输入 input()函数 #计算 + - * /,提供可选择项 #输出 print()函数 x = input('x:') y = input('y:') z = input('请选择+ or - or * or /:') if z == '+': print(float(x)+float(y)) elif z == '-': print(float(x)-float(y)) elif z == '*': print(float(x)*float(y)) elif z == '/': print(float(x)/float(y)) elif z...
false
fb1bd2740282ae93bb5ff150a13267fd344d1040
shen-huang/selfteaching-python-camp
/exercises/1901100137/1001S02E05_array .py
490
4.15625
4
[0,1,2,3,4,5,6,7,8,9] #1 翻转数组 number= [0,1,2,3,4,5,6,7,8,9] number1 = list(reversed(number)) print(number1) #翻转后的数组拼接成字符串 str1= ''.join([str(i) for i in number1]) print(str1) #用字符串切片的方式取出第三到第八个字符 str2 = str1[2:8] print(str2) #字符串翻转 str3 = str2[::-1] print(str3) #转为int型 int1= int(str3) #6 分别转换二进制,八进制,十六进制 print(int1...
false
142c0280b62831f4b4611ce2a683f3bc8008bbbd
shen-huang/selfteaching-python-camp
/exercises/1901090039/1001S02E03_calculator.py
830
4.15625
4
#加、减、乘、除计算器 #定义加法 def add(x,y): return x + y #定义减法 def subtract(x,y): return x - y #定义乘法 def multiply(x,y): return x * y #定义除法 def divide(x,y): return x / y #用户输入 print("可进行的运算") print("1,加法") print("2,减法") print("3,乘法") print("4,除法") choice = input("请输入要进行的运算符号(1/2/3/4):") num1 = int(input("请输入...
false
e3a2a93ae901a793c00bfcb123388dfb011f910a
shen-huang/selfteaching-python-camp
/19100401/shense01/d3_exercise_calculator.py
677
4.125
4
def add(x,y): return x + y def subtract(x,y): return x - y def multiply(x,y): return x * y def divide(x,y): return x / y print("选择运算方式:") print("1、+") print("2、-") print("3、*") print("4、/") num1 = int(input("输入第一个数字:")) choice = input("输入运算器选择(1/2/3/4):") num2 = int(input("输入第二个数字:")) if choice == ...
false
372c25294fa9dc1ddf2e7445cc76d981cc90a27b
shen-huang/selfteaching-python-camp
/exercises/1901050034/1001S02E01_calculator.py
362
4.1875
4
num1 = float(input('please enter one number:')) num2 = float(input('please enter another number:')) op = input('please enter a operational symbol:') if op == '+': print(num1,'+',num2,'=',num1+num2) if op == '-': print(num1,'-',num2,'=',num1-num2) if op == '*': print(num1,'*',num2,'=',num1*num2) if op == '/'...
false
bb0d6aa3d6c274b5783ad1c154724c31f2aaea75
vladkudiurov89/PY111-april
/Tasks/a0_my_stack.py
836
4.34375
4
"""My little Stack""" my_stack = [] """Operation that add element to stack :param elem: element to be pushed :return: Nothing""" def push(elem): global my_stack my_stack.append(elem) return None """Pop element from the top of the stack :return: popped element""" def pop(): global my_stack if len(my_stack) ...
true
b2f358cfc90b32d48a3cae4c613763fd066702a7
billpoon12138/python_study
/Advance_Features/Iteration.py
426
4.125
4
from collections import Iterable d = {'a': 1, 'b': 2, 'c': 3} # iterate key in default condition for key in d: print(key) # iterate value for value in d.values(): print(value) # iterate items for k, v in d.items(): print(key, ':', value) # judge an object whether can be iterated isiterable = isinstance('abc',...
true
ddcbead5ff1a78eaed4e1d81b4cf1adc088c2170
JakNowy/python_learn
/decorators.py
2,109
4.15625
4
# # FUNCTION BASED DECORATORS # def decorator_function(original_function): # def wrapper_function(): # print('Logic before') # result = original_function() # print('Logic after') # return result # return wrapper_function # # @decorator_function # def original_function(): # pr...
true
a9920180a5cfcc87b785b384e0163f7cf7f4c5a9
vedmara/ALgorithms_python_lessons_1-8
/lesson_1/lesson_1_Task_2.py
573
4.125
4
#Выполнить логические побитовые операции «И», #«ИЛИ» и др. над числами 5 и 6. # Выполнить над числом 5 побитовый сдвиг вправо и влево на два знака. a = 5 print(a, " = ", bin(a)) b = 6 print(b, " = ", bin(b)) print(a, " & ", b, " = ", a&b, "(", bin(a&b), ")") print(a, " | ", b, " = ", a|b, "(", bin(a|b), ")") prin...
false
c842cd6d2a6c01b8b4301fb82e45bd812b8b2b86
gregmoncayo/Python
/Python/arrayList.py
2,099
4.21875
4
lis = [] # array list # Main menu for user display def Menu(): print("A. See the list ") print("B. Add to the list ") print("C. Subtract from the list") print("D. Delete the entire list") print("E. See the size of your list") print("F. Reverse") print("G. Search the list") print("H. Qui...
true
2400616ad90902a303878407bc543b56103e48b4
jgambello2019/projectSet0
/ps0.py
2,877
4.4375
4
# 0. Write a boolean function that takes a non-negative integer as a parameter and returns True if the number is even, False if it is odd. It is common to call functions like this is_even. def is_even(int): '''Returns true if number is even, false if odd''' divisibleByTwo = int % 2 return divisibleByTwo == 0 # 1. W...
true
aa182293c7d48552d5f7454953d3e7d6bb999cad
AHKerrigan/Think-Python
/exercise4_2.py
1,131
4.375
4
import math import turtle def polyline(t, n, length, angle): """Draws n line segments with the given length and angle (in degrees) between them. t is a turtle. """ for i in range(n): t.fd(length) t.lt(angle) def polygon(t, length, n): """Draws an Ngon made up of equal angles of the given length t is a turtl...
false
62c63539e4b9b726a3fb5d41ead0ebcb669c8df5
AHKerrigan/Think-Python
/exercise3_2.py
1,435
4.5
4
# A function object is a value you can assign to a variable or pass as an argument. For # example, do_twice is a function that takes a function object as an argument and calls # it twice: # def do_twice(f): # f() # f() #Here’s an example that uses do_twice to call a function named print_spam twice: # def print_spa...
true
65fa427c004588b2ea12bc496314b9a46e1b0f71
AHKerrigan/Think-Python
/exercise9_4.py
934
4.28125
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 9-4: Write a function named uses_only that takes a word and a string of letters, and that returns True if the word co...
true
a3dab7ee3a4f4219af5795df3251825ed25e22f4
AHKerrigan/Think-Python
/exercise5_5.py
554
4.28125
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 5-5: This exercise is simply a copy-paste to determine if the reader understands what is being done. It is a fractal ...
true
31f411dbe5909272f0ddd95da8b43b7718da423c
AHKerrigan/Think-Python
/exercise10_9.py
1,007
4.15625
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ s Exercise 10-9: Write a function that reads the file words.txt and builds a list with one element per word. Write two versions...
true
57a8b9a6d6d36e3046373e8e018e4e48c8c6ebe3
ypratham/python-aio
/Games/Rock Paper Scissor/rps.py
2,469
4.1875
4
import random print('ROCK PAPER SCISSORS') print('-' * 20) print('\nInstructions:' '\n1. This game available in only Computer v/s Player mode' '\n2. You play 1 round at a time' '\n3. Use only rock, paper and scissor as input') input('\nPress Enter to continue') while True: choice = str(input('Do...
true
80503d61dc785101e8ccfdb85a0de5bedf55600d
harerakalex/code-wars-kata
/python/usdcny.py
523
4.15625
4
''' Create a function that converts US dollars (USD) to Chinese Yuan (CNY) . The input is the amount of USD as an integer, and the output should be a string that states the amount of Yuan followed by 'Chinese Yuan' For Example: usdcny(15) => '101.25 Chinese Yuan' usdcny(465) => '3138.75 Chinese Yuan' The convers...
true
aeb7486fae65a77dc97c2b4151a900dcf8ac4b36
harerakalex/code-wars-kata
/python/fibonacci.py
1,918
4.15625
4
''' Problem Context The Fibonacci sequence is traditionally used to explain tree recursion. def fibonacci(n): if n in [0, 1]: return n return fibonacci(n - 1) + fibonacci(n - 2) This algorithm serves welll its educative purpose but it's tremendously inefficient, not only because of recursion, but beca...
true
6b1dc0b9eedc1e8ebf819738c060a6b8ab238eb3
profnssorg/valmorMantelli1
/exer504.py
429
4.1875
4
###Titulo: Exibe números impares ###Função: Este programa exibe todos os números ímpares até o número escolhido pelo usuário ###Autor: Valmor Mantelli Jr. ###Data: 10/12/20148 ###Versão: 0.0.2 # Declaração de variáve x = 1 n = 0 # Atribuição de valor a variavel n = int(input("Digite o número final. O programa exib...
false
4065723d8f4ab99639325c1789d639fd4cf9b6ab
profnssorg/valmorMantelli1
/exer403.py
724
4.1875
4
###Titulo: Maior valor ###Função: Este programa pergunta tres números e exibe o de maior valor ###Autor: Valmor Mantelli Jr. ###Data: 08/12/20148 ###Versão: 0.0.3 # Declaração de variável a = 0 b = 0 c = 0 maior = 0 menor = 0 # Atribuição de valor a variavel a = int(input("Diga o primeiro número inteiro: ")) b...
false
768cf5d7a78e2b362923349ea5ef094f147cb784
profnssorg/valmorMantelli1
/exer606.py
1,494
4.125
4
###Titulo: Organizador de fila ###Função: Este programa organiza entradas e saídas de duas filas ###Autor: Valmor Mantelli Jr. ###Data: 31/12/2018 ###Versão: 0.0.2 ### Declaração de variáve último = 0 fila1 = [] fila2 = [] x = 0 operação = [] ### Atribuição de valor while True: print ("\nExistem %d clientes...
false
a56defabab48718524a7eac281fd4fc28052488c
NotGeobor/Bad-Code
/Password Generator.py
2,307
4.40625
4
# user input word = input("Choose a website: ").lower() # list tracks repeats in string repeats = [] # length variable makes working with 2 different lengths of the "word" string easier length = len(word) # tracks even/odd position in string index with 2 being even and 1 odd odd = 2 # dictionaries used to capitaliz...
true
4e33aa5b846349604f6aa5b5361fb0c00407c221
nileshnegi/hackerrank-python
/day009/ex55.py
778
4.375
4
""" Company Logo Given a string ```s``` which is the company name in lowercase letters, your task is to find the top three most common characters in the string. Print the three most common characters along with their occurrence count. Sort in descending order of occurrence count. If occurrence count is the same, sort ...
true
085de4e412b65c6610e8fd079bfe151dd6598725
nileshnegi/hackerrank-python
/day015/ex98.py
699
4.40625
4
""" Map and Lambda Function You have to generate a list of the first `N` fibonacci numbers, `0` being the first number. Then, apply the map function and a lambda expression to cube each fibonacci number and print the list. """ cube = lambda x: x**3 # complete the lambda function def fibonacci(n): # return a list...
true
de64cf80d0e029df3e4c97f366071ce001653fec
nileshnegi/hackerrank-python
/day001/ex5.py
1,178
4.5625
5
""" Lists Consider a list. You can perform the following functions: insert i e: Insert integer ```e``` at position ```i``` print: Print the list remove e: Delete the first occurrence of integer ```e``` append e: Insert integer ```e``` at the end of the list sort: Sort the list pop: Pop the last element from the list r...
true
4951d729fe33ec638a78ff43dbf3b0c474ee74ac
nileshnegi/hackerrank-python
/day014/ex89.py
644
4.1875
4
""" Validating Credit Card Numbers A valid credit card has the following characteristics: It must start with `4`, `5` or `6`. It must contain exactly 16 digits `[0-9]`. It may have digits in groups of 4, seperated by a hyphen `-`. It must not use any seperators like ` `, `_`, etc. It must not have `4` or more consecut...
true
19649a71c597222f34d4e1192683c9a27c4c586c
nileshnegi/hackerrank-python
/day009/ex59.py
320
4.15625
4
""" Set .add() The first line contains an integer ```N```, the total number of country stamps. The next ```N``` lines contains the name of the country where the stamp is from. """ if __name__ == "__main__": country = set() for _ in range(int(input())): country.add(input()) print(len(country))
true
0e91aad14d9c1287ecdf38786cdad445c4bc36ed
Daniyal56/Python-Projects
/Positive OR Negative Number.py
622
4.5625
5
# Write a Python program to check if a number is positive, negative or zero # Program Console Sample Output 1: # Enter Number: -1 # Negative Number Entered # Program Console Sample Output 2: # Integer: 3 # Positive Number Entered # Program Console Sample Output 3: # Integer: 0 # Zero Entered user_input = int(input("E...
true
d9ea424c5adcd7c2d7ad207f2ad1c254d7ff90ff
Daniyal56/Python-Projects
/Sum of a Number.py
584
4.25
4
## 14. Digits Sum of a Number ### Write a Python program to calculate the sum of the digits in an integer #### Program Console Sample 1: ##### Enter a number: 15 ###### Sum of 1 + 5 is 6 #### Program Console Sample 2: ##### Enter a number: 1234 ###### Sum of 1 + 2 + 3 + 4 is 10 print('=================================...
true
5f52bd1beda25e36c57098ac0187b79688e45457
seed-good/mycode
/netfunc/calculator.py
1,968
4.28125
4
#!/usr/bin/env python3 """Stellantis || Author: vasanti.seed@stellantis.com""" import crayons # function to calculate def calculator(first_operand, second_operand, operator): print('Attempting to calculate --> ' + crayons.blue(first_operand) + " " + crayons.blue(operator) + ...
true
ebaf0f43bc2fbe1238c48669acd256fc949dccaf
ostrbor/prime_numbers
/public_key.py
538
4.125
4
#!/usr/bin/env python #Find two random prime number of same size #and return it's product. from functools import reduce from check import is_prime size = input('Enter size of number: ') min = 10**(size-1) max = 10**size-1 def find_primes(min, max): '''Find two different biggest prime number''' res = [] ...
true
9d68d62847e213ca97ba6d8805b0c1ab73afcf7e
Lucky0214/machine_learning
/isin_pd.py
544
4.25
4
# isin() function provides multiple arguments import pandas as pd df = pd.read_csv("testing.csv") print(df) #We are taking same concept which is not better for coder mask1 = df["class"] =="a" #mask is used for finding same type in a perticular column print(df[mask1]) mask2 = df["class"] == "b" mask3 = df["class"...
true
e46cbac7f53f918c16c35bdc0121a64e8fd7d0f4
ShreyashSalian/Python_count_vowel
/Program2.py
295
4.34375
4
#Wap to count the number of each vowel in string def count_vowel(string): vowel = "aeiou" c = {}.fromkeys(vowel,0) string = string.lower() for co in string: if co in c: c[co] += 1 return c string = input("Enter The String : ") print(count_vowel(string))
true
2a20357da5c6c782ee190906d8706fdb793dc0b2
Pixelus/MIT-6.0.0.1-problems
/ps1a.py
1,686
4.4375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 7 17:02:11 2018 @author: PixelNew """ ############################################################################### # You decide that you want to start saving to buy a house. You realize you are # going to have to save for several years before you...
true
e7bed62194217f93e2508a54436dae60e9dd08f6
jsillman/astr-119-hw-1
/functions.py
618
4.46875
4
#this program prints every value of e^(x) for x ranging from 0 to one less than # a given value, or 9 by default import numpy as np import sys def exponent(x): #exponent(x) function: returns e^(x) return np.exp(x) def show_exponent(x): #show_exponent(x) function: prints the result of for i in range(x): ...
true
f5d5765b913fc91176d15e94d9222d03d276cb02
qiaoy9377/python-base
/第一天练习代码/5.字符串.py
2,616
4.15625
4
#打印变量的数据类型 a = 'hello world' b = 'abcdefg' print(type(a)) print(type(b)) #字符串输入 # name = input('请输入你的名字:') # print(f'您输入的名字为{name}') # print(type(name)) # # password = input('请输入您的密码:') # print('您输入的密码为%s'% password) # print(type(password)) #字符串name=“abcdef”,取到不同下标对应的数据 name = 'abcdefg' print(name[0]) print(name[1]) ...
false
9b02571f769a49486363f882624e8a33a5799bd8
fszatkowski/python-tricks
/2_decorators_and_class_methods/6.py
959
4.34375
4
import abc # ABC (abstract base classes) package provides tools for creating abstract classes and methods in python # Abstract classes must inherit from abc.ABC class # Then @abd.abstractmethod can be defined class BaseClass(abc.ABC): @abc.abstractmethod def greet(self): pass # Abstract class ca...
true
1c6a8a019de03c58205068b13ea9aa343867ba30
Alasdairlincoln96/210CT
/Week 1/Question 1.py
1,805
4.28125
4
from random import * newarray = [] used = [] def create_array(): '''A function which asks the user to enter numbers into an array, the user can carry on entering numbers as long as they want. All the inputs are checked to make sure they are an integer.''' array = [] done = False print("To finis...
true
a90ef4442ea6bb682b1d193310c3ad7b0a670310
Alasdairlincoln96/210CT
/Week 0/Question 1.py
1,255
4.125
4
number1 = False number2 = False number3 = False number4 = False while number1 == False: try: a = int(input("Please enter a number: ")) number1 = True except valueerror: print("Thats not a number. Please enter a whole number: ") number1 = False while number2 == False: try: ...
true
269bd14dc41c21e35ddce507a7a1bb2154c79010
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/primitive types/numbers.py
738
4.375
4
x = 1 y = 1.1 # a + bi # complex numbers, where i is an imaginary number. # we use `j` in python syntax to represent the imaginary number z = 1 + 2j # standard arithmetic math operations print(10 + 3) # addition print(10 - 3) # substraction print(10 * 3) # multiplication print(10 / 3) # division - returns a floa...
true
7fd189d0f76b16e509eabcd8a12786f19641a6fa
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/popular python packages/pynumbers/app.py
2,543
4.4375
4
import numpy as np # use of alias to shorten module import # array = np.array([1, 2, 3]) # print(array) # print(type(array)) # returns `<class 'numpy.ndarray'>` # creating multi-dimensional array # this is a 2D array or a matrix in mathematics # this is a matrix with 2-rows and 3-columns # array = np.array([[1, 2, ...
true
33603d4f428fa7eb1e4a44390281a94547a5503f
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/data structures/map_function.py
408
4.28125
4
items = [ ("Product1", 10), ("Product2", 9), ("Product3", 12) ] # say we want to transform the above list into a list of prices (numbers) # prices = [] # for item in items: # prices.append(item[1]) # print(prices) # returns a map object which is iterable # x = map(lambda item: item[1], items) # conv...
true