blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4345f6601d08be66b47368f450854c28a6bc8061
larrydanny/learning-python
/lists_method.py
1,790
4.3125
4
numbers = [3, 2, 7, 4, 5, 1] print("Add new value 22 at the end on the list") numbers.append(22) print(numbers) print("Add new value 10 at 2 index on the list") numbers.insert(2, 22) # 2 is index and 10 is value print(numbers) print("Get index of given item 7") print(numbers.index(7)) print("If given item not in l...
true
594c5161b6fd9de2d840508cfb1a2f219a8fac81
larrydanny/learning-python
/lists.py
776
4.4375
4
names = ["Larry", "Danny", "Python", "List", "Name"] print("Full lists:") print(names) print("Get name using index of lists:") print(names[2]) print("Update 3 index text lists:") names[3] = "React" print(names) print("Using range operator [start:end]:") print("Display 2 and 3 index value means less one from end inde...
true
aa5ae5867e1103ef8f5292bce27d53d022b0b065
nanako-chung/python-beginner
/Assignment 1/ChungNanako_assign1_problem2.py
1,666
4.46875
4
# Nanako Chung # September 16th, 2016 # M/W Intro to Comp Sci # Problem #2: Using the print function # First, we must name the class by asking the user to store data into a variable. We use the input function to do this. name1 = input("Please enter name #1: ") name2 = input("Please enter name #2: ") name3 = input("Ple...
true
f329ca2ce2c101107f77409d0a0645c233ab2b95
nanako-chung/python-beginner
/Assignment 5/ChungNanako_assign5_problem1.py
1,970
4.3125
4
#Nanako Chung #Intro to Computer Programming M/W #October 24th, 2016 #Problem #1: Pizza Party #create counter for slices needed to get total amount of slices needed for order slices_needed=0 #ask user for budget, cost of each slice, cost of each pie, and num of people budget=float(input("Enter budget for your party: ...
true
e64be02c858f43b52e83a034195af1176159b8b0
carlosmaniero/ascii-engine
/ascii_engine/pixel.py
1,393
4.125
4
""" This module contains the a pixel representation In this case a pixel is a character in the screen """ class Pixel: """ A pixel is the small part in the screen. It is represented by a character with a foreground and background color. """ def __init__(self, char, foreground_color=None, backgrou...
true
96057fafac5f7ed6ef5a7f48757d6ff954017122
Pavankumar45k/Python
/Array Programs/Array rotation.py
692
4.5
4
#Array Rotation from array import * n=int(input("Enter a Number to shift arrays towards left:")) a=array('i',{11,12,13,14,15}) print("Type of a is:",type(a)) #to print array before conversion print("\n Array Before conversion:") for i in range(len(a)): print(a[i],end=' ') # to move the array towards left by n times ...
true
e1d6f5861ef558f55d25b36fa374db78e99c0ce9
paramprashar1/PythonAurb
/py5g.py
553
4.40625
4
# Dictionaries employee = {"eid": 101, "name": "John", "salary": 30000} print(employee) # eid is key and 101 is value print(max(employee)) print(min(employee)) print(len(employee)) employee["eid"] = 222 # updating values of keys KEYS cant be changed but there values can be print(employee["eid"]) print(list(employee....
true
bfcca2e9fe1fbd72974f1e1af21f8d33e08d4bce
paramprashar1/PythonAurb
/py4e.py
524
4.15625
4
#Cart is an empty list with len as 0 """ cart=["Chicken"] cart.append("Dal Makhni") cart.append("Paneer Butter Masala") print(cart) cart.extend(["Noodles","Manchurian"]) print(cart) cart.insert(1,"Soya Champ") print(cart) cart.pop(2) print(cart) print(cart[2]) """ cart=[] choice="yes" while choice=="yes" or choice==...
true
610597451753b96e327a6667da5ea037c5de63b2
B-Rich/Python-Introduction
/Conjectures.py
1,248
4.46875
4
# Python 3.5.2 # TITLE: Conjectures # 1. The Collatz Conjecture - Recursive # Prints the Collatz Conjecture for integer n. # # Given any initial natural number, consider the sequence # of numbers generated by repeatedly following the rule: # - divide by two if the number is even or # - multiply by 3 and add 1 if the ...
true
15604fd17c3cb6d1561ac199524e0fd25381d84e
maiarawill/python
/mundoDois_Atividade06.py
620
4.21875
4
import datetime atual = datetime.date.today().year nascimento = int(input('Qual o seu ano de nascimento')) idade = atual - nascimento if idade <= 9: print('O atleta tem {} anos e esta na categoria: Mirim'.format(idade)) elif 9 < idade <= 14: print('O atleta tem {} anos e esta na categoria: Infantil'.format(i...
false
e623d4524ddf421984209674ed104b63028cadee
dhanendraverma/Daily-Coding-Problem
/Day730.py
1,800
4.28125
4
''' /*************************************************************************************************************************************** Good morning! Here's your coding interview problem for today. This problem was asked by Google. What will this code print out? def make_functions(): flist = [] for i in [1...
true
3a5a348b95550fcf3e64bf989c252dc57908180e
JoonasSipilae/2021_Python_JoonasSipilae
/Examples/conditions.py
912
4.125
4
print() a = 10 b = 20 # Vertailuoperaattoreita # == yhtäsuuruusvertailu if a == b: print(a, "equals", b) # sep-parametrillä voidaan määritellä erotinmerkki else: print(a, "does not equal", b) # != erisuuruusvertailu if a != b: print(a, "does not equal", b) else: print(a, "equals", b) if not a == b...
false
4a9fe3ccaf192afbdcac732dc1b9d043bd3eae3d
marioalvarez/master-phyton
/09-listas/predefinidas.py
719
4.5
4
#Funciones y metodos mas comunes cantantes = ['2pac','drake','bad bunny','julio iglesias'] numeros = [1,2,5.5,6,3,4] #ordenar print(numeros) numeros.sort() print(numeros) #añadir elementos cantantes.append("mario alvarez") cantantes.insert(1, "super mario") print(cantantes) #Eliminar elementos cantantes.pop(1) can...
false
a8d8e375f3b2b6e92c774522a33ee26d8bc2189b
marioalvarez/master-phyton
/11-ejercicios/ejercicio1.py
1,513
4.59375
5
""" Ejercicio 1. Hacer un programa que tenga una lista de 8 numeros enteros y haga lo siguiente: hecho-Recorrer la lista y mostrarla hecho-hacer una funcion que recorra listas de numeros y devuelva un string hecho-ordenarla y mostrarla hecho-mostrar su longitud hecho-buscar algun elemento ( que el usuario pida por tecl...
false
f1af8664ba9acd95d8896575d605335fd14c4795
HectorGarciaPY/primer1.py
/Selecció simple/selsimp1.py
670
4.125
4
print("Selecciona un coche:") print("a) Porsche") print("b) Lamborghini") print("c) Maserati") x=input() if x=="a" or x=="A" or x=="a)" or x=="Porsche" or x=="porsche" or x=="Porche" or x=="porche" or x=="Porxe" or x=="porxe": print("Has escogido un Porsche") elif x=="b" or x=="B" or x=="b)" or x=="Lamborghini" or ...
false
d7d92a9e21aadd244e73b707f8de43be22824179
Elaviness/GB_start_python
/lesson5/task_5.py
724
4.21875
4
""" Создать (программно) текстовый файл, записать в него программно набор чисел, разделенных пробелами. Программа должна подсчитывать сумму чисел в файле и выводить ее на экран. """ with open("lesson5_5.txt", 'w') as num_file: num_file.write('1 6 7 8 2 9 3 4') with open("lesson5_5.txt", 'r') as num_file: st...
false
839a0bee39b3bdee1449563c823f613b2472c8b3
Elaviness/GB_start_python
/lesson5/task_2.py
651
4.125
4
""" Создать текстовый файл (не программно), сохранить в нем несколько строк, выполнить подсчет количества строк, количества слов в каждой строке. """ with open("lesson5_2.txt", 'r+' , encoding="utf-8") as file: str_list = ['stroka_1\n','stroka_2\n','stroka_3333\n'] file.writelines(str_list) lines_count ...
false
abc009f223364ec951d3ebe0a8f39e7263a7c786
afaubion/Python-Tutorials
/Basic_Operators.py
1,115
4.34375
4
# basic order of operations number = 1 + 2 * 3 / 4.0 print(number) print("\n") # modulo remainder = 11 % 3 print(remainder) print("\n") # using two multiplication symbols creates power relationship squared = 7 ** 2 cubed = 2 ** 3 print(squared) print(cubed) print("\n") # using operators with strings helloworld = "he...
true
77ee5325d1f6a6f0a8a63f3b12e8f7168df9535f
afaubion/Python-Tutorials
/Multiple_Function_Arguments.py
2,653
4.90625
5
# Every function in Python receives a predefined number of arguments, if declared normally, like this: # ----- def myfunction(first, second, third): # do something with the 3 variables ... # ----- # It is possible to declare functions which receive a variable number of arguments, # using the following syntax:...
true
20396ec6f593c24fa5e7ed56b51f435e228bae31
afaubion/Python-Tutorials
/List_Comprehensions.py
1,378
4.75
5
# List Comprehensions is a very powerful tool, # which creates a new list based on another list, in a single, readable line. # For example, let's say we need to create a list of integers # which specify the length of each word in a certain sentence, # but only if the word is not the word "the". # Ex: ----- sentence = ...
true
a18e422bb8013ca18c3786ea758b633a03990b1a
chrishoerle6/Leetcode-Solutions
/Python/Easy/Sorting and Searching/First_Bad_Version.py
1,429
4.25
4
## Author: Chris Hoerle ## Date: 08/20/2021 ''' You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also...
true
b2a7820b20882ce1f52cc14c690d40088948f961
chrishoerle6/Leetcode-Solutions
/Python/Easy/Math/Count_Primes.py
775
4.1875
4
## Author: Chris Hoerle ## Date: 08/20/2021 ''' Count the number of prime numbers less than a non-negative number, n. Examples: Input: n = 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. Input: n = 0 Output: 0 Input: n = 1 Output: 0 Constraints: 0 <= n <= 5 * 106...
true
5a8f02c10fbe40bdfd555d1b0d186b19ca38c7f1
chrishoerle6/Leetcode-Solutions
/Python/Easy/Trees/Validate_Binary_Tree.py
1,434
4.28125
4
## Author: Chris Hoerle ## Date: 08/12/2021 ''' Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys ...
true
7c265be4916796794f9bca60890936bbc0ade1d9
chrishoerle6/Leetcode-Solutions
/Python/Easy/Trees/Convert_Sorted_Array_To_Binary_Search_Tree.py
1,467
4.125
4
## Author: Chris Hoerle ## Date: 08/20/2021 ''' Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one. ...
true
2c1ac11465f615cb91c849da97e6a576598de69e
JacksonLeng/Computer-Science
/python_midterm_review 4/answers/16.py
517
4.40625
4
# 16. Movies You Want to See: # Use a for-loop and sorted() to print your list in alphabetical order # without modifying the actual list. # Show that your list is still in its original order by printing it as well. movies_i_want_to_see = ['Space Jam', 'Hidden Figures', 'The Pursuit of Happyness', 'Shrek', 'Independe...
true
90b1816c6f0616b2787b56d0973135e50abe4921
JacksonLeng/Computer-Science
/PYTHON WOK/4-6--4-13/4.11.py
304
4.15625
4
pizzas=['tao yuan pizza','Cyn pizza','beef pizza'] friend_pizzas=pizzas[:] pizzas.append('wu han pizza') friend_pizzas.append('tomato pizza') print("My favorite pizzas are:") for pizza in pizzas: print(pizza) print("My friend’s favorite pizzas are:") for pizza in friend_pizzas: print(pizza)
false
c88b07dd9446dcf5d006d64a8f65168a9f4778ce
sb2rhan/PythonCodes
/MSTutorials/Conditionals.py
1,267
4.21875
4
# price = input("How much did you pay: ") # price = float(price) # converting price to float # if price >= 1.00: # tax = .07 # else: # tax = 0 # print("Tax rate is: " + str(tax)) # country = input("Enter the name of your country: ") # if country.capitalize() == "Kazakhstan": # print("Hey, I'm from the...
false
6e3ecec16a91fd3bb6160ce85b791a0c9a3e3237
sb2rhan/PythonCodes
/ITStepTutorials/OOP/classes_intro.py
2,948
4.15625
4
class Car: mark = 'Tesla' model = 'P100D' year = 2019 def start(self): return f'Car {self.mark} {self.model} has been started' def stop(self): return f'Car {self.mark} {self.model} has been stopped' """ Difference between static method and class method: 1. Static ...
true
5bc4e90a4ad1e45ae203c529b5533631ebb7269f
sb2rhan/PythonCodes
/ITStepTutorials/Collections_Functools/func_tools.py
2,483
4.1875
4
# Functools # a module of high-level functions # they are used to modify other low-level functions # so they are decorators import functools # lru_cache for storing repetetive data import requests # # caches get_webpage function # @functools.lru_cache(maxsize=24) # def get_webpage(module): # webpage = f'https:/...
true
b706d6841a0b6897b63bdade35d603bb3d16e859
mehraveh/ChatSubjects
/filtering.py
456
4.1875
4
def filtering(str, words): if str.endswith("ها") : str = str.replace("ها" , "") elif str.endswith("هاش"): str = str.replace("هاش" ,"") elif str.endswith("های"): str = str.replace("هاش" , "") str_tmp = str if len(str_tmp) > 0: str_tmp = str.replace(str[len(str)-1] ,"...
false
8c2a61c1c0d630b774bc4b0bcdcbe78b1e1311e7
dunste123/cassidoo-rendezvous
/142_one_row/index.py
855
4.15625
4
# Given an array of words, return the words that can be typed using letters of only one row on a keyboard. # # Extra credit: Include the option for a user to pick the type of keyboard they are using (ANSI, ISO, etc)! # # Example: # # $ oneRow(['candy', 'doodle', 'pop', 'shield', 'lag', 'typewriter']) # $ ['pop', 'lag',...
true
317253748627559c6b607815d60d04a0c77792b5
dunste123/cassidoo-rendezvous
/138_backspacing/index.py
942
4.21875
4
# Given two strings n and m, return true if they are equal when both are typed into empty text editors. The twist: # # means a backspace character. # # Example: # # > compareWithBackspace("a##c", "#a#c") # > true // both strings become "c" # # > compareWithBackspace("xy##", "z#w#") # > true // both strings be...
true
df3a99027d7b39c8f83a46ec18018d1231a5fb62
shubhamjante/python-fundamental-questions
/Programming Fundamentals using Python - Part 01/Assignment Set - 03/Assignment on string - Level 2.py
1,081
4.34375
4
""" Given a string containing uppercase characters (A-Z), compress the string using Run Length encoding. Repetition of character has to be replaced by storing the length of that run. Write a python function which performs the run length encoding for a given String and returns the run length encoded String. Provide di...
true
7f7bbd1e45f33fd18705e43ef2f2185d33103ef5
shubhamjante/python-fundamental-questions
/Programming Fundamentals using Python - Part 01/Assignment Set - 02/Assignment on selection in python - Level 3.py
2,127
4.125
4
""" FoodCorner home delivers vegetarian and non-vegetarian combos to its customer based on order. A vegetarian combo costs Rs.120 per plate and a non-vegetarian combo costs Rs.150 per plate. Their non-veg combo is really famous that they get more orders for their non-vegetarian combo than the vegetarian combo. Apart ...
true
bc98f7142d565d2ae272698b052eb1c61016453d
shubhamjante/python-fundamental-questions
/Programming Fundamentals using Python - Part 02/Assignment Set - 07/Assignment on list APIs - Level 3 (puzzle).py
1,726
4.1875
4
""" Use Luhn algorithm to validate a credit card number. A credit card number has 16 digits, the last digit being the check digit. A credit card number can be validated using Luhn algorithm as follows: Step 1a: From the second last digit (inclusive), double the value of every second digit. Suppose the credit card num...
true
f9264a548ddafcd40ffaa986e376baa7a219fbb5
drsantos20/mars-rover
/rover.py
2,640
4.21875
4
""" INPUT AND OUTPUT Test Input: 5 5 1 2 N LMLMLMLMM 3 3 E MMRMMRMRRM Expected Output: 1 3 N 5 1 E """ class rover: def __init__(self): """All the variables are initialised here.""" self.x = 0 self.y = 0 self.direction = 'N' self.left = 'L' self.right = 'R' self.move = 'M' self.north = 'N' sel...
true
1c9ab9ee06ed409ecd052ffae5dc104135ab1c3a
ziwuniao/py000
/ex07+.py
1,442
4.15625
4
# 1.注释 # 输出字符串。 print("Mary had a little lab.") # 输出带格式化变量的字符串。 print("Its fleece was white as {}".format('snow')) # 输出字符串。 print("And everywhere that Mary went.") # 输出字符串并且运算。额,真是个偷懒的好办法啊。 print("." * 10) # what'd that do? # 输出一系列单个字母型自串符。(做的时候不明所以。后来发现有彩蛋。作者的幽默。) end1 = "C" end2 = "h" end3 = "e" end4 = "e" end5 = "...
false
63be02823e11adf100f08cf09996b868a71f271e
saurav188/python_practice_projects
/square_root.py
397
4.3125
4
#Given a positive integer, find the square #root of the integer without using any built #in square root or power functions #(math.sqrt or the ** operator). #Give accuracy up to 3 decimal points. def sqrt(x): a=0 b=x y=(a+b)/2 while round(a,3)!=round(b,3): if y**2>x: b=y ...
true
ad08317c8a72d9fd6d1f5439390b78ce4e9da8ea
chenxingyuoo/learn
/python_learn/廖雪峰python/1.python基础/3.使用list和tuple.py
1,128
4.125
4
# list 初始化后可以修改 classmates = ['Michael', 'Bob', 'Tracy'] print(classmates) len(classmates) print(classmates[0]) print(classmates[-1]) classmates.append('Adam') classmates.insert(1, 'Jack') print(classmates) classmates.pop() classmates.pop(1) print(classmates) s = ['python', 'java', ['asp', 'php'], 'scheme'] prin...
false
387076d31be9acfd5f41edccab076a7e70149482
chenxingyuoo/learn
/python_learn/廖雪峰python/20.异步io/1.协程.py
1,081
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 生产者生产消息后,直接通过yield跳转到消费者开始执行,待消费者执行完毕后,切换回生产者继续生产,效率极高: def consumer(): r = '' while True: n = yield r if not n: return print('[CONSUMER] Consuming %s...' % n) r = '200 OK' def produce(c): c.send(None) n = 0 ...
false
19e32cd3149e716ad1449b5ecb461a1fcc30074d
nimbinatus/LPHW
/ex20.py
1,642
4.46875
4
# import argv function from sys module from sys import argv # set up argv script, input_file = argv # defines the function print_all, which prints a file passed in the function # call def print_all(f): print f.read() # defines a function rewind, which finds the beginning of a file using the # seek file object an...
true
c1a524d57adab1f93d3e7c7264e74e99238803f2
najibelkihel/python-crash-course
/Chapter 4 Working with Lists - Lessons/magicians.py
1,081
4.59375
5
players = ['magic', 'lebron', 'kobe'] # use of for LOOP to apply printing to each player within player variable. for player in players: print(player) # for LOOP has been defined, and each item from the 'players' loop has been # stored in a new variable called 'player'. # for every player in the players list # ...
true
5f85b795aa9102b6cc0b2ccb8a3c4711004cad78
najibelkihel/python-crash-course
/Chapter 5 If Statements - Lessons/toppings.py
1,763
4.3125
4
# Chapter 5, 'Checking for inequality', p.78 requested_topping = 'mushrooms' if requested_topping != 'anchovies': print('Hold the anchovies!') # Above: the if statement is asking if requested_topping is NOT equal to # 'anchovies', then the string 'Hold the anchovies!' should be printed. # Because the requested_t...
true
68554c29ec432067bca62a6c2913ce163e4c0d15
najibelkihel/python-crash-course
/Chapter 5 If Statements - Lessons/toppings2.py
1,770
4.4375
4
# Using if statements with lists, p.89 requested_toppings = ['mushrooms', 'green peppers', 'extra cheese'] for requested_topping in requested_toppings: print('Adding ' + requested_topping + '!') print('\nFinished making your pizza!') # for requested_topping in requested_toppings: if requested_topping == 'g...
true
9e736ad8cc2847d518cd7afd9b0d170345e89df8
najibelkihel/python-crash-course
/Chapter 8 Functions - Lessons/person.py
981
4.25
4
# Returning a dictionary p.144 def build_person(first_name, last_name, age=''): """return a dictionary of information about a person""" person = {'first': first_name, 'last': last_name, } if age: person['age'] = age return person athlete = build_person('lebron', '...
true
a9700460ba4ae908e41039b424b0a9bd3c0635bb
najibelkihel/python-crash-course
/Chapter 8 Functions - Exercises/sandwiches.py
1,499
4.15625
4
# Exercises p.155 # 8-12 def make_sandwich(*items): """Creates a list of items to be included in a sandwich""" print("Here are the ingredients that you've selected for your sandwich:") for item in items: print("\t- " + item.title().strip()) make_sandwich('tomato', 'cucumber', 'mayonnaise', 'chi...
true
8813e1a302ddf207ab90febfe14525db900d7b87
devopstasks/PythonScripting
/5-Data Structures of Python/25-Dictionaries.py
1,161
4.1875
4
''' =================================== Print the method names of Dictionary: print(dir({})) python2: Dictionary is un-ordered python3: Dictionary is ordered =================================== my_dict={} print(my_dict,type(my_dict)) print(bool(my_dict)) ''' ''' my_dict={"fruit":"apple","animal":"tiger",3:"abc","hhh":8...
false
64d6a779e986580cf41e7efcf7b57e26c8041ed1
devopstasks/PythonScripting
/5-Data Structures of Python/24-Tuples.py
552
4.4375
4
''' =========================== Strings and Tuples are immutable Tuple operations: dir((2,3)) Print the method names of Tuples: print(dir(())) =========================== ''' my_empty=() my_tuple=(2,7,[4,9,3],5) ''' print(bool(my_empty)) print(bool(my_tuple)) print(my_tuple) print(my_tuple[1]) print(my_tuple[2]) print(...
false
33841596590431b3ef442ced977d4c755d95dc08
devopstasks/PythonScripting
/11-Loops - for and while loops with break, continue and pass/46-Practice-Read-a-path-and-check-if-given-path-is-a-file-or-a-directory.py
422
4.28125
4
''' ====================== Read a path and check if given path is a file or directory ======================= ''' import os path=input("Enter your path: ") if os.path.exists(path): print(f'Given path: {path} is a valid path') if os.path.isfile(path): print(" and it is a file path") else: pri...
true
5491ddab91157c08bd1a3cd538ce271ab337681a
devopstasks/PythonScripting
/5-Data Structures of Python/23-Lists.py
1,217
4.40625
4
''' =================== Lists are mutable Strings are immutable Print the method names of Lists: print(dir([])) ================== my_list=[] my_list=[2,8,3,"python",7.2,] bool(empty_list)==>False bool(non_empty_list)==>True my_list=[2,8,3,"python",7.2,] print(my_list,type(my_list)) print(my_list[0]) print(my_list[3]...
false
8426de85b92caa2223c5d5087aa1807a39b1577d
devopstasks/PythonScripting
/7-Conditional statements/32-Introduction-to-conditional-statements-simple-if-condition.py
897
4.28125
4
''' ================================== if is called simple conditional statement. Used to control the execution of set of lines or block of code or one line if expression: statement1 statement2 ================================== ''' ''' import os t_w=os.get_terminal_size().columns given_str=input("Enter your s...
true
3a1e4dc2107c16d005b6e188b45ffbee48018c54
wangjun1998a/pythonWorkSpace
/2018-12-1/函数的参数.py
1,217
4.1875
4
# 定义函数的时候,我们把参数的名字和位置确定下来,函数的接口定义就完成了。 # 对于函数的调用者来说,只需要知道如何传递正确的参数,以及函数将返回什么样的值就够了, # 函数内部的复杂逻辑被封装起来,调用者无需了解。 # # Python的函数定义非常简单,但灵活度却非常大。除了正常定义的必选参数外, # 还可以使用默认参数、可变参数和关键字参数,使得函数定义出来的接口, # 不但能处理复杂的参数,还可以简化调用者的代码 # 我们先写一个计算x2的函数 def power(x): return x * x # 现在,如果我们要计算x3怎么办?可以再定义一个power3函数, # 但是如果要计算x4、x5……怎么办?我...
false
16f61816cb29366d110add2564d808c3c5a29fea
muthazhagu/simpleETL
/randomdates.py
2,622
4.25
4
from datetime import date import random def generate_random_dates(startyear = 1900, startmonth = 1, startday = 1, endyear = 2013, endmonth = 12, endday = 31, today = True, numberofdates = 1): """ Method returns a list of n dates between a ...
true
701de8c100f4b6f5efd602d8d68ea154af834f1d
SRSJA18/assignment-1-JaedynH99
/Problem3/repeating_lyrics.py
1,092
4.3125
4
"""Assignment 1: Problem 3 Extension: Repeating Lyrics""" ''' Many songs use repetition. We can use variables to manage that repetition when printing out the lyrics. Here is the chorus for Rick Astley's 'Never Gonna Give You Up' Never gonna give you up Never gonna let you down Never gonna run around and desert you Ne...
true
75b331ff1f7643e3ab7e3c6ce6a4fdc38d8c9c4d
ARaj771/Python-Data-Structure-Practice
/02_weekday_name/weekday_name.py
597
4.375
4
def weekday_name(day_of_week): """Return name of weekday. >>> weekday_name(1) 'Sunday' >>> weekday_name(7) 'Saturday' For days not between 1 and 7, return None >>> weekday_name(9) >>> weekday_name(0) """ weekday_dict = { ...
true
63026172deae959ec9d952658c4cbb199aaff0a1
shaz13/PyScripts
/word_end_finder.py
414
4.4375
4
import re # Replace this with your custom dictionary of words file = open('Urdu_words.txt', 'r') text = file.read().lower() file.close() text = re.sub('[^a-z\ \']+', " ", text) words = list(text.split()) string = str(raw_input ("Enter the last ending letters: ")) def EndsWithWordFinder(string): for word in words...
true
b52e609ba07fca225b3bc37f21e33efdaf593662
ivaylospasov/small-budget
/main.py
1,912
4.15625
4
#!/usr/bin/env python3 __author__ = 'ivaylo spasov' from getBudget import currentBudget, path def main(): endProgram = 'no' totalBudget = currentBudget while endProgram == 'no': print('Welcome to the Personal Budget Program') print('Menu Selections: ') print('1-Add an Expense: ') ...
true
aa721dbd6178cf057d6f22f4367cc3f3a66a6d66
AnderSon277/Calculadora
/calcu.py
1,442
4.34375
4
def menu(): print("\n") print(" CALCULADORA BASICA\n") print(" Que operacion desea efectuar: \n") print(" 1.- Suma") print(" 2.- Resta") print(" 3.- Multipliacion") print(" 4.- Division") print(" 5.- Salir") op = int(input("Seleccione su opcion: ")) return (op) def suma(n1,n2): R = n1 + n2 return(R) def...
false
36a0a0504f648c29f9bbd4c4b111cf7935508891
prajakta401/UdemyTraining
/venv/Lect_23_Missing Data.py
1,536
4.28125
4
#Lecture 23 Missing Data import numpy as np from pandas import Series,DataFrame import pandas as pd data = Series(['one','two','np.nan','four']) data.isnull() # returns True is particular index is null. data.dropna()#drops the row which has NaN values dataframe = DataFrame([[1,2,3],[np.nan,5,6],[7,np.nan,9],[np.nan,np....
true
6ff74e53b090bde4f3a66a99c13552724e1f053e
prajakta401/UdemyTraining
/venv/Lecture15_DataFrames.py
1,877
4.125
4
#Lecture 15: Data FRames import numpy as np # array handling import pandas as pd from pandas import Series , DataFrame import webbrowser # grab/scrape NFL data from website website='http://en.wikipedia.org/wiki/NFL_win-loss_records' webbrowser.open(website) #opens the url in nnew browser window #copy few 10 rows and a...
true
0e0f221bd037f809f317a88589bc0ee4804326a4
deborabr21/Python
/PartI_Introduction_To_Programming/Assignment_2_Guess_a_number.py
668
4.15625
4
#Write a program with an infinite loop and a list of numbers. #Each time through the loop the program#should ask the user to guess a number or type q to quit. #If they type q the program should end. Otherwise it should tell them wether or not they successfully #guessed a number in the list or not. numbers = [1,3...
true
ac66422ab45692bd991bf4fcbac5480fce015094
Sahana012/Python-Code
/countwords.py
320
4.1875
4
introstring = input("Enter your introduction: ") wordcount = 1 charcount = 0 for i in introstring: charcount = charcount + 1 if(i == ' '): wordcount = wordcount + 1 print("Number of word(s) in the string: ") print(wordcount) print("Number of characters(s) in the string: ") print(charcount)
true
318407d0b315c828efdd0c8b171b2a3a1106abb8
Psingh12354/PythonNotes-Internshalla
/code/IF_ELSE.py
343
4.125
4
price=int(input("Enter the price : ")) quantity=int(input("Enter quantity : ")) amount=price*quantity if amount>1000: print("You got a discount of 10%") discount=amount*10/100 amount-=discount else: print("You got a discount of 5%") discount=amount*5/100 amount-=discount print("Total ...
true
814e5f1bcf0948ad96ca6acf2fb8191ed4193284
matthewmckenna/advent2018
/aoc_utils.py
689
4.125
4
""" utility functions for Advent of Code 2018. """ from typing import Iterator, List def txt_to_numbers(fname: str) -> List[int]: """read `fname` and return a list of numbers""" with open(fname, 'rt') as f: data = [int(number) for number in f] return data def comma_separated_str_to_int_iterator...
true
fc1336851b836312139a08eca6860207c1439b75
kehkok/koodaus
/simple_tutorial_py/tut_01_factorial/factorial1.py
2,319
4.125
4
""" This module consists of basic factorial, exponential factorial and taylor series of sin functions """ import math def factorial(n): """Compute basic factorial function Parameters ---------- n : integer Specifies the number to be factorial Returns ...
true
5503c5617b63695175b24478a2e9cba0d98156e6
felpssc/Python-Desafios
/AV1 - PYTHON/questao 02.py
689
4.125
4
for n in range(5): substantivo_singular = input('Informe um substantivo no singular: ') substantivo_plural = input('Informe um substantivo no plural: ') adjetivo = input('Informe um adjetivo: ') lugar = input('Informe um lugar: ') verbo = input('Informe um verbo (ex: voar): ') print(f'Era uma ve...
false
7dc6191710fd5cb5fb54414ee212c4bb3946a3cc
camirmas/ctci
/ctci/p1_8.py
1,940
4.125
4
""" Write an algorithm such that if an element in an NxN matrix is 0, its entire row and column are set to 0. """ # def zero_matrix(matrix: list): # "Naive, takes O(N^2) space and O(N^3) time" # zeroed = {} # for r, row in enumerate(matrix): # for c, value in enumerate(row): # if (r, c) ...
true
9a0a8174bcb51364c9d4e49b642d27e3b01e3e94
claashk/python-startkladde
/pysk/utils/ascii.py
655
4.3125
4
# -*- coding: utf-8 -*- REPLACEMENTS={ "ä" : "ae", "Ä" : "Ae", "ö" : "oe", "Ö" : "Oe", "ü" : "ue", "Ü" : "Ue", "'" : "" } def toAscii(string): """Convert string to ASCII string Replaces all non-ASCII charact...
true
07eed30ca73ba360e51a4baf2188cccc44ffa2f6
JayBee12/ITBadgePDT22021
/Example4.py
1,172
4.65625
5
# We use def to define the structure of a function, functions can be created to expect 'arguments' which are data we provide to the function to do something with # The examples below are 'pass by value' arguments in that the value is passed to the function rather than a reference or pointer to the variable itself #Thi...
true
206e8cd5072d54300e968698cd903acdcce3e4d2
jiaoxiaoyou/study
/01-Python/15-test_python/答案/test_07.py
2,436
4.125
4
# @Author : 强小林 # @CreateDate : 2020/5/13 17:54 # @Description : # @UpdateAuthor : # @LastUpdateTime : # @UpdateDescription : """ python打卡第七天 1、利用random函数生成随机整数,从1-9取出来。然后输入一个数字,来猜: 如果大于,则打印大于随机数;小了,则打印小于随机数;如果相等,则打印等于随机数。 2、使用循环和条件语句完成剪刀石头布游戏,提示用户输入要出的拳 :石头(1)/剪刀(2)/布(3)/退出(4) 电脑随机出拳比较胜负,显示用户胜、负还是平局。运行如下图所示: "...
false
0b2627d91942607f1d199c5b30c3a86f81a1a39e
adarsh-tyagi/codes
/Coding_Problem_Solution_21.py
833
4.1875
4
# asked by Google # Given two singly linked lists that intersect at some point, find the intersecting node. # The lists are non-cyclical. # For example, given A = 3 -> 7 -> 8 -> 10 and B = 99 -> 1 -> 8 -> 10, # return the node with value 8. # In this example,assume nodes with the same value are the exact same no...
true
0385f450453320dd2ce5204afa4df1896a2c0e52
adarsh-tyagi/codes
/Coding_Problem_Solution_30.py
1,054
4.375
4
# asked by Facebook # Given a string of round, curly, and square open and closing brackets, # return whether the brackets are balanced (well-formed). # For example, given the string "([])[]({})", you should return true. # Given the string "([)]" or "((()", you should return false. input_string="([])[]{()}"...
true
2f65b8ab45a01075a6bfd5d96f82fac776e1cb23
adarsh-tyagi/codes
/Coding_Problem_Solution_23.py
992
4.1875
4
# asked by Microsoft # Given a dictionary of words and a string made up of those words (no spaces), # return the original sentence in a list. If there is more than one possible reconstruction, return any of them. # If there is no possible reconstruction, then return null. # For example, given the set of words 'qu...
true
246443dfb184b9d7536754b734117ab7880c15fd
adarsh-tyagi/codes
/Coding_Problem_Solution_16.py
492
4.3125
4
# asked by Google # From a given string return the first recurring character of the string. # for e.g. if string id "ABCDBA" then return "B" # if string is "ABCD" return None because no character is recurring. s=input("enter the string: ") def First_Rec_Char(s): char_list=[] for i in s: if i...
true
5b570168559708075d967909b9d7130ac454da75
emil45/computer-science-algorithms
/algorithmic-questions/majority_element.py
553
4.15625
4
from collections import defaultdict def majority_element(l): """ Given an array of size n, find the majority element. The majority element is the element that appears more than floor(n/2) times. You may assume that the array is non-empty and the majority element always exist in the array. """ ...
true
5dc0333d3f75da76eb9d828521f6385335e311bb
venkyms/python-workspace
/scripts/Tag-counter.py
621
4.3125
4
"""Write a function, `tag_count`, that takes as its argument a list of strings. It should return a count of how many of those strings are XML tags. You can tell if a string is an XML tag if it begins with a left angle bracket "<" and ends with a right angle bracket ">". """ def tag_count(html_list): count1 = 0 ...
true
88f8ee6fde8063fe4241094410a119c289207ab9
venkyms/python-workspace
/scripts/Median.py
698
4.125
4
def median(numbers): numbers.sort() #The sort method sorts a list directly, rather than returning a new sorted list middle_index = int(len(numbers)/2) if len(numbers) % 2 == 0: return (numbers[middle_index] + numbers[middle_index - 1]) / 2 else: return numbers[middle_index] test1 = med...
true
831487db53af4f9217a1f0a6e47ed45a184c003e
KimTanay7/py4e
/Excercise3_Conditional.py
698
4.21875
4
print ("**************************") print ("* Activity 3-Conditional *") print ("**************************") name = input("Name:") print ("Hello ",name, "!") print ("This program will print a grade relevant to your score") print (" Please enter score between 0.0 to 1.0") print ("--------------------------------") x=...
true
611fdf2ab6ee60ea5d795455949c4be0bab5db63
Maryam-ask/Python_Tutorial
/File/Delete_a_File/delete_a_file.py
296
4.125
4
# Delete a file import os if os.path.exists("D:\Python_Home\Files\myfile_create.txt"): os.remove("D:\Python_Home\Files\myfile_create.txt") else: print("the file does not exist!") # delete a folder: os.rmdir("D:\Python_Home\Files\My new folder") # !!! You can only remove empty folders.
true
79029b3ed0e8129679df005edbf65bc1212887d6
Maryam-ask/Python_Tutorial
/Collections/Tuple/Tuples.py
1,223
4.5
4
tuple1 = ("apple", "banana", "cherry") print(tuple1) # ***************************************************************************** # Index numbers thistuple = ("apple", "banana", "cherry", "apple", "cherry") print("\n",thistuple) # ***************************************************************************** # Tupl...
false
382d56ce419ead7862cccbbf16b420da26c17d65
Maryam-ask/Python_Tutorial
/Function/Functions_Sololearn/Functional_Programming/Pure_functions.py
1,339
4.5625
5
""" Pure Functions: Functional programming seeks to use pure functions. Pure functions have no side effects, and return a value that depends only on their arguments. This is how functions in math work: for example, The cos(x) will, for the same value of x, always return the same result. Below are examples of pure and ...
true
01b6fc1147f53d6c3c9c0d7db16772ddc378f5ba
Maryam-ask/Python_Tutorial
/Collections/List/AccessListItems.py
1,168
4.40625
4
thislist = ["apple", "banana", "cherry"] print(thislist[1]) # ************************************************************ # Print the last item of the list thislist = ["apple", "banana", "cherry"] print(thislist[-1]) # ************************************************************ # Return the third, fourth, and fifth...
false
7869e3b3f31dde7d7c1f7cff415a0dee1feb6b56
Maryam-ask/Python_Tutorial
/Exercises/__init__.py
465
4.1875
4
""" Sum of Consecutive Numbers: No one likes homework, but your math teacher has given you an assignment to find the sum of the first N numbers. Let’s save some time by creating a program to do the calculation for you! Take a number N as input and output the sum of all numbers from 1 to N (including N). Sample Input 1...
true
562c78f14b3483c4c1dcaeaf013f1412cc94bf88
Maryam-ask/Python_Tutorial
/Collections/Tuple/UpdateTuples.py
944
4.4375
4
# Change Tuple Values x = ("apple", "banana", "cherry") y = list(x) y[1] = "kiwi" x = tuple(y) print("Change Tuple Values: ", x) # **************************************************************** # Add Items: thistuple1 = ("apple", "banana", "cherry") # Halate 1: z = list(thistuple1) z.append("orange") thistuple1 = t...
false
44cf49419a24a9838a0c42dfb1ef9478491cc7c8
Maryam-ask/Python_Tutorial
/Collections/Dictionary/Accessing_Items.py
1,044
4.25
4
thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } # halate 1: x = thisdict["model"] print(x) # halate 2: estefade az methode get(): y = thisdict.get("model") print(y) # Get keys: # The keys() method will return a list of all the keys in the dictionary. key = thisdict.keys() print("List of k...
true
68329f8726017cbaac11286704ac41a23bc49740
Maryam-ask/Python_Tutorial
/Exercises/SearchEngine.py
581
4.28125
4
""" Search Engine: You’re working on a search engine. Watch your back Google! The given code takes a text and a word as input and passes them to a function called search(). The search() function should return "Word found" if the word is present in the text, or "Word not found", if it’s not. Sample Input "This is awes...
true
823453c64a30e699e33631d62187948c115ddc64
Maryam-ask/Python_Tutorial
/Lambda/Lambda_SoloLearn/lambda_soloLearn.py
567
4.5625
5
def my_func(f, arg): return f(arg) my_func(lambda x: 2 * x * x, 5) # ******************************************* # function: def polynomial(x): return x ** 2 + 5 * x + 4 print(polynomial(-4)) # lambda: print((lambda x: x ** 2 + 5 * x + 4)(-4)) # ******************************************* # Lambda fu...
true
e29a4847b55c2cd7195dcf6cb55daf4acbcb5144
Maryam-ask/Python_Tutorial
/Boolean/BooleanPython.py
1,142
4.3125
4
# Boolean 2 meghdar ra barmigardanad -----> 1. True & 2. False # When you run a condition in an if statement, Python returns ----> True or False print(10 > 9) print(10 == 9) print(10 < 9) # ************************************************** print() a = 200 b = 33 if b > a: print("b is greater than a") else...
true
f07f263f54ce47b98c5da02c53235b5ded4511af
alexandremerched/learning-python
/PythonExercicios/World 3/ex075.py
530
4.15625
4
numbers = int(input("Digite um número: ")), int(input("Digite outro número: ")), int( input("Digite outro número: ")), int(input("Digite o último número: ")) print( f"Você digitou os valores {numbers}\nO valor 9 apareceu {numbers.count(9)} vezes") if 3 in numbers: print(f"O valor 3 apareceu na {numbers.in...
false
f43259151faa546e196e321fdb0387967a3cacda
alexandremerched/learning-python
/PythonExercicios/World 2/ex037.py
461
4.21875
4
num = int(input("Digite o número para ser convertido: ")) option = int(input("""Digite 1 para Binário. Digite 2 para Octal. Digite 3 para Hexadecimal. """)) if option == 1: print("O número em binário é igual a {}".format(bin(num)[2:])) elif option == 2: print("O número em octal é igual a {}".format(oct(num)[...
false
792055dda42ef02fc484ef3414846a44d576bffc
CAEL01/learningpython
/variables.py
1,235
4.28125
4
""" Learning to code Variables in Python (via Pirple.com) Using attributes such as Variables, Strings, Integers (positive numbers), Floats (decimals). These attributes define every value of what is to be printed on the computer screen: A text, a positive numeric value, and a decimal value. Using an artist with song ...
true
0ef4536bf68225a6024c75e4ec831bab68c70910
joshuayun/python_edu
/week04/q04_baseball.py
1,102
4.125
4
""" 야구 게임 숫자 3개를 랜덤하게 생성 1~9 사의 수, 중복 X 3 9 4 사용자가 3개의 숫자를 입력하면 Strike : 숫자와 위치가 맞은 경우 Ball : 숫자만 맞은 경우 을 알려준다. 3 strike가 된 경우에만 맞았습니다. 게임을 종료 1. random 2. list 3. while문을 이용한 반복 4. 입력용 함수를 사용 """ # 랜덤하게 3개 숫자 뽑기 import random original_numbers = list(range(1,10)) numbers = random.sample(original_numbers, 3) while T...
false
cfa15a47f62c7539d79c2b10db2abd7e97ee48e3
roorco/alphabetizer
/alphabetizer.py
854
4.53125
5
#!/usr/bin/env python2 #-*-coding:utf-8-*- # modificare per eliminare accenti def abcd(): print "\n-------------------" print "THE ALPHABETIZER 2014" print "by orobor" print "This is a very small program that sorts" print "the letter of your name in an alphabetical order." print "It is supposed...
true
078716f2ff82a6945ae80fd6353d7f72f30aba15
deep743/Python-Day-1-Project
/calculator.py
1,109
4.21875
4
while True: option = input("Enter add or subtract multiply divide percentage quit : ") if option == 'quit': break elif option == 'add': number1 = float(input("Enter first number: ")) number2 = float(input("Enter second number: ")) print(number1 + number2) elif option ==...
false
193d1d993358ab8addd8de6cca80abbabcb51b2e
natmayak/lesson_2
/if_age_hw_v.2.py
1,005
4.125
4
age = int(input("How old are you? ")) def ageist_function(age): if age <= 0: raise ValueError("You are in your parents' plans") elif 0 < age <= 6: print('Having fun at nursery') elif 6 < age <= 16: print('Wasting best years at school') elif 16 < age <= 21: print('Getting...
true
fa47988f2a8ac4c0b0abdb52ebb239c7e5503fb8
siriusgithub/dly
/easy/17/017/Should_I_say_this.py
348
4.15625
4
def triangle(height): line = '@' x= 1 if height == 0: print('Triangle of height 0 not valid!') while x <= height: print(line) line *= 2 x+=1 def reversetriangle(height): line = '@' x= height if height == 0: print('Triangle of height 0 not valid!') while x > 0: line = '@'*2**(x-1) print('{:>...
true
e213e5bea52460a93e747567b934984932d79800
Aaron-Bird/leetcode
/Python/101 Symmetric Tree.py
1,467
4.3125
4
# Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). # For example, this binary tree [1,2,2,3,4,4,3] is symmetric: # 1 # / \ # 2 2 # / \ / \ # 3 4 4 3 # But the following [1,2,2,null,3,null,3] is not: # 1 # / \ # 2 2 # \ \ # 3 3 # Note: #...
true
426b483ca5b06151e7d00bc317cecc8faa096147
Mega-Barrel/10-days-statistics
/interquartile_range.py
1,168
4.1875
4
''' Task The interquartile range of an array is the difference between its first (Q1) and third (Q3) quartiles (i.e., Q3-Q1). Given an array, X, of N integers and an array, F, representing the respective frequencies of X's elements, construct a data set, S, where each x1 occurs at frequency fi. Then calculate an...
true
df83ed57fddab1c66984ad0027cf12df22b4bd69
RenukaDeshmukh23/Learn-Python-the-Hard-Way-Excercises
/ex33.py
773
4.4375
4
i = 0 #intialise to 0 numbers = [] #empty list numbers while i<6: #while loop started print(f"At the top i is {i}") #print the value of i numbers.append(i) #append will add value of i to numbe...
true
61cd552cd7cf0cb8e816f6c6d9054bc6ad6fbccd
jcjcarter/Daily-1-Easy-Python
/Daily 1 Easy Python/Daily_1_Easy_Python.py
268
4.375
4
# User's name. name = input("What is your name? ") # User's age. age = input("How old are you? ") # User's username. username = input("What is your username? ") print('Your name is {0}, you are {1} years old, and your username is {2}.'.format(name, age, username))
true