blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
d0bb4429e990189944bb9550488f7f5bbfcf5fe1
kamit17/Python
/PCC/Chp8/pizza.py
536
4.4375
4
#Passing an aribitrary Number of Arguments def make_pizza(*toppings): # the * in the parameter tells python to make an empty tuple andpack #whatever value it receives into this tuple. #"""Print the list of toppings you have requested""" #print(toppings) """Summarize the pizza we are about to make""" ...
true
e659f051f0d0730bdd8e2c8f60271db08151a2bb
kamit17/Python
/PCC/Chp7/Super_powers.py
1,077
4.4375
4
""" 7-10. Dream Vacation: Write a program that polls users about superpowers . Write a prompt similar to if you could have one superpower then what would it be? Include a block of code that prints the results of the poll. """ #a place holder dictionary to store the responses superpowers= {} polling_active = True #W...
true
68e9fed9678b9c5996525d08c2d96df277844d0a
kamit17/Python
/W3Resource_Exercises/Strings/ex3.py
750
4.15625
4
""" Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string. Sample String : 'w3resource' Expected Result : 'w3ce' Sample String : 'w3' Expected Result : 'w3w3' Sample String : ' w' Expected Result : ...
true
ec326316fb546cf8ebcd25e18e1a81cdf845ef70
kamit17/Python
/PCC/Chp8/cities.py
560
4.65625
5
""" 8-5. Cities: Write a function called describe_city() that accepts the name of a city and its country . The function should print a simple sentence, such as Reykjavik is in Iceland . Give the parameter for the country a default value . Call your function for three different cities, at least one of which is not in th...
true
c205b507ef49f227a8535774a0373e95357a78a9
kamit17/Python
/W3Resource_Exercises/Strings/ex8.py
385
4.40625
4
#Write a Python function that takes a list of words and returns the length of the longest one def length_longest(words_list): word_len = words_list[0] for i in words_list: if len(i) > len(word_len): word_len = i return len(word_len) a_list = ["Hello","Hi","Applebees","pineapple"] print...
true
b3d96325222b5bdb4866d55a6d7eb48c19ba8a55
kamit17/Python
/Think_Python/Chp3/Exercises/ex5.py
900
4.3125
4
# Use for loops to make a turtle draw these regular polygons(regular means all sides the same # # lengths,all angles the same): # • An equilateral triangle # • A square # • A hexagon (six sides) # • An octagon (eight sides) import turtle #Allows us to use turtles wn = turtle.Screen() # creates a playground for tu...
true
9da2414b95d9cf62789bc8fbecec341a686384b4
kamit17/Python
/PCC/Chp8/printing_models.py
868
4.3125
4
""" Consider a company that creates 3D printed models of designs that users submit. Designs that need to be printed are stored in a list, and after being printed they’re moved to a separate list. The following code does this without using functions: """ #Start with some designs that need to be printed unprinted_design...
true
11fcf4fdd977a27405e64abbd6cfb89a1c266140
kamit17/Python
/W3Resource_Exercises/Strings/ex14.py
405
4.28125
4
# Write a Python program that accepts a comma separated sequence of words as input and prints the unique words in sorted form (alphanumerically). Go to the editor #Sample Words : red, white, black, red, green, black #Expected Result : black, green, red, white,red sample_words = input('Enter a comma seperated list of w...
true
50ae04b492f9c9745132bbca770610cbd8f751bc
kamit17/Python
/W3Resource_Exercises/Strings/ex25.py
1,113
4.8125
5
#. Write a Python program to create a Caesar encryption. #c = (x -n ) % 26 where x is the ASCII key of the source message, n is the key, and 26 since there are 26 characters def encrypted(string,shift): #empty string to hold the cipher cipher = "" #traversing the plain text for char in string: ...
true
5fa4fc1436939b2fc55959ff69777aa79bf357f8
kamit17/Python
/AutomateTheBoringStuff/RegularExpressions/PhoneNumber.py
1,311
4.46875
4
#PhoneNumber.py - A simple program to find phone number in a string without regular expressions. def isPhoneNumber(text): #415 - 555- if len(text) !=12: #checks if string is exactly 12 characters return False #not phone number -sized for i in range(0,3): if not text[i].isdecima...
true
5ea2af667b11e03c79aa1afd12dc28c5dfaa95ad
kamit17/Python
/AutomateTheBoringStuff/DataTypes/string_method2.py
1,161
4.53125
5
# -*- coding: utf-8 -*- #python code to demonstrate working of string methods str = '''Betty Botta bought a bit of butter.“But,” she said, “this butter's bitter!''' str2 = 'butter' #using startswith() to find if str starts with str2 if str.startswith(str2): print("str begins with str2") else: print('str does...
true
ac016d41898a659d95df620ec23aa30d21a52a5a
kamit17/Python
/AutomateTheBoringStuff/DataTypes/deepcopyexample.py
761
4.71875
5
# Python code to demonstarate copy operation # importing "copy for copy Operations" import copy # initializing list 1 list1 = [1, 2, [3, 5], 4] # using deepcopy to deep copy list2 = copy.deepcopy(list1) # original elements of the list print("the original elements before deepcopy") for i in range(0, len(list1)): ...
true
ac4e5aea1c303989bd665f2ea804827e50c5d7c3
kamit17/Python
/examples/myMadlib.py
1,879
4.25
4
""" Once upon a time, deep in an ancient jungle, there lived a {animal}. This {animal} liked to eat {food}, but the jungle had very little {food} to offer. One day, an explorer found the {animal} and discovered it liked {food}. The explorer took the {animal} back to {city}, whe...
true
3f7eb92c2a6cd9ba73ab5dd3c9692528ce9e5316
kamit17/Python
/Think_Python/Chp13/Examples/read_whole_file.py
434
4.125
4
"""Another way of working with text files is to read the complete contents of the file into a string, and then to use our string-processing skills to work with the contents.""" # A simple example to count the number of words in a file f = open("/Users/maverick/GitHub/Python/Think_Python/Chp13/Examples/friends.txt") c...
true
f877f83d6e29bb5f104414ae48403ba91be76d0e
kamit17/Python
/W3Resource_Exercises/Strings/ex2.py
407
4.4375
4
#Write a Python program to count the number of characters (character frequency) in a string. def char_count(input_string): """Funciton to calculate the character frequency in a string""" frequency = {} for char in input_string: if char in frequency: frequency[char] += 1 else: ...
true
5efb695bfbc93a94fd87715af11c74efb748c25f
kamit17/Python
/W3Resource_Exercises/Loops and Conditionals/temperature_convert.py
718
4.1875
4
""" Write a Python program to convert temperatures to and from celsius, fahrenheit. [ Formula : c/5 = f-32/9 [ where c = temperature in celsius and f = temperature in fahrenheit ] Expected Output : 60°C is 140 in Fahrenheit 45°F is 7 in Celsius """ def convert(temp,unit): unit = unit.lower() if unit == 'c': ...
true
73ca90f6464b5b0d5c94006c89624062bd0510b2
kamit17/Python
/LPTHW/ex33_1.py
442
4.21875
4
""" Convert this while-loop to a function that you can call, and replace 6 in the test (i < 6) with a variable. """ def loop(max,step): i = 0 numbers = [] for i in range(0,max,step): print(f"At the top i is {i}") numbers.append(i) print("Numbers now: ",numbers) print(f"At t...
true
24031668fb0e494eb7c1197a0a27060d8a2d10a6
Gonz8088/ITEC3312
/Homework/Homework04.py
1,883
4.15625
4
# PROGRAMMER: Paul Gonzales # DATE: month day, 2019 # ASSIGNMENT: Homework 04 # ALGORITHM: The StopWatch class is built according to the specification, # and uses a datetime object, and timedelta object from the datetime moduleself. # when a StopWatch object is created, the __startTime attribute is initialized # using ...
true
4a29a67f51e667bba2a0ab786253d0b7fe84e3cc
Alonski/superbootcamp
/sentence_statistics.py
626
4.4375
4
def word_lengths(s): # ==== YOUR CODE HERE === return [len(word) for word in s.split()] # ======================= result = word_lengths("Contrary to popular belief Lorem Ipsum is not simply random text") print("Result:", result) assert result == [8, 2, 7, 6, 5, 5, 2, 3, 6, 6, 4] print("OK") def max_word_...
true
fe95c71fc27ea8a2215b44f62c96f43572f2e80e
shengyucaihua/leetcode
/Leetcode349_intersection.py
446
4.25
4
# 给定两个数组,编写一个函数来计算它们的交集。 # # 示例 1: # # 输入: nums1 = [1,2,2,1], nums2 = [2,2] # 输出: [2] # 示例 2: # # 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] # 输出: [9,4] def intersection(nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ num1_set = set(nums1) num2_set = set...
false
4cde5a8cead3d59d99b0030cd22b2f1cd2f93238
kevin-sooter/Intro-Python-I
/src/dictionaries.py
1,360
4.71875
5
#<<<<<<< master # Make an array of dictionaries. Each dictionary should have keys: # # lat: the latitude # lon: the longitude # name: the waypoint name # # Make up three entries of various values. ======= #""" #Dictionaries are Python's implementation of associative arrays. #There's not much different with Python's ver...
true
3f191e135d45d0984a84ccec412cd5337b7772cd
OlehHnyp/Home_Work_7
/Home_Work_7_Task_1_implisit.py
1,396
4.3125
4
import math as m def triangle_area(): """ This function calculate an area of triangle Input parameters: Output: float """ while 1: try: triangle_side = float(input( "Insert side of triangle:" )) triangle_height = float(input( ...
true
5abddd2980f17f30104ea41795c648bab8a5fc43
bennywinefeld/CodiacClub
/ttt1.py
2,276
4.15625
4
# Board is represented by an array with indexes from 0 to 0 # each array element can contain values: ' ','X','O' def drawBoard(board): print(board) print("+---+---+---+") for i in range(3): print("| {} | {} | {} |".format(board[3*i],board[3*i+1],board[3*i+2])) print("+---+---+---+") # Inse...
true
3a45484bb82aa4f372c847992d2de7a2edf5c974
dr34mh4ck/lca-python
/node.py
1,949
4.28125
4
''' *** Binary tree structure is composed by Nodes (left and right) with a *** reference to its parent and the value the Node holds ''' class Node: value = None left = None right = None parent = None ''' *** empty initialization for the Node ''' def __init__(self): pass ...
true
d97b71f4e3a18bcc8d8dc325210b70bd605ecf37
AkshadaSayajiGhadge594/Serial-Programming
/SerialParallelProg.py
222
4.21875
4
print("----------Serial Parallel Programming-----------"); def square(n): return (n*n); #input list: arr=[1,2,3,4,5] #empty list to store result: result=[]; for num in arr: result.append(square(num)); print(result)
true
6ee4d8571be4770511c0e065d839ce17fb068e3d
aisha109/project-97
/guessingGame.py
202
4.15625
4
Question = "Guess a number between 1 and 9" print(Question) QuestionInput = input("Enter your guess") if(QuestionInput == 8 ): print("YOU ARE RIGHT") else: print("ANOTHER GUESS")
true
27e5d8667b78815b1e9de92b49ea0d5d7958603b
VAEH/TiempoLibre
/Funciones.py
834
4.15625
4
""" Escriba un programa que solicite repetidamente a un usuario números enteros hasta que el usuario ingrese 'hecho'. Una vez que se ingresa 'hecho', imprima el número más grande y el más pequeño. Si el usuario ingresa algo que no sea un número válido, agárrelo con un try / except y envíe un mensaje apropiado e ignore...
false
7fa04a5cc1765c0d51d5eab50fca0d294d5b1ec7
natsthomare/CS116
/assignment 3/final/Assignment3.2.py
2,175
4.125
4
import check def print_top_half(i,n): ''' Prints the top half of the X-wing formation\ given n which is the number of lines in the top half of the X-wing formation\ and i which is the variable used as a line counter. print_top_half -> Int Int -> None Requires 0 <= i < n n > 0 ...
false
300636cb53b57670c93110ab7fce3f600f6f30ca
candopi-team1/Candopi-programming101
/7_data_structures_and_algorithms/sorts_python/merge_sort_dummies.py
2,018
4.46875
4
# Merge Sort def merge_sort(list): # Determine whether the list is broken into individual pieces. if len(list) < 2: return list # Find the middle of the list. middle = len(list)//2 # Break the list into two pieces. left = merge_sort(list[:middle]) right = merge_sor...
true
ef23474b4f89dae3b6933ad571e0b4067b6f07c9
kuzaster/python_training_2020
/HW7/task3/task03.py
1,267
4.1875
4
""" Given a Tic-Tac-Toe 3x3 board (can be unfinished). Write a function that checks if the are some winners. If there is "x" winner, function should return "x wins!" If there is "o" winner, function should return "o wins!" If there is a draw, function should return "draw!" If board is unfinished, function should return...
true
9e70185a45e593613d2c1e459ecf01b9fc4e4d2c
KFernandez1988/SSL
/rb_py_node/pygrader/grader.py
609
4.1875
4
# python grader file from grader_class import Grader name = raw_input(' Please Student enter your name ') assignment = raw_input('What was your test about ') grade = '' # checkting for the right data type while( grade is not int): try: grade = int(raw_input('Can you please enter your score ')) if...
true
23bc9f44eac6986b8a2f3326d8053feda2770650
stewartrowley/CSE111
/Week 8/convert_list_dictionaries.py
785
4.25
4
# Example 6 def main(): # Create a list that contains five student numbers. numbers = ["42-039-4736", "61-315-0160", "10-450-1203", "75-421-2310", "07-103-5621"] # Create a list that contains five student names. names = ["Clint Huish", "Michelle Davis", "Jorge Soares", "Abdul A...
true
ac1acc7efa9872384ae7ec869fe853c4e8eff770
stewartrowley/CSE111
/Week 3/get_initials_organization.py
530
4.25
4
# the function gets initials for the code def get_initial(name): initial = name[0:1].upper() return initial # Ask for someones name and return the initials first_name = input("Enter your first name: ") first_name_initial = get_initial(first_name) middle_name = input("Enter your middle name: ") middle_name_init...
true
3290638a7b521dc61d24b72bf98c7340a20f65d3
Ckk3/python-exercises
/EstruturasDeRepetiçãoWhile/menuOpções.py
1,576
4.25
4
'''Crie um programa que leia dois valores e mostre um menu na tela: [ 1 ] somar [ 2 ] multiplicar [ 3 ] maior [ 4 ] novos números [ 5 ] sair do programa Seu programa deverá realizar a operação solicitada em cada caso.''' import os firstNumber = int(input('Type the first number: ')) secondNumber = int(input('Type the ...
false
70cc1506aa7c540297cdb93b340a02fcfd43ee2b
Ckk3/python-exercises
/EstruturasDeRepetiçãoWhile/fatorial.py
869
4.25
4
#Faça um programa que leia um número qualquer e mostre o seu fatorial. #Ex: 5! = 5 x 4 x 3 x 2 x 1 = 120 from time import sleep from math import factorial userNum = int(input('Type the number who you want to know the factorial: ')) print('Calculating.',end='') sleep(0.3) print('.',end='') sleep(0.3) print('.') slee...
false
3e43d7fd2a86300d241cbc7546322f92e14d0b87
zhaowangbo/python
/第一阶段/是否上班.py
443
4.1875
4
while True: day = input("enter a day from monday to sunday, and enter 'q' to quit") week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] if day == 'q': break if day not in week: print("you must enter a day from monday to sunday") continue if...
true
cb5c23e7e270aead77e49ab266ed88dcbeb748ed
Krit-NameWalker/6230401848-oop-labs
/Krit-623040184-8-lab5/P4.py
587
4.15625
4
def fac(num): if num == 0: return 1 if num == 1: return 1 else: return num * fac(num-1) if __name__ == "__main__": try: num = input("Enter an integer:") num = int(num) if num < 0: print("Please enter a positive integer. {} is not ...
true
9dfabf53905b32a03ef4d0fd4009ce606bf76000
Mistarcy/python-hello-world
/week6/high_low.py
1,012
4.28125
4
# Example by James Fairbairn <j.fairbairn@tees.ac.uk> # We wrote this together in class. # # **DO NOT REMOVE THIS HEADER** # # Notes: # + This file is for demonstration purposes only. # + You must use this example to guide your own solution. # **DO NOT SUBMIT THIS FILE AS IS FOR ASSESSMENT** import random MAX...
true
1c194054862028e0455f6894afae2563cb750792
joaoo-vittor/estudo-python
/OrientacaoObjeto/aula5.py
426
4.15625
4
""" Aula 5 Atributos de Classe - Python Orientado a Objetos """ class A: vc = 123 a1 = A() a2 = A() a3 = A() print('#'*30) a3.vc = 321 # aqui estou criando um atribudo print(a3.__dict__) print(a2.__dict__) print(a1.__dict__) print(A.__dict__) print('#'*30) print('Antes de Alterar vc') print(a1.vc) print(a2....
false
2476b8db009ab4cf5c9dbed329b4a3de2fa45bcd
hunterad96/unbeatable_tic_tac_toe
/tic_tac_toe/display_functions.py
1,237
4.1875
4
import platform from os import system """ Functions to handle the rendering of the board in the terminal, and ensuring that the terminal doesn't become cluttered with boards other than the board representing the most recent state of the game. """ # Function that cleans up the terminal to avoid having too many boar...
true
35e52395a0d1b999fd9696cc00955d3d1203ed49
simmihacks/python_projects
/hangmanpseudo.py
1,377
4.28125
4
#this is not code but a Pseudocode for an MIT coding challenge: #https://courses.edx.org/courses/course-v1:MITx+6.00.1x+2T2017_2/courseware/530b7f9a82784d0cb57de334828e3050/bfe9eb02884a4812883ff9e543887968/?child=first """ Hangman Pseudo Code 1. Load the words 2. Randomly Select a word 3. Save the word in a string: ...
true
8d631dfa7af78f6522855cc4914209c5009a8e79
EoinStankard/pands-problem-set
/ProblemFive-primes.py
2,097
4.3125
4
#Name: Eoin Stankard #Date: 28/03/2019 #Problem Five: Write a program that asks the user to input a positive integer and tells the user #whether or not the number is a prime. value=input("Please enter a positive integer: ") #This code will keep looping until the done variable is given 1. I used this as i will need to...
true
1e218f276764d53945e4a79b13bb35f615ca3ef8
Pnickolas1/Code-Reps
/AlgoExpert/Recursion/tail_call_optimization.py
1,254
4.125
4
""" Tail Call optimization: - tail call optimization is when the recursion call is the last thing in the function before it returns - hence the name "the recursive function call comes at the "tail" of the function - the call stack never grows in size - TCO prevents stack overflows - tail call optimzation is a compile...
true
172bb99cf56fb5c77537340a1e9a1b00c9d103ff
Pnickolas1/Code-Reps
/Arrays/even_odd.py
570
4.125
4
# when working with arrays, take advantage of the fact you operate on both ends # efficiently # given an array of ints, sort evens first then odds x = [2, 3, 7, 5, 10, 14, 15, 22, 27, 31] print(len(x)) def even_odd(arr): next_even = 0 next_odd = len(arr) -1 while next_even < next_odd: if arr[...
true
f8b8a4c36802b6beb3a27326e7d05b204351ac4e
Pnickolas1/Code-Reps
/Algorithms/Bottom_Up_Algorithm.py
1,047
4.3125
4
# Bottom up algorithms offer another option in solving a problem. Bottom up algorithms are often used instead of a # recursive approach. While recursion offers highly readable, succinct code, it is succeptible to a high memory cost # O(n) and could lead to a stack overflow. # recursion starts from the "end and works...
true
eca7a7ce6540b3979f21670b0aad8b9f676c7f6e
Pnickolas1/Code-Reps
/EOPI/array/check_if_decimal_integer_is_palindrome.py
797
4.21875
4
import math """ checking if a integer is a palindrome can be 2 waysL Optimal: space: O(1) time:: O(n) 1. way, reverse the integer, and then compare to the given parameter 2. iterate through through the param, popping off the most significant int, and the least significant digit, comparing, if they dont match, re...
true
c08f3c18300548d6b77bbeb80e667a031b411960
Nicoconte/Programacion-1
/practica_2/ejercicio_6.py
918
4.1875
4
import random # 3 Listas: 1- La original / 2- Palabras a eliminar / 3- La resultante def ingresar_palabras_a_eliminar(): palabras_a_eliminar = [] entrada = input(("Que palabras deseas eliminar ")) while(entrada != "listo"): palabras_a_eliminar.append(entrada) entrada = input(("Que palabras deseas elim...
false
d04d1642831395c1f8bed417c1138b4d8c89f804
gunnsa/Git_place
/git-python/sequence.py
349
4.15625
4
n = int(input("Enter the length of the sequence: ")) # Do not change this line sequence = 0 x1 = 1 x2 = 2 x3 = 3 if n > 0: print(1) if n > 1: print(2) if n > 2: print(3) if n > 3: for x in range(0,n-3): sequence = x1 + x2 + x3 print(sequence) x1 = x2 x2 = x3 x3 = ...
true
16c36a6e26395be7996359701bd6373fc3036de5
himanig/py-path
/createmodule_circle.py
237
4.25
4
#creating my own module from math import pi radius = input('Enter the radius of circle: ') print(end='\n') print('The area of the circle is= ', float(radius) ** 2 * pi) print(end='\n') print('The circumference is= ', float(radius) * pi)
true
bf0b3dde8a51d60ca5326d99eb3b7217622e50d8
couple-star/python-study
/exercise/excercise22.py
201
4.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #Write a function that takes a string as input and returns the string reversed. string=raw_input('please in put one string: ') a=string[::-1] print a
true
fff1490edf893397e742018cb3519a579f1c27e5
choutos/winterchallenge_2019
/day01/day01.py
2,342
4.5625
5
''' Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. For example: - For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2. - For a mass of 14, dividing by ...
true
dcf62d8f75a28a3c6de9cbc8800003e632f7cfc8
NitinJRepo/Linear-Algebra
/01-creating_vector.py
628
4.34375
4
import numpy as np # Create a vector as a row vector_row = np.array([1, 2, 3, 4, 5]) print("row vector: ", vector_row) # Create a vector as a column vector_column = np.array([[1], [2], [3], [4], [5]]) print("column vector: ", vector_column) # Selecting elements print("Select third element of vector:") print(vecto...
true
d503bc0ac71fde9f617d693e3842e1572041a94b
bigplik/Python
/lesson_nana/functions.py
683
4.1875
4
#functions hours = 24 minutes = 24 * 60 seconds = 24 * 60 * 60 #calculation to units eg. to seconds, or hours calculation_to_units = seconds name_of_unit = "seconds" ''' def day_to_units(days): num_of_days = days print(f"{num_of_days} days are {num_of_days * calculation_to_units} {name_of_unit}") day_to_units(176...
true
3f09381843b9d724563344d5d36ceb7df27d177b
pndiwakar/python_hello_word
/radius.py
309
4.4375
4
#!bin/python # Impoort the required module for getting maths function PI from math import pi #assign the input to variable r = float(input("Input the radius of circle : ")) # To make it square of r either use "r * r" or "r**2" print ("Areas of circle with radius={} is : {}" .format(r, str(pi * (r * r))))
true
622beb7f9d24e18d9fd844c2c57ea3ef648f456a
marmst10/Python-Examples
/Basic Python Manipulations.py
1,832
4.125
4
#!/usr/bin/env python # coding: utf-8 # STAT 7900 – Python for Data Science<br> # Homework 3<br> # Connor Armstrong<br> # <br> # 1. Create a CSV (Comma Separated Values) file from the data below (copy and paste the data into Excel then save as a csv) and read in as a Pandas Dataframe. Then do the following using Panda...
true
f321231eb06846b84c88bcfcc274a875bbc16b6f
joyadas1999/calculator
/calculator.py
1,650
4.40625
4
#this function is an example of addition def calculator_addvalue(addvalue_x,addvalue_y): calc_add = addvalue_x + addvalue_y return calc_add add_x = calculator_addvalue(100,30) print(add_x) #this function is an example of subtraction def calculator_subtvalue(subtvalue_x,subtvalue_y): calc_subt = subtvalue_x...
true
378e26693bc0fb641470307d5e6ed10dd9e0fc06
BryJC/LPtHW
/40-49/ex42.py~
2,203
4.28125
4
## Animal is-a object (yes, sort of confusing) look at the extra credit class Animal(object): pass ## Dog is-a(n) animal class Dog(Animal): def __init__(self, name): ## class Dog has-a(n) attribute name set to name self.name = name ## Cat is-a(n) animal class Cat(Animal): def __init__(se...
true
ee456ae55757848df8f2c3cf1007748b735e4011
maoa20-gm/Algoritmos
/aula_01/practica_01.py
2,645
4.25
4
''' def hello(): print("Oi mundo!") print("Oi de novo!") hello() def continha(): print(798 - 2 * 378) continha() def somaQuadrados(a,b): return print(a*a + b*b) somaQuadrados(5,7) pergunta1 = "Qual é a Capital da Nicaragua? \n a) Atahualpa\n b) Managua \n c) San Jose \n d) Tegucigalpa" de...
false
b2f460c60a956866ffabcf756b76f851db3e8f1c
kyunghwanleethebest/inflearn_leaf
/code/2_property.py
607
4.15625
4
# Underscore, Getter, Setter class Example: def __init__(self): self.x = 0 self.__y =0 # private self._z = 0 # protected @property def y(self): print('Get Method') return self.__y @y.setter def y(self, value): print('Set Method') if value < ...
false
8fb7f09891f642640d0349410a84552fdb0a6098
balazsbarni/pallida-basic-exam-trial
/namefromemail/name_from_email.py
717
4.40625
4
# Create a function that takes email address as input in the following format: # firstName.lastName@exam.com # and returns a string that represents the user name in the following format: # last_name first_name # example: "elek.viz@exam.com" for this input the output should be: "Viz Elek" # accents does not matter #pri...
true
fc5e75a3fb1934afea5063e0b3462ebd51452ae5
sidtandon2014/Algorithms
/Algos/Sorting/MergeSort.py
1,150
4.125
4
def mergeSort(arr, left, right): middle = left + (right - left) // 2 if left < middle: mergeSort(arr, left, middle) if (middle + 1) < right: mergeSort(arr, middle + 1, right) merge(arr, left, middle, right) def merge(arr, left, middle, right): leftArrIndex = 0 rightArrIndex = 0...
false
15469c6b9eb1e92deadda1e6330bd8e0d54452ad
Shwibi/python-c11-stanselm
/marks.py
434
4.21875
4
# Practice: 18/8/2021 # Conditional Statements with calculation # Program 1 physics = int(input("Enter marks in physics: ")) chemistry = int(input("Enter marks in chemistry: ")) biology = int(input("Enter marks in biology: ")) total = physics + chemistry + biology percentage = total/3 print("Total marks: ", total)...
true
412fb126e7f325e85c8d67c1aefaac11f0e86655
Shwibi/python-c11-stanselm
/vote.py
201
4.21875
4
# Practice: 18/8/2021 # Conditional Statements, boolean # Program 2 age = int(input("Enter age: ")) if age >= 18: print("You are eligible to vote!") else: print("You are not eligible to vote!")
true
2c1876b25ba61af9e861f01199b49637fcaf9592
Elmurat01/ThinkPython
/Think Python - Chapter 04/ThinkPython4_flowers.py
754
4.25
4
import turtle, math bob = turtle.Turtle() def arc(t, r, angle): """Draws an arc length angle from a circle of radius r. t is a turtle. """ step = (2 * math.pi * r) / 360 for i in range(angle): t.fd(step) t.lt(1) def flower(t, no_petals, len_petals, angle): """Draw...
true
c7d44451340d31439de7278b1e802ab76a8e23a6
Elmurat01/ThinkPython
/Think Python - Chapter 15/draw_circle.py
963
4.3125
4
import turtle, math bob = turtle.Turtle() class Point: """Represents a point in 2-D space.""" class Circle: """ Represents a circle. Attributes: radius, center """ def draw_circle(t, circle, color = "black"): """ Takes a Circle object and a Turtle object and...
true
d289e8f42445a154370d8355a81f7171eb7a7dcd
alexagrchkva/for_reference
/theory/5th_sprint/unittest_task.py
1,593
4.15625
4
import unittest class Calculator: """Производит различные арифметические действия.""" def divider(self, num1, num2): """Возвращает результат деления num1 / num2.""" return num1/num2 def summ(self, *args): """Возвращает сумму принятых аргументов.""" if len(args) <2: ...
false
a84d8f35a45c7b9fe1b1c9706efc981a71b37f4e
annamariamistrafovic1994/SN-WD1-Lesson8
/mood_checker.py
515
4.1875
4
x = input("What mood are you in? ") print(x) operation = input("Choose one of the given solutions (happy, sad, relaxed, nervous, excited): ") print(operation) if operation == "happy": print("It is great to see you happy!") elif operation == "sad": print("Cheer up!") elif operation == "relaxed": print("Sta...
true
3842011e556e7e0708ec652718d1daa099d7cade
mlr0929/FluentPython
/05FirstClassFunctions/any_and_all.py
707
4.21875
4
""" all(iterable) Return True if every element of the iterable is truthy; all([]) returns True >>> all([0, 1, 3]) False >>> all([1, 1, 3]) True >>> all([]) True # Equivalent to >>> def all(iterable): ... for element in iterable: ... if not element: ... return False ... return True any(iter...
true
e42da9aa532f1dd148ea2f000846a3bace45eb24
sandyg05/cs
/[Course] Python for Everybody - University of Michigan/Course 2 - Python Data Structures/Chapter 6 - Strings.py
1,548
4.625
5
# Chapter 6 - Strings Quiz # 1. # What does the following Python Program print out? str1 = "Hello" str2 = 'there' bob = str1 + str2 print(bob) # Hellothere # 2. # What does the following Python program print out? x = '40' y = int(x) + 2 print(y) # 42 # 3. # How would you use the index operator [] to print o...
true
c19dba940010c1d12eaab21bfe06e2479fcfe3ca
sandyg05/cs
/[Course] Python for Everybody - University of Michigan/Course 1 - Programming for Everybody (Getting Started with Python)/Chapter 1 - Why We Program.py
1,341
4.34375
4
# Chapter 1 - Why We Program Quiz # 1. # When Python is running in the interactive mode and displaying the chevron prompt (>>>) # what question is Python asking you? # What would you like to do? # 2. # What will the following program print out: x = 15 x = x + 5 print(x) # 20 # 3. # Python scripts (files) hav...
true
0db347081d9257b3b7fd0f8baeda34b5bf7e4b86
Tclack88/Scientific-Computing-Projects
/Basic/SineSeriesApprox.py
1,833
4.28125
4
#!/usr/bin/python3 import math pi = 3.1415926535897932384626433832795028841971 def factorial(n): num = 1 for i in range (1,n+1): num *= i return num # we are not allowed to import functions like # factorial or pi, so I have to define them here # Self explanatory definition I'd say ...
true
1c34a6302c82676ed500cd9407c39c944b6a1d0d
Tclack88/Scientific-Computing-Projects
/Basic/InfoAssist.py
2,868
4.46875
4
#!/usr/bin/python3 # The purpose of this program is to take info from a .csv file (csv.csv... very creative name) # and automate the process of finding specific information: import csv with open('csv.csv') as f: readCSV = csv.reader(f, delimiter=',') # "with open(file) as f" automatically closes after ...
true
3caa0f0153dbd76fd844262a24d75e3b851d28b2
Tclack88/Scientific-Computing-Projects
/Intermediate/lorenz_attractor.py
1,269
4.1875
4
#!/usr/bin/env python3 # plot of a lorentz attractor as apart of a solution to a nonlinear dynamics problem # strogatz import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def lorenz(x,y,z,r, a=10, b=8/3): x_dot = a*(y-x) y_dot = r*x-y-x*z z_dot = x*y-b*z return x_dot, y_do...
true
04cdb0bfddf2670ad3f4cc7de8f4bb849bdbcdf6
JunWonOh/Multimodal-Calculator
/Multi-modal Calculator/Calculator_Module/Calculator_Presentation.py
2,583
4.15625
4
from tkinter import * import tkinter.font as font from Calculator_Module import Calculator_Control # initialize the root root = Tk() # title of the window root.title("CSI 407 Project") # color of the window root.configure(bg="#606060") # disable resizing root.resizable(False, False) # the font of the buttons myFont =...
true
b77691eea281865c3cc1aaeea025a4ed1a3cb07f
koolhussain/Python-Basics
/19.Dictionary.py
379
4.125
4
exDict = {'Jack':[75,'White'],'Bob':[22,'brown'],'Ahmad':[23,'Blue'],'Kevin':[17,'Black']} print(exDict) print(exDict['Jack']) #Adding New Key-value pair exDict['Tim'] = 54 print(exDict) #Modifiy Old Key-Value pair exDict['Tim'] = 15 print(exDict) #Deleteing a Key-Value Pair del exDict['Tim'] print(exDict) #REfern...
false
d8a1213f4366ecd4985389b1e81d60bba23e893c
SMGuellord/Algorithms-and-data-structures-using-Python
/queue/QueueWithSinglyLinkedList.py
1,751
4.21875
4
class Node(object): def __init__(self, data): self.data = data self.next_node = None class Queue(object): def __init__(self): self.head = None self.size = 0 def enqueue(self, data): self.size += 1 new_node = Node(data) if not self.head: ...
true
1831235ebe9dee4c75bccff6f62ad2afd8b3e8c4
Tanyaregan/daily_coding
/daily_1_13.py
1,093
4.40625
4
# Given an array of integers, find the first missing positive integer # in linear time and constant space. # In other words, find the lowest positive integer that does not exist in the array. # The array can contain duplicates and negative numbers as well. # For example, the input [3, 4, -1, 1] should give 2. The inp...
true
851c2de55b7ddbc0166c6a4c374a8cb1f7c72e9c
azizamukhamedova/Python-Thunder
/ArrangementOfLetters.py
588
4.21875
4
''' Backtracking is a form of recursion. But it involves choosing only option out of any possiblities. ######################## Arrangemt Of Letter Problem ########################## ###### Python ###### ''' de...
true
19e65fde298f1f827b77865f5c49af233991cbe6
acneuromancer/algorithms-datastructures
/Python/most_frequent.py
421
4.15625
4
""" Given an array find out what the most frequent element is. """ def most_frequent(a_list): count = {} max_val = 0 max_key = None for key in a_list: count[key] = 1 if key not in count else count[key] + 1 if count[key] > max_val: max_key = key max_...
true
efc4ced43468dfe6429a96611e65d57437690c31
Eastwu5788/LeetCode
/48.py
1,361
4.21875
4
# !/usr/local/python/bin/python # -*- coding: utf-8 -*- # (C) Wu Dong, 2020 # All rights reserved # @Author: 'Wu Dong <wudong@eastwu.cn>' # @Time: '2020-06-19 13:36' """ 给定一个 n × n 的二维矩阵表示一个图像。 将图像顺时针旋转 90 度。 说明: 你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。 示例 1: 给定 matrix = [ [1,2,3], [4,5,6], [7,8,9] ], ...
false
f251c542e7dd581c3223c2718352287820910ce5
mauriciosierrac/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/3-say_my_name.py
458
4.4375
4
#!/usr/bin/python3 ''' That Function print the first and last name''' def say_my_name(first_name, last_name=""): ''' funcion say my name Return: print the first and last name ''' if type(first_name) is not str: raise TypeError ('first_name must be a string') if type(last...
true
06b4012fc2db5a8d35e1a4b48bfe5354ea26401f
carolinegbowski/exercises_day_1
/05_iteration_4.py
1,080
4.125
4
this_list = [1, 2, ['jeff', 'tom'], [42, ['billy', 'jason']]] def crack_this_list(any_list): for i in any_list: if type(i) is list: for j in i: if type(j) is list: for k in j: if type(k) is list: for l...
false
5987f01590742617c2aaa36c27ad7def84d98967
ashokjain001/Coding_Practice
/problem-Solving/capitalization.py
332
4.3125
4
#write a function that accepts a string. The function should #capitalize the first letter of each word in the string then #return the capitalized string. def capitalization(string): array=string.split() newstr='' for i in array: newstr=newstr+' '+i[0].upper()+i[1:] return newstr print capitalization('a shor...
true
59af5c806732b7c23220593ad053287590f012b2
johnerick-py/microsoft-python
/microsoftExercicios/python-lists/challenge1.py
1,208
4.125
4
import random suits = ["Hearts", "Spades", "Clubs", "Diamonds"] ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"] cards = [] baralho = [] count = 0 for suit in suits: for rank in ranks: cards = rank + ' of ' + suit baralho.append(cards) random.shuffle(baralho)...
false
19d20dff0e99e6c54e024fbee301b8dc95ae8dbd
karakose77/udacity-cs101-intro-to-computer-science-exercises-and-projects
/mk005-is_symmetric.py
510
4.46875
4
# A list is symmetric if the first row is the same as the first column, # the second row is the same as the second column and so on. Write a # procedure, symmetric, which takes a list as input, and returns the # boolean True if the list is symmetric and False if it is not. def is_symmetric(L): """ Returns Tru...
true
296530e3cb3d06b42ff811d9c10ed8c82e6f6723
karakose77/udacity-cs101-intro-to-computer-science-exercises-and-projects
/mk009-is_palindrome_recursive.py
343
4.34375
4
# Define a procedure, that takes as input a string, and returns a # Boolean indicating if the input string is a palindrome. def is_palindrome_recursive(s): """ Returns true if input string is a palindrome. """ if len(s) == 0 or len(s) == 1: return True return (s[0] == s[-1]) and is_palindr...
true
6e8dd58f96b1748825260c3a3d8cedf1f62b2637
jzarazua505/the_matrix
/property.py
794
4.125
4
width = 5 height = 2 # This is where we calculate perimeter perimeter = 2 * (width + height) # This is where we calculate area area = width * height print("Perimeter is " + str(perimeter) + " and Area is " + str(area) + "!") print(f"Perimeter is {perimeter} and Area is {area}!") print(f"Area: {area}") # f(x) = y = 2x ...
true
94dd05b8a2370ab85db2412e2be93872d0fbce05
2281/unittest
/unittest/radius.py
494
4.15625
4
from math import pi def circle_area(radius): if radius < 0: raise ValueError("Radius can't be negative") if type(radius) not in [int, float]: raise TypeError("Type is not int or float") return pi*radius**2 #print(circle_area(-5)) # r_list = [1,0,-1,2+3j, True, [2], "seven"] # message =...
true
75bafe1ecce74af6b790cc77007c9e184ae912be
Annapooraniqxf2/read-write-python-program
/finish-the-program/p008_finish.py
447
4.15625
4
# Python program to find the # sum of all digits of a number # function definition def sumDigits(<Finish the line>): if num == 0: return 0 else: return num % 10 + sumDigits(int(num / 10)) # main code x = 0 print("Number: ", x) print("Sum of digits: ", sumDigits(x)) print() x = 12345 print("Number: ", x) ...
true
2882485852aa333e90ae5a1677a967305918dceb
Annapooraniqxf2/read-write-python-program
/finish-the-program/p001_finish.py
305
4.21875
4
""" Input age of the person and check whether a person is eligible for voting or not in Python. """ # input age age = int(input("Enter Age : ")) # condition to check voting eligibility <Fill the line> status="Eligible" <Fill the line> status="Not Eligible" print("You are ",status," for Vote.")
true
e59f0cb7158c7181f7b6a538e1f3386b3dd52767
KhauTu/KhauTu-Think_Python
/Chap15_5.py
880
4.1875
4
from math import sqrt class Point: def __init__(self, x, y): self.x = float(x) self.y = float(y) class Circle: def __init__(self, a, b, c): # line between a and b: s1 + k * d1 s1 = Point((a.x + b.x)/2.0, (a.y + b.y)/2.0) d1 = Point(b.y - a.y, a.x - b.x) # line between a and c: s2 + k * d2 s2 = Point...
false
f31ac167f2e8d70f19e58355b919395abaf878ea
Allegheny-Computer-Science-102-F2020/cs102-F2020-challenge2-starter
/iterator/iterator/iterate.py
1,166
4.53125
5
"""Calculate the powers of two, with iteration, from minimum to maximum values.""" # TODO: Add the required import statements for List and Tuple def calculate_powers_of_two_for_loop( minimum: int, maximum: int ) -> List[Tuple[int, int]]: """Calculate and return the powers of 2 from an inclusive minimum to an...
true
2ca165947c741d4c65a75f3df950a38fa39a04bd
JosiahMc/python_stack
/python_fundamentals/coin_tosses.py
1,630
4.375
4
# Assignment: Coin Tosses # Write a function that simulates tossing a coin 5,000 times. Your function should # print how many times the head/tail appears. # # Sample output should be like the following: # # Starting the program... # Attempt #1: Thro1 head(s) so far and 0 tail(s) so far # Attempt #2: Throwing a coin....
true
a3d18cc43f4ca22670598e60ba5b883f11c867b5
dexterka/coursera_files
/2_Python_data_structures/week4_lists/lists_testing.py
1,019
4.125
4
# Define list friends = ['Bob', 'Harry', 'Anne', 'Peter', 'Helen', 'Mary'] print(friends[2:4]) print(type(friends)) friends[1] = 'Susan' print(friends) print('Length of list:', len(friends)) # A counted loop with range for i in range(len(friends)): friend = friends[i] print('Index:', i) ...
true
cca42ca6cfd18d29c6681cd7a84e813e204e6008
MHKNKURT/python_temelleri
/5-Pythonda Koşul İfadeleri/if-else-demo.py
2,283
4.125
4
#1 # name = input("İsim: ") # age = int(input("Yaş: ")) # edu = input("Eğitim Durumu: ") # if (age >= 18) and (edu == "lise" or edu == "üniversite"): # print("Ehliyet alabilirsiniz.") # else: # print("Ehliyet alamazsınız.") #2 sozlu1 = int(input("Sözlü1: ")) sozlu2 = int(input("Sözlü2: ")) yazili = int(input("Y...
false
15119d609e7855b9330937e8d96e235dd900361e
vkmb/py101
/classes/classes and objects.py
853
4.125
4
# classes.py # - classes and objects class Employee: 'Common base class for all employees' empCount = 0 # This is a class variable def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print "Total Employee %d" % Emplo...
true
954070ef0bbdfc02dd030e2f7ab9a2abdf26d190
mjaw10/assignment
/Spot check pool.py
521
4.21875
4
print("This program will calculate the volume of a pool") width = float(input("Please enter the width of the pool: ")) length = float(input("Please enter te length of the pool: ")) depth = float(input("Please enter the depth of your pool: ")) main_section_volume = length * width * depth circle_radius = width/2 ci...
true
5f111a2967558285ab96d83966b029eebe29a3d2
saisrikar8/C1-Dictionary
/main.py
1,797
4.125
4
''' 03/08/2021 Review List: mutable, [] List functions LIST.insert(INDEX, ELEMENT) LIST.append(ELEMENT) LIST.remove(ELEMENT) LIST.pop(INDEX) LIST[INDEX] = ELEMENT Tuple immutable, () ___________________________________________________ Dictionary Another type of list, stores data/values inside the curly...
true
a010b033f58c902cfcf9979e4ab456c78795f2d7
chernish2/py-ml
/01_linear_regression_straight_line.py
2,976
4.3125
4
# This is my Python effort on studying the Machine Learning course by Andrew Ng at Coursera # https://www.coursera.org/learn/machine-learning # # Part 1. Linear regression for the straight line y = ax + b import pandas as pd import numpy as np from plotly import express as px import plotly.graph_objects as go # Hypo...
true
21f96178fa5517739532612710192bcb8edb93c4
akankshashetty/python_ws
/Q5.py
341
4.34375
4
"""5. Write a program to print the Fibonacci series up to the number 34. (Example: 0,1,1,2,3,5,8,13,… The Fibonacci Series always starts with 0 and 1, the numbers that follow are arrived at by adding the 2 previous numbers.)""" a = 0 b = 1 c = 0 print(a,b,end=" ") while not c==34: c=a+b print(c,end=" ") ...
true