blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
b0cea73eafad1a0327f69801d0067a5e1c32010a
cristinamais/exercicios_python
/Exercicios Estruturas Logicas e Condicionais/18.py
1,425
4.40625
4
""" 18 - Faça um programa que mostre ao usuário um menu com 4 opções de operações matemáticas (as básicas por exemplo). O usuário escolhe umas das opções e o seu programa então pede dois valores numéricos e realiza a operação, mostrando o re sultado e saindo. """ num1 = float(input("Digite o primeiro número: ")) num2 =...
false
2ddb71b98fa70291fa0b3b895e9e86ab0003ba61
Hscpro/Python-Study
/Animal.py
877
4.1875
4
#!/usr/bin/env python3 class Animal(object): owner = 'jack1' #动物的名称 def __init__(self, name): self.__name = name def get_name(self): return self.__name def set_name(self,value): self.__name = value @classmethod def get_owner(cls): return cls.owne...
false
6045bc04be311fe39536317c887401cf2f1717f6
thejose5/Motion-Planning-Algorithms
/Basic/BFS.py
2,810
4.375
4
print("DEPTH FIRST SEARCH ALGORITHM") print("The graph is implemented using dictionaries. The structure of the dictionary is as follows: {Node1:{NeighbourNode1:[<distance b/w nodes>,<heuristic>],...},Node1:{NeighbourNode1:[<distance b/w nodes>,<heuristic>],...} and so on\n\n") graph = {'A':['S','B'], 'B':['A'...
true
edb281a7b109cf17fcd3e57aec82dd125b51de60
imakash3011/PythonFacts
/Maths/DoubleDivision.py
413
4.1875
4
# ###################### Double division print(-5//2) print(-5.0//2) # ################################# Power operator # Right associative (right to left) print(2**1**2) print(1**3**2) # ############################ No increment and decrement operators x = 10 print(x) # x++ x+=1 print(x) # #################...
true
7e0fcc5cac0753e25e70f69a63388b358ff6aa1d
lyf1006/python-exercise
/7.用户输入和while循环/7.2/tickets.py
202
4.3125
4
tip = "How old are you?" while True: age = input(tip) if int(age) < 3: print("票价为0$") elif int(age) <= 12: print("票价为10$") else: print("票价为15$")
false
d8eeb69854f7a00b908e5b9b209684c46a3bc887
lyf1006/python-exercise
/7.用户输入和while循环/7.2/pizza.py
244
4.125
4
tip = "Please enter an ingrident you want to add: " tip += "\n(Enter 'quit' when you are finished)" while True: ingrident = input(tip) if ingrident == "quit": break else: print("We will add this ingrident for you.")
true
8a46f1f736b1c5f782f9cfbd385ea5b01e0379e6
DD-PATEL/AkashTechnolabs-Internship
/Basic.py
1,156
4.28125
4
#Task 1- printing value of variables and finding variable type a=7 b=3.6 c= "DD" print("value of a is :", a) print("value of b is :", b, type) print(c) #Task 2- Basic string commands such as printing and slicing of string name = "Divyesh" print(name) print(name[1:5]) print(name[:4]) print("Hello",...
true
14a14730776ee546b12942ad8145261b531f9e13
mail-vishalgarg/pythonPracticeOnly
/Array/palindromString.py
505
4.125
4
def palindromString(str): print "reverse string:",str[::-1] if str == str[::-1]: print "palindrom" else: print "not a palindrom" def palindromString2(str): revStr = '' i = len(str) while i > 0: revStr = revStr + str[i -1] i = i - 1 print 'rev str:',revStr ...
false
d9881c031ca58a90e6bc1407f9e935b8c23a457e
dannymccall/PYTHON
/password_generator.py
1,852
4.125
4
from tkinter import messagebox import random import tkinter as tk def password_generator(): #Opening a try block try: #declaring a variable pw as a string without initialising pw = str() #Getting the input from the text box length = text_field_1.get() if length == '': me...
true
0bd4bead6a5c5b6366f09fd6ff33c670b0a64635
Mudando/Python
/naleatorios.py
433
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jan 24 14:42:57 2021 @author: gilson """ import random #numero aleatório de 0 a 10 numero = random.randint(0,10) print (numero) #Forcar o python a selecionar sempre o mem numero random.seed(1) numero2 = random.randint(0,10) print (numero2) #Selecion...
false
bf82b6adb9dac5134d161d9c6978919f6dffb57b
Dhruv2550/Aspect-Ratio-Calculator
/Aspect Ratio Calculator.py
876
4.28125
4
def aspect_ratio(w, h, nw, nh,nratio): if nratio == 'width': nw = int(input("Enter the New Width\n")) if w - h < 0: nh = nw * (h / w) else: nh = nw / (w / h) elif nratio == 'height': nh = int(input("Enter the New Height\n")) if w - h > 0: ...
false
798e45402c0a205c7ce97410213f8402e09706cb
RomanoNRG/Cisco-DevOps-MDP-02
/Task2/Dicts_vs_List_Time_tradeoff.py
529
4.28125
4
# Program to demonstrate # space-time trade-off between # dictionary and list # To calculate the time # difference import time # Creating a dictionary d ={'john':1, 'alex':2} x = time.time() # Accessing elements print("Accessing dictionary elements:") for key in d: print(d[key], end=" ") y = time.time() print("...
true
118809abf08a5bdd94c9db133c55f07ae554c675
Mullins69/SimplePYcalculator
/main.py
1,571
4.25
4
print("Welcome to Mullins simple Calculator") print("Do you want to use the calc, yes or no?") question = input("yes or no, no caps: ") if question == "yes": print("Which would you like to use, addition, subtraction , division or multiplication? ") question2 = input("no caps : ") if question2 == "ad...
true
5cc753ba1aeb3b148cd575fbcb57c47313e15b08
pnkumar9/linkedinQuestions
/revstring.py
452
4.1875
4
#!/usr/local/bin/python3 # recursive def reverse1(mystring): if (len(mystring) == 0): return("") if (len(mystring) == 1): return(mystring) newstring=reverse1(mystring[1:])+mystring[0] return(newstring) # non-recursive without a lot of adding and subtracting def reverse2(mystring): newstring="" for i in rang...
true
940dfca49d079b7fe7476807ca550de96730c0b6
longfeili86/math487
/Homework/HW2/funcDefs.py
1,634
4.375
4
# This is the starter code for homework2. Do not change the function interfaces # and do not change the file name ####################################################### #Problem 1 ####################################################### # write a function that solves the linear system Ax=b, where A is an n by n tridia...
true
e45b63de61aa0edd4abf61641f145b7c5802af29
Thunder-Ni13/python-exercicios-guanabara
/PythonTest/aula007ex005.py
294
4.15625
4
n = int(input('Digite um número: ')) a = n - 1 b = n + 1 print('Analisando o número {}, seu antecessor é {} e seu sucessor é {} '. format(n, a, b)) n = int(input('Digite um número: ')) print('Analisando o número {}, seu sucessor é {} e seu antecessor é {} '. format(n, (n+1), (n-1)))
false
c6e9d1e78e796b8475a8a215709ac84e169e4935
PeterFriedrich/project-euler
/p4.py
1,242
4.1875
4
# A palindromic number reads the same both ways. The largest # palindrome made from the product of two 2-digit numbers # is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. # Palindrome function def isPal(num): numAux = num revnum = 0 # takes number a...
true
870e03d5aba2162f04f5ae6622d0fcee98d4daf5
sneaker-rohit/playing-with-sockets
/multithreaded echo app/client.py
1,094
4.125
4
# The program is intented to get used familarised with the sockets. # The client here sends a message to the server and prints the response received # Client side implementation. Below are the set of steps needed for the client to connect # 1. Connect to the address # 2. Send a message to the server # Author: Rohit ...
true
960443d850e10687b32b0df36aee867bdd8544d4
AntonioFry/messing-with-python
/main.py
738
4.125
4
print("Welcome to my first game!") name = input("What is your name? ") age = int(input("What is your age? ")) health = 10 if age >= 18: print("You are old enough!") wants_to_play = input("Do you want to play? ").lower() if wants_to_play == "yes": print("Let's play!") left_or_right = input("First choic...
true
9c91dbfc6ced145210d7fb46eee096167fc0db64
reksHu/BasicPython
/numpyModul/stockRange.py
402
4.15625
4
# 练习:计算股票价格的波动范围:在一定时期内最高的最高价 - 最低的最低价 import numpy as np def read_csv(): fileName="aapl2.csv" high_prices, low_prices = np.loadtxt(fileName,delimiter=',',usecols=(4,5),unpack=True) return high_prices,low_prices high_prices,low_prices = read_csv() stock_range = np.max(high_prices) - np.min(low_prices) ...
false
e2df04dc838999bf07badb47ae8990811931f23e
makhmudislamov/coding_challanges_python3
/module_2/last_factorial.py
1,057
4.28125
4
""" Prompt: Given a non-negative number, N, return the last digit of the factorial of N. The factorial of N, which is written as N!, is defined as the product of all of the integers from 1 to N. Given 3 as N, the factorial is 1 x 2 x 3 = 6 Given 6 as N, the factorial is 1 x 2 x 3 x 4 x 5 x 6 = 720 Given 9 as N, the...
true
75aa205b3e5494ce8e83effedfd0db31e08b4d98
makhmudislamov/coding_challanges_python3
/module_4/valid_anagram.py
876
4.34375
4
""" Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: false Note: You may assume the string contains only lowercase letters. Follow up: What if the inputs contain unicode cha...
true
75ea05edc4c6fd9a65e542a5998f8cf7efb15ad6
makhmudislamov/coding_challanges_python3
/module_4/find_index.py
1,001
4.3125
4
# -*- coding: utf-8 -*- """ Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Examples: [1,3,5,6], 5 → 2 [1,3,5,6], 2 → 1 [1,3,5,6], 7 → 4 [1,3,5,6], 0 → 0 """ def fin...
true
b96f08921bedc7c0faa7810428c108fbe6b42acd
makhmudislamov/coding_challanges_python3
/module_12_trees/balance_tree_stretch.py
2,562
4.53125
5
""" Given this implementation of a Binary Tree, write a function to balance the binary tree to reduce the height as much as possible. For example, given a tree where the nodes have been added in an order such that the height is higher than it could be: Nodes have been added in this order: tree = Tree() tree.add(No...
true
92e2e4ebb03fae16e319447a29fe27117854d889
jprice8/leetcode
/linked_lists/real_python.py
1,528
4.15625
4
# Class to represent the Linked List class LinkedList: def __init__(self): self.head = None # method adds element to the left of the linked list def addToStart(self, data): # create a temp node tempNode = Node(data) tempNode.setLink(self.head) self.head = tempNode...
true
ce739ae410b3bc59a42c8fa2d7952f1951d62935
jaeyoon-lee2/ICS3U-Unit1-04-Python
/area_and_perimeter.py
391
4.28125
4
#!/user/bin/env python3 # Created by: Jaeyoon # Created on: Sept 2019 # This program calculates the area and perimeter of rectangle # with dimensions 5m x 3m def main(): print("If the rectangle has the dimensions:") print("5m x 3m") print("") print("area is {}m^2".format(3*5)) print("perimete...
true
b4b64d43aad905857456d36c61b424c53d824cc7
TehWeifu/CoffeeMachine
/Problems/Long live the king/task.py
233
4.15625
4
column = int(input()) row = int(input()) if column == 1 or column == 8: if row == 1 or row == 8: print("3") else: print("5") else: if row == 1 or row == 8: print("5") else: print("8")
false
67ed8715ed674b3f1ed1994989cd4650597a7226
hemanthgr19/practise
/factorial.py
318
4.125
4
def fun(tea): if tea < 0: return 0 #print("0") elif tea == 0 or tea == 1: return 1 #print("the value is equal to 0") else: fact = 1 while (tea > 0): fact *= tea tea -= 1 return fact tea = 3 print(tea, fun(tea)) #print(n)
true
bf24b473c81d7f6a323f440b2caf1d030ee7fa6d
khoIT/10xclub-hw
/sorting/sorting_runtime.py
1,726
4.125
4
from datetime import datetime import random, sys from merge_sort import merge_sort, merge_sort_iterative from heapsort import heapify, heapsort def bubble_sort(arr): i = 0 while i < len(arr): j = 0 while j < len(arr)-1: if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j...
false
9199cc6e779fbd4e835a94c0f832a1121430905a
khoIT/10xclub-hw
/trie/two_strings_to_form_palindrome.py
614
4.15625
4
def two_strings_palindrome(arr): reversed = {} for string in arr: if string in reversed: return reversed.get(string), string if len(string) > 1: reversed[string[::-1]] = string reversed[string[:-1][::-1]] = string for string in arr: if string in re...
false
985c9b997b6a16a94014ae14bafe059812cd2621
Creedes/HarvardCourse
/python/lambda.py
318
4.1875
4
#nested datastructures people = [ {"name": "Harry", "house": "Gryffindor"}, {"name": "Cho", "house": "Ravenclaw"}, {"name": "Draco", "house": "Slytherin"}, {"name": "fungus", "house": "Ravenclaw"} ] #lambda says what sort() have to sort people.sort(key = lambda person: person["name"]) print(people)
false
dd45f1114aacf040a6726aab846c68f3da42a1c9
mraps98/ants
/src/ga.py
2,207
4.125
4
class SimpleGA: """ This is an implementation of the basic genetic algorithm. It requires a few functions need to be overriden to handle the specifics of the problem. """ def __init__(self, p): self.p = p def nextGen(self): """ Create the next generation. Returns t...
true
f476087e70dabc6ff4d7f5311f6d71175a323225
S1rFluffy/fogstream_courses
/Practice_1/task4.py
1,116
4.1875
4
""" Процентная ставка по вкладу составляет P процентов годовых, которые прибавляются к сумме вклада. Вклад составляет X рублей Y копеек. Определите размер вклада через год. Программа получает на вход целые числа P, X, Y и должна вывести два числа: величину вклада через год в рублях и копейках. Дробная часть копеек...
false
7f720a89090fdeddbd9e406d394b61850ba815c7
Aliot26/HomeWork
/comprehension.py
1,500
4.28125
4
# This program randomly makes a number from 1 to 20 for user guessing. import random # add random module guesses_taken = 0 # assign 0 to guesses_taken variable print('Hello! What is your name?') # print the message myName = input() # assign value printed by user to myName variable number = random.randint(1, 20) ...
true
32826a67b046670ad85a74a4ddbfdb3ec58cedfd
Aliot26/HomeWork
/reverse.py
324
4.15625
4
inputS = ("The greatest victory is that which requires no battle") def reverseString(inputString): inputString = inputString.split() inputString = inputString[-1::-1] output = " ".join(inputString) return output print("The greatest victory is that which requires no battle") print(reverseString(input...
true
023885a61005008c9b646bf0997de90f180d8c59
aman09031999/PythonTutorial_Basic
/list.py
1,634
4.125
4
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> # List in Python >>> >>> nums = [12,45,67,56,67] # list of number >>> nums [12, 45, 67, 56, 67] >>> name = ['Hello','Aman','Pradhan'] # list of Strin...
false
e55be7027d048b145d3981e2d81f7462fea954fe
ErnestoPena/Intro-Python-I
/src/13_file_io.py
919
4.25
4
""" Python makes performing file I/O simple. Take a look at how to read and write to files here: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files """ # Open up the "foo.txt" file (which already exists) for reading # Print all the contents of the file, then close the file files = open('C:...
true
4d5770e312d763bbc1d43ff27f521e64cbc3e2ff
Sunnyshio/2nd-year-OOP
/1st Semester Summative Assessment.py
1,120
4.375
4
# program that accepts the dimensions of a 3D shape (right-cyliner and sphere) and prints its volume class Shape: # Constructor method to process the given object: dimension def __init__(self, *argument): self.dimension = argument # printVolume method: code to process/calculate the volume o...
true
bd07f81e6c4b66c1422065c352832a6cd5561432
yasirabd/udacity-ipnd
/stage_3/lesson_3.2_using_functions/secret_message/rename_files.py
1,250
4.25
4
# Lesson 3.2: Use Functions # Mini-Project: Secret Message # Your friend has hidden your keys! To find out where they are, # you have to remove all numbers from the files in a folder # called prank. But this will be so tedious to do! # Get Python to do it for you! # Use this space to describe your approach to the pro...
true
c7348a4c84b5ef2de8d07b71c56816b052aa0d82
nlewis97/cmpt120Lewis
/rover.py
359
4.125
4
# Introduction to Programming # Author: Nicholas Lewis #Date: 1/29/18 # Curiosityroverexercise.py # A program that calculates how long it take a photo from Curiotsity to reach NASA. def timecalculator(): speed = 186000 distance = 34000000 time = distance/speed print("It will take", time, "seconds for...
true
2e7421cf23a1dbc4136687af7be0a67cd149d4c7
nlewis97/cmpt120Lewis
/madlib.py
423
4.15625
4
# Introduction to Programming # Author: Nicholas Lewis # Date: 2/2/18 # madlib.py # A program that functions as a madlib def madlib(): name = input("enter a name:") verb = input("enter a verb:") adjective = input("enter an adjective:") street = input("enter a street name:") print(name, "started to...
true
12365a6f64568bc9454cbd525e5a2b8d830d0bb4
Churqule/python_learning
/FAQ/slice.py
1,155
4.125
4
#!/usr/bin/env python3 # _*_ coding:utf-8 _*_ import os L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack'] #取前3个元素,用一行代码就可以完成切片: print(L[0:3]) #L[0:3]表示,从索引0开始取,直到索引3为止,但不包括索引3。即索引0,1,2,正好是3个元素。 #如果第一个索引是0,还可以省略: print(L[:3]) ''' 类似的,既然Python支持L[-1]取倒数第一个元素,那么它同样支持倒数切片,试试: ''' print(L[-2:]) print(L[-2:-1]) #切片操作十分有用...
false
942fbd118ccf3d93c6b397bfb9d06c0c6ed3a971
Churqule/python_learning
/FAQ/if_else.py
419
4.28125
4
#!/usr/bin/env python3 # _*_ coding:utf-8 _*_ import os age = 3 if age >= 18: print('adult') elif age >= 6: print('teenager') else: print('kid') ''' input()返回的数据类型是str,str不能直接和整数比较,必须先把str转换成整数。Python提供了int()函数来完成这件事情: ''' s = input('birth: ') birth = int(s) if birth < 2000: print('00前') else: p...
false
2d690cd3ff70d267947be2ee1b8f7875fa1f48a0
medhini/ECE544-PatternRecognition
/mp1/models/support_vector_machine.py
1,600
4.125
4
""" Implements support vector machine. """ from __future__ import print_function from __future__ import absolute_import import numpy as np from models.linear_model import LinearModel class SupportVectorMachine(LinearModel): def backward(self, f, y): """Performs the backward operation. By backwar...
true
98c76a84e5362b78d5e36590990ed9de3f700add
VitaliiStorozh/Python_marathon_git
/8_sprint/Tasks/s8_1.py
2,585
4.21875
4
# Write the program that calculate total price with discount by the products. # # Use class Product(name, price, count) and class Cart. In class Cart you can add the products. # # Discount depends on count product: # # count discount # 2 0% # 5 5% # 7 10% # 10 20% # 20 30% # more than 20 50% # Write unittes...
true
626884ee70540431a1f36f56e99afd2487171c25
VitaliiStorozh/Python_marathon_git
/3_sprint/Tasks/s3.2.py
326
4.125
4
# Create function create with one string argument. # This function should return anonymous function that checks # if the argument of function is equals to the argument of outer function. def create(str): return lambda str1: str1 == str tom = create("pass_for_Tom") print(tom("pass_for_Tom")) print(tom("pass_for_...
true
cdfa670aeb908033858308055aa4802dda5fc4f3
Okreicberga/programming
/week04-flow/guess2.py
418
4.25
4
# Program that promts the user to guess a number # the program tell the user if there to guess to high or too low, each time they guess. numberToGuess = 30 guess = int(input("Please guess the number:")) while guess != numberToGuess: if guess < numberToGuess: print("too low") else: print("too high") gue...
true
21a98009d75c3648b6fdac4f6ac64bc9a574b917
Okreicberga/programming
/labs/Topic09-errors/useFib.py
218
4.15625
4
# Author Olga Kreicberga # This program prompts the user for a number and # Prints out the fibonacci sequence of that many numbers import myFunctions nTimes = int(input('how many:')) print (myFunctions.fibonacci(nTimes))
true
8937f36dbe99019123b72af1cc0e60f0e9b1f231
AgileinOrange/lpthw
/ex32.py
274
4.28125
4
# Exercise 32 Loops and Lists the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] # this first kind of for-loop goes through a list for number in the_count: print(f'This is count {number}')
true
9ddeb98336bc7a229d71c532ff6ca1bd544c4c67
Mr-koding/python_note
/working_with_string.py
792
4.1875
4
# String formatting/manipulation # String is an array of characters/object # A string an immutable sequence of characters myString = "this is a string" "this 23 is also string" "344" "" " " "True" 'I can have single quote' "@#$%#$%&^" "[34,34,56]" # Strings have indices print(myString[2]) # i # Slicing can be per...
true
df50a7e0b27fc1a865fa980625ce50bafe122119
fatimabenitez/bootcamp
/clases/dino.py
1,248
4.25
4
""" #funciona pero esta comentado class Dino: def __init__ (self): print("----------------Naci----------------") pepe=Dino() """ """ class Dino: ojo = 2 def __init__(self, un_nombre, un_color, canti_patas=4, un_genero=None): self.nombre = un_nombre self.color = un_color self...
false
a05f262054a8eefcddfefdbd7e8883085aee5b9d
SURYATEJAVADDY/Assignment
/assignment/assignment1_4.py
786
4.28125
4
# Write a class that represents a Planet. The constructor class should accept the arguments radius (in meters) and rotation_period (in seconds). # You should implement three methods: # (i)surface_area # (ii)rotation_frequency import math class Planet: def __init__(self): self.radius = int(input("Ent...
true
370325ad5443eb93ee3179152c7b8380dbdbb6c4
aribis369/InformationSystemsLab
/numpyhw.py
2,133
4.1875
4
# Program to get analysing student marks for different subjects. import numpy as np # Generating array for 10 students and 6 subjects A = np.random.randint(low=0, high=101, size=(10,6)) try: choice = int(input("Enter your choice\n" "1) Students with highest and lowest total marks\n" ...
true
fe6f064841aa0934d61dd3f11677c84fa18f4f36
yabur/LeetCode_Practice
/Trees/Tree_Practice/Practice_Set1/IsBST.py
1,513
4.15625
4
# Is It A BST # Given a binary tree, check if it is a binary search tree (BST). A valid BST does not have to be complete or balanced. # Consider the below definition of a BST: # 1- All nodes values of left subtree are less than or equal to parent node value # 2- All nodes values of right subtree are greater ...
true
b2d231a9a260802889ed8929c62cf81429df8636
yabur/LeetCode_Practice
/Graphs/GraphFoundation/AdjacencyList.py
1,337
4.25
4
# Adjascency List representation in Python class AdjNode: def __init__(self, value): self.vertex = value self.next = None # A class to represent a graph. A graph # is the list of the adjacency lists. # Size of the array will be the no. of the # vertices "V" class Graph: def __init__(self, ver...
true
36e87e1e2c56a436f958846964b43f7523603e6a
Rajpratik71/pythonTrainAppin
/Nestedif.py
262
4.125
4
a=int(input("enter the number for a: ")) b=int(input("enter the number for ")) c=int(input("enter a number")) if a>b: if a>c: print("the greatest number is 'a'") elif: print("the greatest number is 'b'") else: print("the greattest no is 'c'")
false
61e0ee03f7b42d02bfef3c307e1442a7fa89ad3b
wldrocha/Python
/3.py
348
4.3125
4
#-*- coding: utf-8 -*- # #ejercicio #3 # Mostrar el resultado de elevar el numero 2 al cuadrado y al cubo. numero = raw_input('Introduce el número a sacarle el cadrado y el cubo de si: ') cuadrado = numero**2 cubo = numero**3 print "el cuadrado de "+str(numero)+" es igual a "+str(cuadrado) print "el cubo de "+str(numer...
false
97fa7bf41d2c14e3bcfc26eadbdf964f4ada08a1
jonathasfsilva/lab-jfs-20181
/algOrdenacao.py
2,971
4.25
4
u"""Algoritmos de Ordenação. - BublleSort - InsertSort - MergeSort - QuickSort - SelectSort """ # dfdf def mergeSort(lista): """MergeSort. Recebe uma lista e retorna a lista ordenada por mergeSort. """ if len(lista) > 1: meio = len(lista)//2 ladoDireito = lista[:meio] ladoEsq...
false
d29730d76c28c24a0c2be8ec32f7e9a1489b1c5a
lvonbank/IT210-Python
/Ch.03/P3_2.py
489
4.125
4
# Levi VonBank ## Reads a floating point number and prints “zero” if the number is zero. # Otherwise “positive” or “negative”. “small” if it is less than 1, # or “large” if it exceeds 1,000,000. userInput = float(input("Enter a floating-point number: ")) if userInput == 0: print("It's zero") elif userInput > ...
true
aa4fb45cf22cf8d68e6d311cf1efc7552d42bd41
lvonbank/IT210-Python
/Ch.04/P4_5.py
913
4.125
4
# Levi VonBank # Initializes variables total = 0.0 count = 0 # Priming read inputStr = input("Enter a value or Q to quit: ") # Initializes the largest and smallest variables largest = float(inputStr) smallest = float(inputStr) # Enters a loop to determine the largest, smallest, and average while inputStr.upper() !=...
true
80b94f65df7acf89744b8a1fbdbc74177e09e7ad
lvonbank/IT210-Python
/Lab07/Lab07.py
1,144
4.4375
4
# Levi VonBank # Group Members: Scott Fleming & Peter Fischbach def main(): # Obtains strings from the user set1 = set(input("Enter a string to be used as set1: ")) set2 = set(input("Enter a string to be used as set2: ")) set3 = set(input("Enter a string to be used as set3: ")) # Determines eleme...
true
295263667e05765c97cc89de5d6b54ed02109d48
lvonbank/IT210-Python
/Ch.03/P3_21.py
357
4.21875
4
# Levi VonBank ## Reads two floating­point numbers and tests whether # they are the same up to two decimal places. number1 = float(input("Enter a floating-point number: ")) number2 = float(input("Enter a floating-point number: ")) if abs(number1 - number2) <= 0.01: print("They're the same up to two decimal plac...
true
ce7a6159d432f1ae5c820279cf3c77ed8d4a85fd
AsdaRD/Shakh_Intro_Python_09_06_21
/lessons/lesson_6.2.py
1,446
4.125
4
# множества set - не сохраняет порядок, все элементы уникальные # my_list = [3, 10, 10, 2, 2, "2", 3, 3, 3, 3, 3, 3] # my_list_unique = list(set(my_list)) - убирает дубли # my_set = set(my_list) # print(my_set) # my_list_unique = list(my_set) # # print(my_list_unique) # new_set = {1, 2, 3, 4, 54, 54} # print(new_set) ...
false
29173826db662583656792fac1fc39f18e7f2958
NikDestrave/Python_Algos_Homework
/Lesson_3.9.py
961
4.125
4
""" Задание_9.Найти максимальный элемент среди минимальных элементов столбцов матрицы. Пример: Задайте количество строк в матрице: 3 Задайте количество столбцов в матрице: 4 36 20 42 38 46 27 7 33 13 12 47 15 [13, 12, 7, 15] минимальные значения по столбцам Максимальное среди них = 15 """ from random import random...
false
16afd1d6f6291e39cd87abb83115dd6faee3b91a
mef14/data_structures
/binary_tree.py
1,467
4.34375
4
# -*- coding: utf-8 -*- class BinaryTree(object): """ Binary Tree implementation. """ def __init__(self, key): self.key = key self.leftChild = None self.rightChild = None def insertLeft(self, newNode): t = BinaryTree(newNode) if not self.leftChild: self.leftChild = t else:...
false
92d19754dff461772d3e1a2e4f0d5d3a815cc4f5
FredericVets/PythonPlayground
/helloPython.py
1,036
4.28125
4
""" Notes from Python Programming https://www.youtube.com/watch?v=N4mEzFDjqtA by Derek Banas """ print("Hello Python") print('Hello Python') # single or double quotes are treated the same. ''' I'm a multiline comment. ''' name = "Frederic" print(name) name = 10 print(name) # 5 main data types : Numbers String...
true
08035695d95b28c86e07a4b858270c15b88a7ec4
FredericVets/PythonPlayground
/conditionals.py
292
4.15625
4
# keywords : if, else; elif # conditionals : == != > >= < <= # logical operators : and or not age = 15 if age >= 21: print("You are old enough to drive a tractor trailer") elif age >= 16: print("You are old enough to drive a car") else: print("You are not old enough to drive")
false
c99a6a6246a88c7c55e13de677c4b0d9dde09c84
eveminggong/Python-Basics
/7. Tuples.py
924
4.28125
4
tuple1 = (1,2,3) tuple2 = (5,6,7) tuple3 = ('Red', 'Blue', 'Black') print(f'Tuple1: {tuple1}') print(f'Tuple2: {tuple2}') print(f'Tuple3: {tuple3}') def add_tuple(Tuple1, Tuple2): FinalTuple = Tuple1 + Tuple2 print(f'The tuples are added {FinalTuple}') add_tuple(tuple1,tuple2) def duplicate_tuple(Tuple1,...
true
ec61070b91028fe626d24645c354dea9364199be
ramanathanaspires/learn-python
/basic/ep13_iterators_comprehensions_genfunc_genexp/generator_expressions.py
223
4.125
4
double = (x * 2 for x in range(10)) print("Double:", next(double)) print("Double:", next(double)) print("Double:", next(double)) print("Double:", next(double)) print("Double:", next(double)) for num in double: print(num)
true
dc2ab7aa13e66dfd39cf9f523e4a0a7320326f51
ramanathanaspires/learn-python
/basic/ep4_string_functions/acronym_generator.py
287
4.21875
4
# Ask for a string string = "Random Access Memory" ACR = "" # Convert the string to uppercase string = string.upper() # Convert the string into a list string = string.split() # Cycle through the list for i in string: # Get the 1st letter of the word print(i[0], end="") print()
true
f7d3deda15f5fa65cb0dfbfce4d9cba884c3eb6c
IamP5/Python---Loops
/Question3.py
354
4.28125
4
""" Make a program that receive a float number "n". If the number is greater than 157, print "Goal Achieved" and break the loop. Else, print "Insufficient" and read a new number "n". You should read at most 5 numbers """ for i in range(5): i = float(input()) if i > 157: print("Goal Achieved") break ...
true
44252d3a22878ea2f3f669d944f73e2992d627cf
amirobin/prime
/home_study/missing2.py
324
4.125
4
def find_missing(list1,list2): missingout = 0 if len(list1) > len(list2): longer_list = list1 shorter_list = list2 else: longer_list = list2 shorter_list = list1 for val in longer_list: if val not in shorter_list: missingout = val print missingout find_missing([1,6,7,8,9],[1,6,8...
true
4b3a5c066c3f2417a58c4318f9119aeaf5bd916f
mbreault/python
/algorithms/check_permutations.py
618
4.1875
4
## given two strings check if one is a permutation of the other ## method 1 using built-in python list methods def sorted_chars(s): ## sort characters in a string return sorted(set(s)) def check_permutation(a,b): if a == b: return True elif len(a) != len(b): return False els...
true
001ec9b81f35b566172d5acad526457c670df3e5
Shaw622/Introducing_Python
/Chapter03/HW.py
839
4.28125
4
years_list = [1991, 1992, 1993, 1994, 1995, 1996] print(years_list[3]) print(years_list[-1]) things = ["mozzarella", "cinderella", "salmonella"] print(things) print(things[1].capitalize()) print(things) things[1] = things[1].capitalize() print(things) things[0] = things[0].upper() print(things) del things[-1] prin...
false
1f92c8e71474d67e720967c544bca4fa1b9ba8dd
ajayvenkat10/Competitive
/slidingwindow.py
1,657
4.4375
4
# Python3 program to find the smallest # window containing # all characters of a pattern from collections import defaultdict MAX_CHARS = 256 # Function to find smallest window # containing # all distinct characters def findSubString(str): n = len(str) # Count all distinct characters. dist_count = len(set([x fo...
true
bd2737365d163236c1640be6973584bd194e48ea
dstada/Python
/test2.py
1,230
4.28125
4
""" Tests whether a matrix is a magic square. If it is, prints its magic number. INPUT INSTRUCTIONS: Either just press "Submit" or enter EACH ROW IN A NEW LINE. Separate entries by comma and/or space. Example 1: 1, 2, 3 4, 5, 6 7, 8, 9 Example 2: 7 12 1 14 2 13 8 11 16 3 10 5 9 6 15 4 """ import numpy as np def is...
true
94fb53db05943459330902864360926149c3d610
dstada/Python
/Is that an IP address.py
1,384
4.21875
4
"""Is That an IP Address? Given a string as input, create a program to evaluate whether or not it is a valid IPv4 address. A valid IP address should be in the form of: a.b.c.d where a, b, c and d are integer values ranging from 0 to 255 inclusive. For example: 127.0.0.1 - valid 127.255.255.255 - valid 257.0.0.1 - in...
true
0bc0a586aca6cc1a7d1a02df1b898a753b40f893
dstada/Python
/[Challenge] Prime Strings.py
950
4.1875
4
"""Prime Strings A String is called prime if it can't be constructed by concatenating multiple (more than one) equal strings. For example: "abac" is prime, but "xyxy" is not ("xyxy" = "xy" + "xy"). Implement a program which outputs whether a given string is prime. Examples Input: "xyxy" Output: "not prime" Input: ...
true
eb38f1c9a63f9d009a1236af993ecdfd08bc0672
dstada/Python
/rgb to hex.py
1,437
4.5
4
""" RGB to HEX Converter RGB colors are represented as triplets of numbers in the range of 0-255, representing the red, green and blue components of the resulting color. Each RGB color has a corresponding hexadecimal value, which is expressed as a six-digit combination of numbers and letters and starts with the # sig...
true
3344e55d98db5c3825de7bd85e21155d10bf84a6
sridharbe81/python_sample_program
/String Formating.py
421
4.15625
4
dict = {'Name':'Vivek', 'Age':'33'} print('My Name is {} and I am {} Old.'.format(dict['Name'],dict['Age'])) print('My name is {Name} and I am {Age} years old'.format(**dict)) pi = 3.14378 print('The Value of pi is {:.02f}'.format(pi)) import datetime my_date = datetime.datetime(2017,4,17, 7,16,15) print...
false
7d3386351d9205a438cf9876d0408f7f3c2e9652
anamarquezz/BegginerPythonEasySteps
/hello/hello/for_loop_excercises.py
1,324
4.1875
4
print("\n ....prime numbers......... \n") def is_prime(number): # check if number is divisible by 2 to numner =1,2,3,4 if(number < 2): return False for divisor in range(2, number): if number % divisor == 0: return False return True print("is prime? 5 \n") print(is_prime(...
false
d4df46d410ba8a5da505b799aa070dbc651fb258
AbinayaDevarajan/google_interview_preparation
/dynamic_programming/fibonacci.py
937
4.1875
4
import timeit """ Top down approach by using the recursion: """ def fibonacci(input): if input ==0: return 1 elif input ==1: return 1 else: return fibonacci(input-1) + fibonacci(input -2 ) """ memoization usage of cache """ def fibonacci_memo(input, cache=None): if input =...
true
1cddccfcd681221093b1a367335b5fa41c1c6271
victoire4/Some-few-basic-codes-to-solve-the-problem
/3.The Longest word.py
583
4.375
4
def longest(N): # We define the function A = N.split(' ') # A is a list. Each element of A is one word of N L = 0 # Initialisation of the size for the comparison for i in range(0,len(A)): if (len(A[i]) > L): W= A[i] L = len(A[i]) ...
true
b093714348f4756585e4a329323f58b7a2c28af9
doxmx/dojo
/katas/leapyear/py/test.py
1,975
4.15625
4
import unittest # Import the function(s) to test, e.g.: from kata import is_leap_year # Implement tests here class TestTemplate(unittest.TestCase): # Define as many tests cases as needed def test_case(self): """ Test Case 1 """ data = [True] result = data[0] sel...
false
6fe7e5516c8a1b0052f41b8f944151b971e840e0
MillicentMal/alx-higher_level_programming-1
/0x07-python-test_driven_development/0-add_integer.py
533
4.15625
4
#!/usr/bin/python3 """ This is the "0-add_integer" module. The 0-add_integer module supplies one function, add_integer(). """ def add_integer(a, b=98): """My addition function Args: a: first integer b: second integer Returns: The return value. a + b """ if (a is None or (not isinstance(a, int) and ...
true
8287ac8f2d458302a9de577d017bace013f74246
Mauricio-KND/holbertonschool-higher_level_programming
/0x06-python-classes/6-square.py
2,904
4.46875
4
#!/usr/bin/python3 """Module that creates an empty square.""" class Square: __size = 0 """Square with value.""" def __init__(self, size=0, position=(0, 0)): """Initialize square with size and position.""" if not isinstance(size, int): raise TypeError("size must be an integer") ...
true
9a99e019e0277ed5cbf5b89f497e623aa880ea03
c212/spring2021-a310-labs
/march/lecture-march-08/BST-tests.py
627
4.15625
4
from BST import * num = 6 a = BST(num) print("Start from empty, insert ", num) a.display() num = 3 print("----Now insert ", num) a.insert(BST(num)) a.display() print("---And insert 2:") a.insert(BST(2)) a.display() numbers = [7, 9, 0, 8, 1, 4, 5] print("---And insert (in order): ", numbers) for num in numbers: a.ins...
false
70f61d6b99a071e58621ce3f570badb3d26ac767
chenjb04/fucking-algorithm
/LeetCode/字符串/387字符串中的第一个唯一字符.py
904
4.15625
4
""" 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 示例: s = "leetcode" 返回 0 s = "loveleetcode" 返回 2 提示:你可以假定该字符串只包含小写字母。 Related Topics 哈希表 字符串 """ """ hash: 遍历字符串,如果字符不在hash中,加入hash,key为字符:value为索引 如果字符存在hash中,那么value可以设为长度,最后返回最小索引 """ def firstUniqChar(s: str) -> int: if not s: return -1 hash_map = {} ...
false
c624af739fddb8f72a59134c74a13ecfebecbe21
chenjb04/fucking-algorithm
/LeetCode/栈和队列/用递归函数和栈操作逆序一个栈.py
1,653
4.125
4
""" 一个栈依次压入1、2、3、4、5,那么从栈顶到栈底分别为5、4、3、2、1。将这个栈转置后, 从栈顶到栈底为1、2、3、4、5,也就是实现栈中元素的逆序, 但是只能用递归函数来实现,不能用其他的数据结构。 """ """ 解题思路: 需要两个递归函数,get_remove_last将栈底元素返回并移除; reverse栈的逆序 get_remove_last: 先pop出栈顶元素 然后弹出并返回少了一个元素的栈的栈底元素 最后把value压入栈顶 reverse: 调用get_remove_last获取栈底元素 然后调用reverse对少了一个元素的栈进行逆序处理 最后把value压入栈,...
false
77f20853645d1d5657a674aaead9aefd37feefb8
chenjb04/fucking-algorithm
/LeetCode/栈和队列/232用栈实现队列.py
2,838
4.3125
4
# 使用栈实现队列的下列操作: # # # push(x) -- 将一个元素放入队列的尾部。 # pop() -- 从队列首部移除元素。 # peek() -- 返回队列首部的元素。 # empty() -- 返回队列是否为空。 # # # # # 示例: # # MyQueue queue = new MyQueue(); # # queue.push(1); # queue.push(2); # queue.peek(); // 返回 1 # queue.pop(); // 返回 1 # queue.empty(); // 返回 false # # # # 说明...
false
1b9ed4be63989a054f4c3866ef9fa35c4927c1ac
livneniv/python
/week 2/assn2.py
446
4.1875
4
#Write a program to prompt the user for hours and rate per hour to compute gross pay user_name=raw_input('Hi Sir, Whats your name? ') work_hours=raw_input('and how many hours have you been working? ') work_hours=float(work_hours) #converts type from string to float rate=raw_input('pardon me for asking, but how much do...
true
9c695f5445161a76936e72ac336a9253d9113541
s4git21/Two-Pointers-1
/Problem-1.py
1,086
4.15625
4
""" Approach: 1) if you were to sort the first and last flag, your middle flag is automatically sorted 2) use two pointers to keep track of the sorted indices for 0 and 2 3) you'd need to have a 3rd pointer to make comparisons from left to right 4) swap elements at 3rd moving pointer with either left/right pointer if 0...
true
50bc005b9baea7ad7e64f4ec4f95149c94ab2b0c
grogsy/python_exercises
/csc232 proj/encrypt.py
2,898
4.28125
4
import random import string import sys symbols = list(string.printable)[:94] def encrypt(text): """Add three chars after every char in the plaintext(fuzz) After, substitue these chars with their hex equivalent(hexify) input: string sentence returns: string >>> encrypt('secret message') ...
true
2f0fbbe6d72d54c7ca98ed12821a1b12e59a2313
grogsy/python_exercises
/datastructures/merge_sort.py
768
4.1875
4
def merge_sort(arr): if len(arr) <= 1: return arr left = [] right = [] midpoint = len(arr) // 2 for i, element in enumerate(arr): if i < midpoint: left.append(element) else: right.append(element) left = merge_sort(left) right = merge_sort...
true
34445e45fd10f8a252f743c9410099857c8ca96d
kiksnahamz/python-fundamentals
/creating_dictionary.py
1,040
4.75
5
#Creating a dictionary from a list of tuples ''' Creating a list of tuples which we name "users" ''' users = [ (0, "Bob", "password"), (1, "Rolf", "bob123"), (2, "Jose", "longp4assword"), (3, "username", "1234"), ] ''' we are transcribing the data from users into a dictionaries. The fir...
true
46104a9824c0c549577b73a45c048bc7009936ca
rsheftel/raccoon
/raccoon/sort_utils.py
1,828
4.15625
4
""" Utility functions for sorting and dealing with sorted Series and DataFrames """ from bisect import bisect_left, bisect_right def sorted_exists(values, x): """ For list, values, returns the insert position for item x and whether the item already exists in the list. This allows one function call to ret...
true
115a859802940f367926d1487f65bb874e075d41
xatlasm/python-crash-course
/chap4/4-10.py
267
4.25
4
#Slices cubes = [cube**3 for cube in range(1,11)] print(cubes) print("The first three items in the list are: ") print(cubes[:3]) print("Three items from the middle of the list are: ") print(cubes[3:6]) print("The last three items in the list are: ") print(cubes[-3:])
true
16bd7425b8d794c6ccdb22fbb12d1f764c4ccd7e
Jayoung-Yun/test_python_scripts
/repeating_with_loop.py
903
4.28125
4
word = 'lead' print word[0] print word[1] print word[2] print word[3] print '========================' word = 'oxygen' for char in word: print char # space is necessar! length = 0 for vowel in 'aeiou' : length = length +1 print (' In loop : There are'), length, ('vowels') print ('There are'), length, ('vowe...
true
9d10008f588fe46246752758f08b27d66cde8ba8
leonardlan/myTools
/python/list_tools.py
936
4.28125
4
'''Useful functions for lists.''' from collections import Counter def print_duplicates(my_list, ignore_case=False): '''Print duplicates in list. Args: my_list (list): List of items to find duplicates in. ignore_case (bool): If True, case-insensitive when finding duplicates. Returns: ...
true
de7566c719dd416848d89a6a1710cd12a534230e
sabil62/Python-and-Data-Analysis
/matplotlib.py
353
4.125
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 10 22:15:24 2019 @author: User """ import matplotlib.pyplot as plt x= [0,1,2,3,4,5,6] y= [i**2 for i in x] z= [i**3 for i in x] plt.plot(x,y,'r',label='square') plt.plot(x,z,':',label='cubic') plt.legend() #this is just to show axes comment this out plt.xlim(-1,7) plt.y...
false