blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7a0a5f7926f661bdb3061cdad7f232473a5e2a47
cyjhunnyboy/PythonTutorialProj
/pers/cyj/day07/04-异常处理/异常处理.py
2,233
4.28125
4
""" 需求:当程序遇到问题时不让程序结束,而越过错误继续向下执行 try.....except.....else 格式: try: 语句t except 错误码 as e: 语句1 except 错误码 as e: 语句2 ..... except 错误码 as e: 语句n else: 语句e 注意:else语句可有可无 作用:用来检测try语句块中的错误,从而让except语句捕获错误信息并处理 逻辑:当程序执行到try...except...else语句时 1、如果当try"语句t"执行出现错误...
false
e2428d1972b286b13755a7f534ddca4d2ac8459d
cyjhunnyboy/PythonTutorialProj
/pers/cyj/day04/02-list(列表)/list列表方法.py
2,271
4.25
4
# 列表方法 # append 在列表中的末尾添加新的元素 list1 = [1, 2, 3, 4, 5] list1.append(6) print(list1) list1.append([7, 8, 9]) print(list1) # extend 在末尾一次性追加另一个列表中的多个值 list2 = [1, 2, 3, 4, 5] list2.extend([6, 7, 8]) # TypeError: 'int' object is not iterable # list2.extend(9) print(list2) # insert 在下标处添加一个元素,不覆盖原数据,原数据向后顺延 list3 = [1, 2...
false
0ab40b89d111ba1fdd7c3ebdd813b5d21ceb0272
cyjhunnyboy/PythonTutorialProj
/pers/cyj/day06/01-set/set.py
1,436
4.21875
4
""" set: 类似dict,是一组key的集合,不存储value 本质:无序和无重复元素的集合 """ # 创建 # 创建set需要一个list或者tuple或者dict作为输入集合 set1 = set([1, 2, 3, 4, 5]) print(set1) # 重复元素在set中会自动被过滤 print(set([1, 2, 3, 3, 3, 4, 5])) print(set([1, 2, 3, 3, 2, 1])) set2 = set({1:"good", 2:"nice"}) print(set2) # 添加 set3 = set([1, 2, 3, 4, 5]) set3.add(6) print(set3...
false
ddea47ea7104526d791b3c123aaa13d1aaeb62d3
cyjhunnyboy/PythonTutorialProj
/pers/cyj/day04/05-break与continue语句/continue语句.py
395
4.1875
4
""" continue语句 作用:跳过当前循环中的剩余语句,然后继续下一次循环 注意:跳过距离最近的循环 """ for i in range(10): print(i) if i == 3: continue print("*") print("&") print("=================") num = 0 while num < 10: print(num) if num == 3: num += 1 continue print("*") print("&") num += 1
false
786cf0d56d1b916df31862abe73be15d07e33a2a
cyjhunnyboy/PythonTutorialProj
/pers/cyj/day03/01-运算符和表达式的续集/逻辑运算符.py
791
4.28125
4
""" 逻辑与:and 逻辑与运算表达式:表达式1 and 表达式2 值:如果表达式1的值为真,表达式2的值为真,整个逻辑与运算表达式的值为真,否则为假 """ num1 = 10 num2 = 20 if num1 - 10 and num2: print("***********") """ 逻辑或:or 逻辑或运算表达式:表达式1 or 表达式2 值:如果表达式1和表达式2的值其中有一个为真正,整个逻辑或运算表达式的值为真,否则为假 """ num3 = 0 num4 = 1 if num3 or num4: print("逻辑或表达式结果为真") """ 逻辑非:not 逻辑非运算表达式:not 表达式 ...
false
8d3496826ca6dd7bd4aa40bf48a5563f873a86a3
emelleby/in1000
/3_oblig/testing.py
928
4.5
4
liste = [1, 2, 3] l = len(liste) """ Function to calculate the product of the numbers in the list def produkt(liste): produkt_liste = 1 for i in range(len(liste)): produkt_liste *= liste[i] return produkt_liste def produkt(liste): produkt = 1 for i in liste: produkt *= i ret...
false
8e001e5a0e936f366a6f09b7e3c8d0b76fd14c32
leticiafelix/python-exercicios
/04 - Manipulando textos/desafio022.py
621
4.125
4
#faça um programa que leia o nome completo de uma pessoa e mostre: #o nome com todas as letras maiusculas #o nome com todas as letras minusculas #quantas letras tem (sem considerar os espaços) #quantas letras tem o primeiro nome nome = str(input('Insira seu nome completo:')) nome = nome.strip() mai = nome.upper() min ...
false
4229b121411d36062db4f30122e745d7fd523e0e
WHJR-G8/G8_C15_For_Student_Reference
/Student_Project.py
568
4.125
4
import turtle turtle.pensize(4) turtle.pencolor("OliveDrab") turtle.setpos(-50, 0) def repeated_tasks(c,s,a): turtle.fillcolor() for i in [0, 1, 2]: #This function call is to make the house shelter i.e upper part of the house turtle.forward(25) turtle.right(90) #Thi...
true
6c5244b15945d02c986258e76d9da2b1f3da289c
ichan266/Code-Challenges
/Leetcode/Past Code Challenges/05-27-21 shift2Dgrid.py
1,421
4.21875
4
# Leetcode # 1260 # https://leetcode.com/problems/shift-2d-grid/ # Given a 2D grid of size m x n and an integer k. You need to shift the grid k times. # In one shift operation: # Element at grid[i][j] moves to grid[i][j + 1]. # Element at grid[i][n - 1] moves to grid[i + 1][0]. # Element at grid[m - 1][n - 1] moves ...
true
e0ea787e176e1b2e4f868fdb8012ca792e2d9d6c
Sethrick/SelfTaughtP_CompletedExercises
/Python_Althoff_SelfTaughtProgrammer/SelfTaughtP_pp085_Ch05_Challenges.py
1,797
4.46875
4
# 1) Create a list of your favorite musicians. band_list = ["TSFH", "Evancho", "Thomas", "Piano Guys"] print(band_list) # 2) Create a list of tuples, with each tuple containing the longitude # and latitude of somewhere you've lived or visited. Ft_Riley = (39.1101, 96.8100) Gimli_Peak = (49.7661, 117.6469) Keystone...
true
a18650703c788528552895a8a2192dc73d59f70c
Sethrick/SelfTaughtP_CompletedExercises
/Python_Althoff_SelfTaughtProgrammer/SelfTaughtP_pp151_Ch13_Encapsulation.py
1,676
4.4375
4
# Encapsulation in object oriented programming means that both variables # (state) and methods (for altering state or doing calculations) are grouped # together in "objects". class Rectangle(): def __init__(self, w, l): self.width = w # Variables (state) self.len = l def area(self): # Method ...
true
6442273820b2d9041861d6e999377d20be6462d0
Sethrick/SelfTaughtP_CompletedExercises
/Python_Althoff_SelfTaughtProgrammer/SelfTaughtP_pp035_Ch03_ConditionalStatements.py
1,071
4.4375
4
# Making decisions with control structures/conditional statements. # Pseudocode: # If (expression) Then # (code_area1) # Else # (code_area2) # Basic if/else control structure home = "America" if home == "America": print("Hello America") else: print("Hello World") # Multiple if statement...
false
702908e84864118b15aed1a4e935941cfe4c622a
lawrencetheabhorrence/Data-Analysis-2020
/hy-data-analysis-with-python-2020/part02-e09_rational/src/rational.py
1,179
4.21875
4
class Rational(object): def __init__(self, a, b): self.a = a self.b = b def __add__(self, r): # a/b + c/d = (ad + bc) / bd a = self.a * r.b + self.b * r.a b = self.b * r.b return(Rational(a, b)) def __sub__(self, r): a = self.a * r.b - self.b * r.a ...
false
9b96ad978ca5642f2db095845c2902b3dafe603c
RitikaAg/Hacktoberfest-2020-FizzBuzz
/Python/FizzBuzzP2.py
397
4.15625
4
// Another method for creating FizzBuzz // MishManners import sys inputs = sys.argv inputs.pop(0) def fizzbuzz(n): # for n in range(n, num, n + 1): if n % 3 == 0 and n % 5 == 0: print ('fizzbuzz') elif n % 3 == 0: print ('fizz') elif n % 5 == 0: print ...
false
5e9a5d8d18445d8a2ddc2f279947648bf30c99c2
4RG0S/2021-Summer-Jookgorithm
/안준혁/[21.07.13]3613.py
840
4.15625
4
word = input() bigger = False underscore = False makeBigger = False error = False small = False out = [] for alphabet in word: if 'a' <= alphabet <= 'z': small = True if makeBigger: out.append(alphabet.upper()) makeBigger = False else: out.append(alphab...
true
fade9fcc59fd25e22249fec0c309e759687a3db4
JCharlieDev/Python
/Python Programs/TkinterTut/TkGrid.py
375
4.34375
4
from tkinter import * # Mostly everything is a widget # Main Window root = Tk() # Creating label widget myLabel1 = Label(root, text = "Hello world") myLabel2 = Label(root, text = "My name is Charlie") # Putting it on the screen myLabel1.grid(row = 0, column = 0) myLabel2.grid(row = 1, column = 5) # Event l...
true
3f0e54298456bd64e7c15f298faba0f3f0b7d93a
Code360In/21092020LVC
/day_01/labs/02_height_of_the_building.py
438
4.28125
4
# Program to calculate the height of the building # given angle of sight and distance of the measurer from the building import math # input a = float(input("Enter the angle of sight in deg: ")) d = float(input("Enter the distance in mts: ")) # process h = d * math.tan(math.radians(a)) h = h * 3.281 ...
true
18e91eed6e9810bf6b24c6713f9a74984084c8cf
sofmorona/nucoroCurrency
/currencyRates/utils.py
1,571
4.25
4
import datetime import decimal from functools import reduce def checkDateFormat(date_string, format): """ Function to check if the given date has the expected format :param date_string: string to check if is a valid date format :param format: the format expected by the date_string :return: datetime...
true
aeb99449371c2c2c9bea0311b55e7cc265e973bf
Ganesh-sundaram-82/DatastructuresAndAlgo
/DS/Linked-List/LinkedList.py
1,069
4.15625
4
import Node # # head = Node.Node("1") # # head.NextNode = Node.Node("2") # # print(head.value) # # print(head.NextNode.value) #Single Linked-list class LinkedList: def __init__(self): self.head = None def append(self, value): if self.head is None: self.head = Node.Node(va...
true
2f0caf50c2cd55dc92dc8bc98982da0a2cc1143d
Saberg118/Simple_Python_Programs
/password.py
1,125
4.53125
5
""" This is a password generator that prompts the user the day the were born, favoriteFruit, and first name. The new password will contain the the last two letters of their first name, the last digit of the day they were born times 3, first three letter of their favorit fruit, and the first letter of their name capit...
true
9157fb6460d261a48f65e981febc73a2729032f3
zmarrich/beginning-python
/pltlweek7ses1.py
1,056
4.15625
4
###SLIDE ONE print("She said, '"'I dont like to wear a helmet it messes up my hair'"',which is really silly") print("Yes\\No?") print("April\nMay\nJune\n") #####SLide TWO message= 'I like Python.' print(message.lower()) print(message.upper()) print(message.replace('Python','Pasta',1)) #slide 3 ##statement='I like to g...
true
99b2b3031898b7edfb6cf8bf45669075c5d17184
KarlaXimena16/Tarea-04
/NumerosRomanos.py
867
4.1875
4
#encoding: UTF-8 #Autor: Ángel Guillermo Ortiz González #Matrícula: A01745998 #Descripción: Convierte números entre 1 y 10 a números romanos. #convierte números arábigos entre el 1 y el 10 a su correspondiente número romano def convertirNumeroARomano(numero): if numero >= 1 and numero <= 3: romano = numero...
false
d46c23889ec6a85af6e38228d20c8a7215b6d072
byuniqueman/pyproj
/bdate
313
4.1875
4
#!/usr/bin/env python3 # test test test import datetime currentdate = datetime.date.today() userinput = input ("What is your birthday? (mm/dd/yy) ") # format expected below 03/24/1964 birthday = datetime.datetime.strptime(userinput, "%m/%d/%Y").date() print(birthday) days = birthday - currentdate print(days)
true
567c548fc3250b56aa461da9d3d5e9317fa96398
itszrong/2020-Statistics-Tools
/Chi square using contingency table.py
2,387
4.3125
4
data = [] columns = int(input("How many columns are there?")) rows = int(input("How many rows are there?")) array_of_row_sum = [] array_of_column_sum =[] grand_total = 0 #initialising array for column restraints for n in range(columns): array_of_column_sum.append(0) #initialising the observed data an...
true
86194a8c37522488d322d2f6c382aca1d3ec82e6
mcalidguid/string-manipulation
/string_manipulator.py
1,875
4.34375
4
def swap_case(sentence): output = "" for letter in sentence: if letter == letter.upper(): output += letter.lower() else: output += letter.upper() print(">>>: %s" % output) def reverse_swap_words(sentence): output = "" for letter in sentence: if lette...
true
8dfe55144cae789d302f6bcba813b1389e925951
aviik/intellipat_assignments
/Assignment_2_ComDs/05_character_to_string.py
314
4.375
4
#5.Write a Python program to convert a list of characters into a string. # enter some characters my_char = [] while True: foo = input("==>") if foo == 'done': break my_char.append(foo) def string_maker(my_char): my_string = ''.join(my_char) print(my_string) string_maker(my_char)
true
33a3181bfee5926139e75082d94345044a8855c1
aviik/intellipat_assignments
/Assignment _1_(Cond, Loops,Funct)/05_squared_series_of_series.py
286
4.25
4
## 1^2 + ( 1^2 + 2^2 ) + (1^2 + 2^2 + 3^2) + .......+nth_number print("Give the nth number: ") nth_number = int(input("> ")) i = 1 j = 1 sum = 0 while i <= nth_number: total = 0 for j in range(0,i+1): total = total + j**2 sum = sum + total i = i + 1 print(sum)
false
576a955463ff5e791ad3298e5c08d8ff1adfaa99
Luccifer/PythonCourseraHSE
/w02/e16.py
397
4.125
4
# Сколько совпадает чисел def coincidence_of_numbers(num1, num2, num3): if num1 == num2 == num3: ans = 3 elif num1 == num2 or num2 == num3 or num1 == num3: ans = 2 else: ans = 0 return ans if __name__ == '__main__': num1, num2, num3 = int(input()), int(input()), int(input...
false
e6d81842388a1f017975a84b9e97966183acf27a
DTIV/PythonDeepDive
/Variables_and_Memory/dynamic_vs_static.py
649
4.34375
4
# DYNAMIC VS STATIC TYPING ''' Python is dynamically typed - the variable can be whatever, it just changes the memory address for what is needed and rewrites. Static typed must specify type and the variable is specific to that type always ''' print("Python variables can change dynamically throughout the code, changi...
true
40efaa887d904eaf1ac46162ad204045f0ab60ab
R-Gasanov/gmgcode
/String DataType/E_StringsTest.py
1,559
4.5625
5
# Not only can we ask for specific parts of the string, we can modify on how we percieve them as well x = (' Good_Morning ') # Now what we can do with this its change its case from upper to lower, here are the following commands print (x.upper()) # The one above is upper print (x.lower()) # The next one is lower # As ...
true
83cffd1b2b720d02ea4cc84173497d42b5df7019
R-Gasanov/gmgcode
/AllCode/C_Python Practice/B_ DataTypes/String DataType/D_StringsTest.py
1,267
4.625
5
# Now we will be looking at slicing , essentially splitting strings seperately x = 'Good Morning' # Now as you can see from the bottom we're using a colon ':' print (x[:4]) # Now what were doing is we selected a letter through the representation of numericle values print ('#######################') # And using the colo...
true
d02a46f80a02b48025d476b4409155fdda384f19
R-Gasanov/gmgcode
/AllCode/I_Tuples/E_TupleTest.py
2,485
5.0625
5
# We can't technically change its values with a tuple, although there are some unique ways of doing so vegtables = ('cucumber','carrot','zuccini','swiss chard','garlic') # As a small portion of us know, zuccini is not a vegtable veg_list = list(vegtables) # What we're doing here, is converting this tuple into a list, w...
true
95b51884352d71eabe74efbb6466a5744e5135ae
R-Gasanov/gmgcode
/AllCode/B_ DataTypes/NumbersTest.py
848
4.5
4
# We will now be looking at Numbers, and the various types #There are 3 basic types # Integer, a basic whole number x = 1 # Float, a number that is a decimal y = 17.7 # Complex a number with multiple featurs that involves with symbols and letters z = 1j # You can of course convert each number to a different number t...
true
527e950a38182ee8c94a7d20fe610da64b54ce74
R-Gasanov/gmgcode
/AllCode/I_Tuples/A_TupleTest.py
707
4.3125
4
# Now first of lets begin our tests with Tuple, since they can store multiple values lets try it atuple = ('China','America','United Kingdom','Russia','Poland') print (atuple) # As you can see when you review the atuple variable you can see the print ('####################') # Additionally as we have previously expla...
true
5dc7dc9d22063290ee88b2821a9e143ca570023c
R-Gasanov/gmgcode
/AllCode/L_Functions/C_Functiontest.py
1,081
4.53125
5
# Now we will be looking at passing a list as an argument throught the function print ('#######################') # So lets make our function! def my_function(movies): # As per usual we will iterate through the list for x in movies: print (x) # Now lets provide us with the list horror = ['Scream', 'Frid...
true
96213221e172e444f5cec4a847d2b71fbaca52c2
jlheen/python-challenge
/PyPoll/main.py
2,857
4.21875
4
# python-challenge -- PyPoll # Import Modules import os import csv # Read csv file PyPoll_Data = os.path.join("./Unit03 - Python_Homework_PyPoll_Resources_election_data.csv") with open(PyPoll_Data) as csvfile: csvreader = csv.reader(csvfile, delimiter=",") # Skip the header row csv_header = next(csvfile)...
true
24b6df398f7d67ef5c4fa41ae36129d9689aa1c9
amaizing-crazy/kv-055
/python_basic/task3.py
324
4.5625
5
#Define a function reverse() that computes the reversal of a string. # For example, reverse("I am testing") should return the string "gnitset ma I". def reverse(string): rstring = '' for i in string[::-1]: # for i in string[-1:0:-1]: rstring = rstring + i print(rstring) reverse("I am testing") ...
true
7f72822d56efd0bfac9dc8c11d35c1478be6d074
stemlatina/Python-Code
/h3q5MD.py
601
4.21875
4
#Marilu D #Q5MD #User Input a = float(input("Please enter the length of first side: ")) b = float(input("Please enter the length of second side: ")) c = float(input("Please enter the length of third side: ")) #If Statements if a == b and b == c and a ==c : print("This is a equilateral triangle") elif a == b or a ...
true
d835091502b8867ed9d8062b1b48396fafdde20f
blky/python
/learning1/forloop.py
593
4.3125
4
# first line in this doc forLine = 'www.google.com' count = 0 for i in forLine: count +=1 print format(count,'2d'), i else: print('out of for loop') # () is used for tuple , which is read-only - unlike list .. iwth [] tup = (1,2,3,4,5,6) for ea in tup: print ea # file can be thought as string.. therefore, for i...
false
9cfc825230c0c9999879ca4d593c0c241ad9e717
Kelley12/LearningPython
/Blake/Chapter 3 - Functions/practiceProject.py
663
4.34375
4
# Practice Project from Chapter 3: the Collatz Sequence def collatz(number): if number % 2 == 0: number = number//2 print(str(number)) return number else: number = 3 * number + 1 print(number) return number def main(): print('Enter a number:') try: ...
true
cc30c59ecfe69bfe7ef9cef978921b99e5fea390
HeartAttack417/labs4
/individual_1.py
1,187
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Дано предложение. В нем слова разделены одним или несколькими пробелами (символ «-» # в предложении отсутствует). Определить количество слов в предложении. Рассмотреть два # случая: # начальные и конечные пробелы в предложении отсутствуют; # начальные и конечные ...
false
616ae81759d0e0a7535c0224f881092c6df8e407
Prajnahu/Python-program
/paliendrome.py
783
4.15625
4
def palindrome(string): backwards=string[::-1].casefold() return backwards==string.casefold() #returns true or false return palindrome(string) word=input("please enter a word to check") if palindrome(word): print("{} is a paliendrome".format(word)) else: print("{} is not a paliendrome".f...
true
3a7e2f0802f5cf4d660a531474f603bb768b3a96
ddotafonso/CodeCabinet
/revertingstring.py
350
4.28125
4
# Reverting String in Python in O(n) Complexity def revertingString(x): str = "" for word in x: str = word + str return str phrase = "Hi my name is Dimbu" print(revertingString(phrase)) # Reverting a string in O(1) complexity def revertingString(x): print(x[::-1]) phrase = "My name is ...
false
ee1253259b1532b29be46cdc810ce441ebef2a8c
DamocValentin/PythonLearning
/BinarySearchAlgorithm.py
1,404
4.21875
4
# Create a random list of numbers between 0 and 100. # Ask the user for a number between 0 and 100 to check whether their number is in the list. # The programme should work like this. The programme will half the list of numbers and see whether # the users number matches the middle element in the list. If they do not ma...
true
50c69cb28453275cbfc1cf90ae86620d6b6f341b
elenzi/algorithmsproject
/algorithmsproject/bruteforce.py
2,204
4.125
4
import copy from algorithmsproject.airportatlas import AirportAtlas from algorithmsproject.route import Route from algorithmsproject.travelplan import TravelPlan import itertools class BruteForce: """Exhaustively searches for the shortest path.""" def __init__(self, travel_plan: TravelPlan): self.tr...
true
888d75b81e63ba39cea0efd63d6ef386c44279ec
isakfinnoy/INF200
/src/isak_finnoy_ex/ex01/tidy_code.py
1,187
4.375
4
from random import randint as dice __author__ = 'Isak Finnoy' __email__ = 'isfi@nmbu.no' """This is a game of two dices, where the user is trying to guess the correct sum of the two dices, decided by the random.randint function. The max number of valid guess attempts are 3, though you can make as many invalid gues...
true
7dc02f383ad728300cf81c4f2aa999a9dad987a8
Panlq/Algorithm
/剑指offer/两个等长数组和之差最小.py
1,351
4.21875
4
""" 将两序列合并为一个序列,并排序,为序列Source 拿出最大元素Big,次大的元素Small 在余下的序列S[:-2]进行平分,得到序列max,min 将Small加到max序列,将Big加大min序列,重新计算新序列和,和大的为max,小的为min。 """ def mean(sorted_list): if not sorted_list: return [], [] big = sorted_list[-1] print(big) small = sorted_list[-2] print(small) big_lis...
false
a382c532d9dffade4e7cf2ede892e66ac17fc57d
calvinxuman/python_learn
/macheal_liao/recursive_function.py
2,310
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/2/22 09:35 # @Author : calvin #递归函数定义 def fact(n): if n == 1: return n return n*fact(n-1) '''如果一个函数在内部调用自身本身,这个函数就是递归函数. 递归函数的优点是定义简单,逻辑清晰。理论上,所有的递归函数都可以写成循环的方式,但循环的逻辑不如递归清晰. 使用递归函数需要注意防止栈溢出。在计算机中,函数调用是通过栈(stack)这种数据结构实现的,每当进入一个函数调用, 栈就会...
false
6c517a29a5eaff0bbde1474f9a6814956f7fd58b
Jhedie/Comfortable_Python
/CodingBat/biggest_number_index.py
698
4.28125
4
# program to print the index of the biggest number in an array #main function def get_biggest(array): position = 0 return biggest_number(array, position) #recursive function for comparisons def biggest_number(List, position1): if position1 == len(List)-1: return position1 else: #pos...
true
917a9a9479b123d6499b194cd85616606b8f2101
riccab/python-practice
/hello.py
705
4.46875
4
print("hello, world!") """This is a doc string spanning multiple lines""" #print("Enter your name:") x = input("Enter Your name \n") print("Hello, " + x) #The for loop acts as an iterator, does not require an indexing variable #In this example banana will not be printed because print is being skipped by the continu...
true
2ad10828096ea4ab3c4fdd4d5003c49dceaf15e2
gauravgrover95/Learn-Python-The-Hard-Way
/ex45.py
2,249
4.15625
4
class Animal(): def __init__(self, name): self.name = name def speak(self): print "check me out.. I am speaking" ## ?? Dog is-a class of Animal class Dog(Animal): def __init(self, name): ## ?? Dog has-a name self.name = name def speak(self): print "Bow Bow!" ## ?? Cat is-a class of superclass Anim...
false
e0625a5687cc4a2b3d25ace6301be755abcf740c
KevinVaghani/ex01
/2021-10-01_Vaghani_K_matrixMultiplication.py
953
4.15625
4
A=[] print("Enter value for first matrix") for i in range(3): a=[] for j in range(3): j=int(input("enter input for ["+str(i)+"]["+str(j)+"]")) a.append(j) A.append(a) B=[] print("Enter value for second matrix") for i in range(3): b=[] for j in range(3): j=int(input("enter inp...
false
b4061c0f5fd130dd7fa7d1f78a0edf84b32480fc
joaompinto/enclosed
/enclosed/__main__.py
564
4.15625
4
import argparse from enclosed import Parser, is_enclosed def main(): parser = argparse.ArgumentParser(description="Extract enclosed tokens from string") parser.add_argument( "target", metavar="target", type=str, help="full string containing enclosed tokens", ) args = pa...
true
b49f502b495aed530ecd17f4af988ef0f13a151b
BrucePorras/PachaQTecMayo2020-1
/Semana3Sesion2/rcornejo/init.py
1,062
4.21875
4
#Este programa va hacer un carrito de compras #Vamos a pedir el nombre del bodeguero. print ("Hola ¿Cuál es tu nombre?") strbodeguero = input() print (f"{strbodeguero} ingresa tu primer producto") lstproductos = [] lstproductounitario = [] strnombredelproducto = input() print("Ingresa el valor del producto") fltvalorp...
false
ed01c5af7f7bbb690f7867bee4eeacfc38f8762e
juanmager/EstructurasDeDatos
/Recursividad/recursividad_fibonacci.py
784
4.125
4
# Ejercicio 3 # Implementar una función recursiva que calcule los números de la serie de Fibonacci. # La función para generar la serie de Fibonacci es la siguiente (donde N es el índice # del número en la serie): # alt text # Luego escribir un programa que pida un número N (mayor o igual a 0) al usuario e imprima por...
false
eb3bab615bff56be26265fef235a7900259e4dc6
zarjer/Cisco-BlackBeltLevel1
/Task2.py
789
4.125
4
""" Zar Jerome C. Cajudo Task 2 """ #Libraries and Functions always come in handy to developers by allowing reusability of existing code. #There are certain well known inherent libraries that you have access to after installing python. #By using these libraries and functions in them, #write a program (in Pytho...
true
601c9380d30a6e6291cc77ea76e798c9998c9142
vinay432/inputs-from-the-user
/inputs from user.py
434
4.21875
4
#Taking inputs from user,we need to explain the user what type of input to be accepted by code like integer or float, it may be string type. a=input("Enter your lucky number:") #a is a varable to store inputs which is given by user print(a) #printing the lucky number out. #if you wanna specify particularly, user c...
true
14b01be431db3db57e947f724d8978f98f2a3bb2
Lisa-Mays/CMIS102_Assignments
/salesmanpay.py
1,326
4.1875
4
# This program calculates a salesman's weekly pay with a fixed hourly # rate and a fixed commission percentage # Set hourly rate to 27 dollars per hour Declare hourly_rate as float hourly_rate = float(27.00) # Set commission percentage to 25 percent commission_percentage = 0.25 # Prompt for hours worked Declare hour...
true
a88885108e991e9b7204ee9cba4a5f1632406157
gonsan20/misiontic
/Ciclo1/210619/main.py
941
4.125
4
from util import palabras, grafico """ Tareas 1. obtener palabra para adivinar 2. mostrar con __ las letras que conforman la palabra 3. preguntar por una letra al usuario 4. validar si la letra está en la palabra 5. mostrar las letras del palabra 6. preguntar por la palabra 7. validar si ha ganado o no """ def codif...
false
d7f76d7af932f16b1202d118982e8825b01e7816
sunita18808/sunita18808
/Len's Slice.py
666
4.125
4
# Your code below: toppings = ["pepperoni", "pineapple", "cheese", "sausage", "olives", "anchovies", "mushrooms"] prices = [2, 6, 1, 3, 2, 7, 2] num_two_dollar_slices = prices.count(2) num_pizzas = len(toppings) print("We sell " + str(num_pizzas) + " different kinds of pizza!") pizza_and_prices = [[2, "pepperoni"], [6...
true
65f044891f824b888e9a1bcfb652ef32b0e76d7a
supermitch/Chinese-Postman
/chinesepostman/dijkstra.py
2,163
4.125
4
"""Minimum Cost Path solver using Dijkstra's Algorithm.""" def summarize_path(end, previous_nodes): """ Summarize a chain of previous nodes and return path. Chain is a dictionary linked list, e.g. {1: None, 2: 1, 3: None, 4: 2} returns [1, 2, 4] for end = 4. """ route = [] prev = end ...
true
1fc44e0f5bab8bd1caae1f070b6c8ea445d77ed2
gitschwiftyyy/web_caesar
/caesar.py
896
4.15625
4
def encrypt(string, shift): shift = int(shift) shift = shift % 26 newstring = "" for i in range(len(string)): chrnumber = ord(string[i]) chrnumber = int(chrnumber) if chrnumber > 64 and chrnumber < 91: chrnumber = chrnumber + shift if chrnumber > 90 a...
false
0733878ff327550bd6d688ec366b0c52dc1e11a0
jainpiyush26/python_code_snippets
/python_tricks/namedtuples.py
651
4.28125
4
from collections import namedtuple """ syntax is to pass the object name and then the key names as a list of space separated string, I would prefer passing them explicitly as a list! They are still tuples but can be used to store initial value of an object or something like that """ test_obj = namedtuple('test_obj', [...
true
bd4848b15e233d540097077f986b851f57586316
oleg31947/jobeasy-algorithms-course
/lesson_4/HW_4/Count.py
644
4.34375
4
# Write a Python function, which will count how many times a character (substring) # is included in a string. DON’T USE METHOD COUNT # string = input(f"Enter a string ") # substring = input(f"Enter a substring ") def count(given_string, given_substring): counter = 0 if len(given_substring) > len(given_string...
true
3cf40241d8f485cc2e4b71a6ad9fc78f6093689c
oleg31947/jobeasy-algorithms-course
/lesson_4/No duplicate.py
528
4.125
4
# Your task is to remove all duplicate words from a string, leaving only single (first) words entries. # Input # 'alpha beta beta gamma gamma gamma delta alpha beta beta gamma gamma gamma delta' # Output # 'alpha beta gamma delta' def no_duplicate(string): array = string.split(' ') result = [] for item ...
true
3d2de6b37d9b22649f370c9074f1cad602897279
oleg31947/jobeasy-algorithms-course
/lesson_5/My_head_is_at_the_wrong_end.py
735
4.1875
4
# You're at the zoo... all the meerkats look weird. Something has gone terribly wrong - someone has gone # and switched their heads and tails around! # Save the animals by switching them back. You will be given an array which will have three values (tail, body, head). # It is your job to re-arrange the array so that t...
true
d520ea776b4cffaf52273b1ecb9f3b550310b0ed
CoolHappyGuy/python-misc
/ElfName.py
1,784
4.15625
4
#This program determines your elf name based on the initial of the user's name as well as their birth month. FirstInitial = {"a": "Perky", "b": "Nipper", "c": "Bubbles", "d": "Happy", "e": "Squeezy", "f": "Sunny", "g": "Merry", "h": "Tootsie", "i": "Kringle", "j": "Puddin", "k": "Cookie", "l": "Tinker",...
false
e4cdb1a97f4b615353ec503717e9bc4ea0df60ef
mpv33/Advance-python-Notes-
/Threads/Threading.py
1,307
4.15625
4
#!/usr/bin/python import threading import time exitFlag = 0 class myThread (threading.Thread): def __init__(self, threadID, name, counter): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter def run(self): print("Starting " + self.name) ...
true
c4c521b0f14ce7a09573df822d15a5ff7160903f
sifatjahan230/Python-programming
/string/sWAP cASE.py
572
4.3125
4
''' You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. For Example: Www.HackerRank.com → wWW.hACKERrANK.COM Pythonist 2 → pYTHONIST 2 Input Format A single line containing a string S. Constraints 0<len(S)<=1000 Out...
true
820536da887128b6ce19457d296550868b27443e
TanyoTanev/SoftUni---Python-Fundamentals
/Lists_adv_ElectronDistribution.py
1,246
4.15625
4
'''Electron Distribution You are a mad scientist and you decided to play with electron distribution among atom's shells. You know that basic idea of electron distribution is that electrons should fill a shell until it's holding the maximum number of electrons. The rules for electron distribution are as follows: Maxim...
true
9ea71c52d86f9b499eecbba238cf33ffc46a0e59
TanyoTanev/SoftUni---Python-Fundamentals
/Fund_Dictionaries - 6.Courses.py
2,233
4.34375
4
'''6.Courses Write a program that keeps information about courses. Each course has a name and registered students. You ewill be receiving a course name and a student name, until you receive the command "end". Check if such course already exists, and if not, add the course. Register the user into th course. When you rec...
true
a555a9b776d85e3df2d9d0850bc76141bdc02d1b
TanyoTanev/SoftUni---Python-Fundamentals
/Classes Catalogues.py
1,784
4.28125
4
''' Catalogue Create a class Catalogue. The __init__ method should accept the name of the catalogue. Each catalogue should also have an attribute called products and it should be a list. The class should also have three more methods: add_product(product) - add the product to the product list get_by_letter(first_lette...
true
5924f01f7768401e2789650b5c3d20ac165018b0
CZnyu/rock-paper-scissors-exercise
/game.py
1,292
4.125
4
print("Rock, Paper, Scissors, Shoot!") import random arr = ["Rock","Paper","Scissors"] def options (s): if s == "Rock": return arr[0] if s == "rock": return arr[0] elif s == "Paper": return arr[1] elif s == "paper": return arr[1] elif s == "Scissors": ret...
false
96be08c6e3211029ca2c689fd6d2110c2a7365e2
thewalia/CP
/DS/LinkedList.py
1,642
4.1875
4
class Node: def __init__(self, data): self.data = data self.nextNode = None class LinkedList: def __init__(self): self.head = None self.size = 0 def insertStart(self, data): self.size+=1 newNode = Node(data) if not self.head: ...
true
ffe716689c54473c7305bfebc5069a8b41b0ee8a
RayQinruiWang/SelfLearning
/Learning Space/Datascience/Python/Python notes.py
849
4.59375
5
####################################### Data science with Python ######################################## # Dictionary my_dict = { "brand":"ford", "model":"Mustang", "year":1964 } # or to use constructor dict my_dict = dict(brand = "ford", model = "Mustang", year = 1964) # To read by index rea...
true
02eb1a5d54c1329cf1cfb8296782a739a4753508
PBillingsby/CodewarsKata
/Python/oddoreven.py
214
4.4375
4
# Inputs integer and outputs if it is odd or if it is even def even_or_odd(number): if type(number) == int: if int(number) % 2 == 0: return ("Even") else: return ("Odd")
true
50c3767373e9c2a4eb0ee269e3b571907c342673
isaszy/python_exercises
/types, conditional and variable/L1Ex10Triangulos.py
299
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 10 22:08:26 2020 @author: isinha """ def triangulo (a: float, b: float, c: float) -> str: if a + b > c or b + c > a or a + c > b: return 'É lado de triângulo' else: return 'Não é lado de triângulo'
false
80efc890da80fc7ec9eef9d50313399f899f315b
adhikaridev/python_assignment_II
/16_game_model_player_class_8puzzle.py
2,839
4.46875
4
# 16. Imagine you are creating a Super Mario game. You need to define # a class to represent Mario. What would it look like? If you aren't # familiar with SuperMario, use your own favorite video or board game # to model a player. # Because I am not familiar with Super Mario, I am trying to model a # player of game 8-p...
true
729b3bf3510acb4897088e31b25b47175e057e8c
adhikaridev/python_assignment_II
/10_camel_snake_kebab.py
761
4.5625
5
# 10. Write a function that takes camel-cased strings (i.e. # ThisIsCamelCased), and converts them to snake case (i.e. # this_is_camel_cased). Modify the function by adding an argument, # separator, so it will also convert to the kebab case # (i.e.this-is-camel-case) as well. def to_snake_or_kebab(camel, separator): ...
true
f69b77574ae862d8fde1040d31fa1e6a5cac9010
malikyilmaz/Class4-PythonModule-Week4
/3- Number Guessing Game.py
1,926
4.21875
4
""" WAs a player, I want to play a game which I can guess a number the computer chooses in the range I chose. So that I can try to find the correct number which was selected by computer. Acceptance Criteria: Computer must randomly pick an integer from user selected a range, i.e., from A to B, where A and B belo...
true
5f8cba55b7a5ee2e8ccf448ae4d4603592d22296
CWxMaxX/al_python_demo
/Day 1 Basic/Test5.py
417
4.25
4
a = float(input("Number A : ")) b = float(input("Number B : ")) addition = a + b subtraction = a - b multiplication = a * b division = a / b modulus = a % b expoment = a ** b floorDivision = a // b print("A + B = ", addition) print("A - B =", subtraction) print("A * B =", multiplication) print("A / B =", div...
false
5e58817bdbd6be6b022b467bc79ae44861a4b664
PyOrSquare/Python
/Module 1/m1_circumference.py
209
4.5
4
# Calculate Circumference of a Circle with known radius # c = 2 * Pi * radius import math print('Enter Radius') r=input() c=2*math.pi*r print ('Circumference of the Circle with radius %d cms = %.2f'% (r,c))
true
2712a9f2890a5e022ac77e54665d0ff38a2a81df
Ritzing/Algorithms-2
/TernarySearch/Python/ternary.py
647
4.25
4
def ternary_search (L, key): left = 0 right = len(L) - 1 while left <= right: ind1 = left ind2 = left + (right - left) // 3 ind3 = left + 2 * (right - left) // 3 if key == L[left]: print("Key found at:" + str(left)) return elif key == L[right]: print("Ke...
true
186938082eae6b93c9f8d872b59b26e0af6a5e56
Ritzing/Algorithms-2
/SelectionSort/Python/selectionSort.py
906
4.40625
4
def selection_sort(array): """ Selection sort sorts an array by placing the minimum element element at the beginning of an unsorted array. :param array A given array :return the given array sorted """ length = len(array) for i in range(0, length): min_index = i ...
true
2e502c966ce9329c238908a49e712e8c712b8f02
waliasandeep/Learn-python-the-hard-way
/Ex11.py
507
4.21875
4
#Exercise 11 #Taking basic inputs from the user print "How old are you?" age = raw_input() print "How tall are you?" height = raw_input() print "How much do you weigh?" weight=raw_input() print "So you are %r years old,%r tall and %r heavy." %(age, height, weight) #Skipping excersice 12 as it is making y...
true
75f45ea5b4e661377fc66e6c70fb99ae58208473
tapsevarg/1st-Semester
/Session 08/Activity1.py
600
4.25
4
# This is a program for creating multiplication tables. def get_value(): print("Enter value to multiply") value = int(input()) return value def get_expressions(): print("Choose number of expressions") expressions = int(input()) return expressions def process_math(value, expressions): c...
true
de9dfa0449f1ff51bd61f2f0c5f514a58a4c1bfb
nnekaou/TriTesting
/TestTriangle.py
2,090
4.125
4
# -*- coding: utf-8 -*- """ Updated Jan 21, 2018 The primary goal of this file is to demonstrate a simple unittest implementation @author: jrr @author: rk """ import unittest from Triangle import classifyTriangle # This code implements the unit test functionality # https://docs.python.org/3/library/unittest.html ha...
true
cdd2e6f8f01af3a67c7baca73969ef21360d0062
phifertoo/python_basics
/basics/referencing.py
1,021
4.40625
4
# Variables are just references to a value # although you modify the new reference (cheese), the new reference still points to the same data [0, 1, 2, 3, 4, 5] # therefore, any references pointing to the same data will reflect the altered data spam = [0, 1, 2, 3, 4, 5] cheese = spam cheese[1] = 'hello' print...
true
9b20ec2adb891724dd57f4e8a012a160f2d8773f
MohitPanchasara/Sorting-Algorithms
/Heap and Heap Sort.py
2,510
4.28125
4
# Build Heap # Heap Inserton # Heap Deletion # Heap Sort import time import random def Swap(Heap , i , j): Heap[i] , Heap[j] = Heap[j] , Heap[i] def heapify(Heap, n, i): largest = i left_child = 2 * i + 1 right_child = 2 * i + 2 if left_child < n and Heap[i] < Heap[left_c...
false
b0a661b051a1df590b2228e5e37fc76b06dcced3
S-Luther/school-python
/Python-Sam/EvenOdd.py
336
4.4375
4
##Sam Luther ##EvenOdd: It tells you whether or not a inputed number is even ##11/3/16 n=float(input("Please input a number to see if it is even:")) def is_odd(n): c = float(n%2) if(c==0): print(str(n)+' is an even number.') if(c!=0): print(str(n)+' is not an even number.') i...
true
2a1acdf65abf610bdee548968a102a98f5bc4e30
S-Luther/school-python
/Python-Sam/paskal.py
864
4.21875
4
# -----------------------------------------+ # Sam Luther | # pascasl.py | # Last Updated: January 9, 2016 | # -----------------------------------------| # It is a program | # -----------------------------------------+ de...
false
43d8232bf0fbbf7f83083db65ae42d023a1bfdcf
S-Luther/school-python
/Bernard/ThreeTurtleLearn.py
1,010
4.40625
4
#ThreeTurtleLearn #Bernard Kintzing #10/25/16 import turtle #Go to where the mouse is clicked screen = turtle.Screen() screen.onclick(turtle.goto) #Actions based off of key pressed i = 0 def up(): while(1 == 1): turtle.forward(1) def down(): while(1 == 1): turtle.forward(...
false
9a2e7a4b11a51d2891e50055d4e76666e2db3012
afs2015/SmallPythonProjects
/FunPythonProjects/Summation.py
387
4.21875
4
#!/usr/bin/python # Author: Andrew Selzer # Purpose: Simple function that sums all numbers for a provided integer # Example: 5 would return 1 + 2 + 3 + 4 + 5 a.k.a., 15 print ("Type summation(number) to use this program.") def summation(num): counter = 1 tot = 0 while (counter <= num): ...
true
6d849def5e8612e54a2016f4c0e775b753d56323
afs2015/SmallPythonProjects
/FunPythonProjects/StringReverser.py
308
4.71875
5
#!/usr/bin/python # Author: Andrew Selzer # Purpose: Simple function to use reverse a string. print ("Type reverse(text) to use this program.") # This works by reading a string a single character at a time and appending it to a variable. def reverse(text): a="" for i in text: a=i+a return a
true
e5bd4c753f78731fa381f5b3fa2e7211cf14a5ae
Ashuduklan/Algorithms
/Array_Exercise.py
2,462
4.40625
4
# 1. Let us say your expense for every month are listed below, # January - 2200 # February - 2350 # March - 2600 # April - 2130 # May - 2190 # Create a list to store these monthly expenses and using that find out, # # 1. In Feb, how many dollars you spent extra compare to January? # 2. Find out your total expe...
true
41a05c88202898e224c10adb9c8cfe8516926f3f
youzhian/helloPython
/IfAndElsePractice.py
1,053
4.125
4
# -*- coding: utf-8 -*- age = 20 if age >= 18: print("your age is",age) print("adult") # elif是 else if的缩写 age = 3 print("your age is",age) if age >= 18: print("adult") elif age >= 6: print("teenager") else: print("kid") # 使用input()与int() s = input("你的出生年份:") brith = int(s) if brith < 2000: pri...
false
080b9c3e24cdb07ae7385ea5579868798853c437
Shantanu1395/Algorithms
/LinkedList/endTofront.py
961
4.15625
4
class Node(object): def __init__(self,data): self.data=data self.next=None class LinkedList(object): def __init__(self): self.head=None def length(head): temp=head count=0 while temp!=None: count+=1 temp=temp.next return count def pr...
false
d9a9d80a3d4129521c5b10a7762e499565d16754
goatber/dice_py
/main.py
1,342
4.1875
4
""" Dice Rolling Simulator by Justin Berry Python v3.9 """ import random class Die: """ Creates new die with methods: roll """ def __init__(self, sides: int): self.sides = sides def roll(self) -> int: """ Rolls die, returns random number base...
true
d655cce31f34b46df4a649ba9b3cdd34cf13e076
chapman-cpsc-230/hw3-massimolesti
/turtlestarter.py
527
4.15625
4
import turtle def draw_reg_polygon(t,num_sides,side_len): t.left(30) for i in range(num_sides): t.forward(side_len) t.left(360.0/num_sides) # Ask user for input here. # Now create a graphics window. t = turtle.Pen() for j in range (3): draw_reg_polygon(t,6,50) t.right(150) # Put the res...
true
e620ea1e1a2a45e5e0cbbd29951d6f20eae70228
Kulbhushankarn/Find-area-of-circle
/code.py
241
4.25
4
#area of circle #This code is written by Kulbhushan Karn print ("Find the area of circle") r = float(input("Enter the radius:")) if (r>= 0 and r <= 100) : area = 3.14 *r*r print("area : %f " %area ) else : print("Enter valid number upto 100")
false