blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f67dc059f382699180b17a1c9d2ca2708504f2db
AmazingCaddy/PythonCode
/exercise/MyOperator.py
560
4.125
4
#!/usr/bin/env python #coding: utf-8 def Operator(): x = int(raw_input('Enter x: ')) y = int(raw_input('Enter y: ')) print 'x + y = ' + str(x + y) print 'x - y = ' + str(x - y) print 'x * y = ' + str(x * y) print 'x / y = ' + str(x / y) print 'x // y = ' + str(x // y) print 'x % y = ' + str(x % y) print...
false
83d5431831804d453b09cf5670061394685d3418
TylerHJH/DataStructure
/lab1_e3.py
762
4.34375
4
""" Input: First we have a empty list Hailstone. n: Get a number n and put it into the list, then judge whether is even or odd. If it's even, put n/2 into the list Hailstone, else put 3n+1 into the list. Then continue to judge whether the calculated number n/2 or 3n+1 is odd or even and do the same o...
true
a04385440109a511922a3d4b5c52973a1fe94eeb
biu9/cs61a
/lab01.py
1,402
4.15625
4
def falling(n, k): """Compute the falling factorial of n to depth k. >>> falling(6, 3) # 6 * 5 * 4 120 >>> falling(4, 3) # 4 * 3 * 2 24 >>> falling(4, 1) # 4 4 >>> falling(4, 0) 1 """ "*** YOUR CODE HERE ***" total = 1 for i in range(n,n-k,-1): total = tot...
false
57d5bbcba5804c546fe168de0c62bf3397c3836d
YOON93KYS/python_renshu
/basic/5-4-2/main2.py
408
4.1875
4
''' 5-4-2. 実践演習 1)5-3-2の関数(def)で定義したadd関数でnum_1とnum_2を足した値を返すように変更せよ 2)add関数に10,20を渡して戻り値を受け取り、出力せよ (目標20分) ''' ''' #2)add関数に10,20を渡して戻り値を受け取り、出力せよ ''' def add_3(num_1, num_2): return(num_1 + num_2) print(add_3(10, 20))
false
053bbf84269b6a100eace6160769e4e370108201
Muoleehs/Muoleeh
/Task_7.py
673
4.15625
4
import statistics from array import * # The * above implies the need to work with all array functions arr = array ('I', []) # 'I' represents a type code for unsigned/positive integers as the task demands length = int(input("Enter the length of the array: ")) # This collects the number of integers expected in ...
true
85afdfdc5b985e0ed5a51ad251690345e69d94bd
magatj/Job_And_Res_Parser
/Random_Word.py
2,857
4.125
4
import random import pandas as pd def rand_word(): '''Transform excel column and row files to a dictionary''' word_list = [] q1 = input('What is the file location \n (file must only have on column with a header and values \n\ example: C:/Users/jesse/Desktop/Word_list.xlsx)')#'C:/User...
true
d80e96637b85bc4db58a814e19d7f2724efdded7
se7enis/learn-python
/webapp/cgi-bin/createDBtables.py
682
4.15625
4
import sqlite3 connection = sqlite3.connect('coachdata.sqlite') # establish a connection to a database; this disk file is used to hold the database and its tables cursor = connection.cursor() # create a cursor to the data cursor.execute("""CREATE TABLE athletes( id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NUL...
true
be349070298d6a455ad7b1613d2eee5f1dbfe3a5
Ubagaly/lessons_py
/Lessons 1/zadacha1.py
396
4.125
4
# Решение 1 задания name=input("Введите Ваше имя:") surname=input("Введите Вашу фамилию:") age=int(input("Cколько Вам лет?:")) c=int(input("Введите любое целое число:")) print (f"{name} {surname} в данный момент Вам: {age} ") age_c=age+c print (f"Через {c} лет Вам будет: {age_c} ")
false
5d52ea7ca0578936a860b55dc5e14396e09272b9
kas/ctci
/02-linked-lists/07.py
681
4.21875
4
# implement a function to check if a linked list is a palindrome from doublylinkedlist import DoublyLinkedList def palindrome(doubly): palindrome = False s = '' itr_nd = doubly.head while itr_nd: s += str(itr_nd.data) itr_nd = itr_nd.next_node if s[::-1] == s: palindrome ...
false
b6600be05f7aaab0b30065fdd8efefb6897181e4
sujay-dsa/ISLR-solutions-python
/Chapter-2-Intro-to-statistical-learning.py
1,707
4.15625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 20 22:28:35 2018 Here I try to map the commands specified in R to the python equivalent. All commands are as mentioned in ISLR chapter 2. @author: Sujay """ # Basic Commands # creating a vector (python equivalent is list) x=[1,2,3,4] y = [1,4,3,7] type(x) # Findin...
true
3a30077f0f59df38612411201149dad154069646
Zerl1990/2020_python_workshop
/12_lists.py
385
4.25
4
# A list can contain values of different types my_list = ["Hello", "Hi", 10, False] # Print values in list print(f'This is my list: {my_list}') print(f'First Value: {my_list[0]}') print(f'Second Value: {my_list[1]}') print(f'Third Value: {my_list[2]}') print(f'Fourth Value: {my_list[3]}') # Add extra value my_list.ap...
true
707ddc672d67b78308356f7a14e85973d414ad6a
Zerl1990/2020_python_workshop
/11_tuples.py
293
4.125
4
# A tuple can contain values of different types tuples = ("Hello", "Hi", 10, False) # Print tuple information print(f'This is my tuple: {tuples}') print(f'First Value: {tuples[0]}') print(f'Second Value: {tuples[1]}') print(f'Third Value: {tuples[2]}') print(f'Fourth Value: {tuples[3]}')
false
dcdfb53769710b6345d2363183167b1adb075ffa
joelcede/programming_languages
/python3/BitCounting.py
718
4.25
4
''' Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case. ''' def count_bi...
true
7ddf9b6a3da88ae4dde1a83da6425d387f8fe6c4
AnasBrital98/Regression-analysis
/Linear_Regression_Using_Least_square_Method.py
1,076
4.21875
4
import numpy as np import matplotlib.pyplot as plt from sklearn.datasets import make_regression x , y = make_regression(n_samples=100 , n_features= 1 , noise=10) """ Our Linear Model Looks like this : Y_estimated = theta[0] + theta[1] * x . our goal is to compute the coefficients Theta[0] and Theta[1] that will fit...
false
f36c3605339edeea69b4c8b982fe343a9378e85d
Praful-Prasad/COMPLETED
/COMPLETED/ex1/13. Fibonacci.py
235
4.28125
4
n=int(input('Enter a number : ')) print("Fibonacci series till n = ") sum2=0 sum=1 print(0,end=" ") print(1, end =" ") for i in range(0,n+1): sum3=sum+sum2 sum2=sum sum=sum3 print(sum,end= " ")
false
02760cdd7504f5ea11125f313bbe196469866d76
chyld/berkeley-cs61a
/misc/lab01/lab01_extra.py
663
4.25
4
from functools import reduce """Coding practice for Lab 1.""" # While Loops def factors(n): """Prints out all of the numbers that divide `n` evenly. >>> factors(20) 20 10 5 4 2 1 """ "*** YOUR CODE HERE ***" nums = [x for x in range(1, n+1) if not(n%x)] nums.sort() ...
true
236385c58e9fd1f164336b632cee97ceab94f215
sameervirani/week-1-assignments
/fizzbuzz.py
367
4.28125
4
#Take input from the user. If the input is divisible by 3 then print "Fizz", #if the input it divisible by 5 then print "Buzz". #If the input is divisible by 3 and 5 then print "Fizz Buzz". user1 = int(input("Enter number: ")) if user1 % 3 == 0 and user1 % 5 == 0: print("Fizz Buzz") elif user1 % 3 == 0: print(...
true
1b5a6eca3df1fa66ecf3d3b56b2e41f273af07a5
Nabdi22/TTA
/DFD-Code.py
598
4.125
4
print("Hello Welcome to Nafisa's Shoe Shop") shoe_size = int(input("Please enter your shoe size: ")) if shoe_size > 6: print("You will need to shop from the Adult Section") else: print("You will need to shop from the Junior Section") print("Please choose from our three different brands which are Nike...
true
e1284e6ec7edccbd7e16479288c8b9a48ecc4dc0
lakshyarawal/pythonPractice
/Mathematics/computing_power.py
875
4.15625
4
""" Computing Power: Find x raised to the power y efficiently """ import math """ Naive Solution: """ def comp_power(a, b) -> int: power_result = 1 if b == 0: return power_result for i in range(b): power_result = power_result * a return power_result """ Efficient Solution: Divide t...
true
4125cc5cddbea0f79f8b4ab1312c78eeb8493274
dvanduzer/advent-of-code-2020
/day2-2.py
1,295
4.1875
4
""" For example, suppose you have the following list: 1-3 a: abcde 1-3 b: cdefg 2-9 c: ccccccccc Each line gives the password policy and then the password. The password policy indicates the lowest and highest number of times a given letter must appear for the password to be valid. For example, 1-3 a means that the pas...
true
ed0443b6c95d9ec77dafc2dfdd66e0a86a5ed180
DvorahC/Practice_Python
/exercice2_easy.py
723
4.15625
4
""" Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. Extras: Add: asking the user for another number and printing out that many copies of the previous message. (Hint: order of operations exists in Py...
true
f7c25cf743a72a8029f30f5ea059efbc67c7cdc2
jeremyt0/Practice-Tasks
/reverse.py
560
4.4375
4
task = """In python, you have a list of values n elements long called value_list. Create a second list that is the reverse of the first, starting at the last element, and counting down to the first.""" def reverseList(list1): newlist = [] n=0 while n<len(list1): newlist.append(list1[len(list1)-1]) ...
true
4ad39a656ac13778c9f38d91e6cc475336d94863
sasikrishna/python-programs
/com/ds/Stack.py
1,085
4.125
4
class Stack: """" Stack implementation in python. """ def __init__(self): self.stack = []; self.top = -1; def push(self, value): self.stack.append(value); self.top += 1; return True; def peek(self): if self.top == -1: return; ...
false
cb5993d7038d87f1d89a16986304b04eed125b58
Amirpatel89/CS-Fundamentals
/Day1/Bubblesort.py
343
4.15625
4
array = [5, 3, 2, 4, 1] def bubble_sarray(list) = swapped = True; while swapped == True: while swapped: False for i in range(len(a) - 1): if list[i]>list[i+1]: temp = list[i] list[i] = list[i+1] list[i+1] = temp bubbleSort(list) pri...
true
fb5d104195bc067404b8b128105e5762497b73d9
joannaluciana/Python-OOP-
/oop/day2/hwday2/6 he lambda.py
1,080
4.5
4
#6. Write a Python program to square and cube # every number in a given list # of integers using Lambda. Go to the editor #Click me to see the sample solution items = [1, 2, 3, 4, 5] squared = list (map(lambda x: x**2, items)) print(squared) #13 Write a Python program to count the even, odd numbers in #a given ar...
true
968b2b4e002d1fae4de0d40a9efd38e34e32c58d
jmontara/become
/Recursion/recursion_start.py
693
4.40625
4
# recursive implementations of power and functions def power(num,pwr): """ gives number to the power inputs: num - int, number pwr - int, power outputs: ret - int, number to the power """ if pwr == 0: return 1 else: return num * power(num, pwr - 1) def factorial(num): if num == 0: return 1 e...
true
f7e90d0db53004d861dba2c1e87bda1a52f80930
muskanmahajan37/learn-em-all
/learnemall/datasets/iris.py
2,069
4.1875
4
## Core Functionality to Load in Datasets import numpy as np import pathlib from sklearn.model_selection import train_test_split def load_data(split=False,ratio=None,path='./data/iris.csv'): ## generalized function to load data """ Loads in data from ./data/dataset.csv Parameters: =================...
true
66fcb60cbdb27745ab8e04b104c226b1b37a1889
congsonag/udacity-data-structures-algorithms-python
/list-based collections/Queue.py
1,883
4.34375
4
"""Make a Queue class using a list! Hint: You can use any Python list method you'd like! Try to write each one in as few lines as possible. Make sure you pass the test cases too!""" class Element: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(sel...
true
9252f3ade60fe56615ae4d47bc1325b009fc0782
Tsedao/Structure_and_Interpretation_of_Computer_Programs
/lab/lab04/lab04.py
2,583
4.1875
4
# Q2 def if_this_not_that(i_list, this): """Define a function which takes a list of integers `i_list` and an integer `this`. For each element in `i_list`, print the element if it is larger than `this`; otherwise, print the word "that". >>> original_list = [1, 2, 3, 4, 5] >>> if_this_not_that(origin...
false
3d659dc37006707dad08aedbde8b2f9df9437e09
bnmcintyre/biosystems-analytics-2020
/extra/01_dna/dna.py
1,670
4.15625
4
#!/usr/bin/env python3 """ Author : bnmcintyre Date : 2020-02-04 Purpose: count the frequency of the nucleotides in a given piece of DNA """ import argparse import os import sys # -------------------------------------------------- def get_args(): """Get command-line arguments""" parser = argparse.Argument...
true
928d0729cfdcc0880182ed0a9453f190ff9f9f4a
jessiditocco/calculator2-01-18
/calculator.py
922
4.28125
4
"""A prefix-notation calculator. Using the arithmetic.py file from Calculator Part 1, create the calculator program yourself in this file. """ from arithmetic import * while True: token = raw_input("> ") token = token.split() operator = token[0] if operator == "q": break elif operator =...
true
5143231de6f9ce460c87056834ce6915d7960579
amithmarilingegowda/projects
/python/python_programs/reverse_list.py
712
4.71875
5
import sys # Option #1 # --------- # Using in-built function "reversed()": This would neither reverse a list in-place(modify the original list), # nor we create any copy of the list. Instead, we get a reverse iterator which we use to cycle through the list. # # Option #2 # --------- # Using in-build function "reverse(...
true
6786b1a9403fd5127628622b32ad046207ec7fc9
charliechocho/py-crash-course
/voting.py
289
4.15625
4
age = 101 if age >= 18 and age <= 100: print("you're old enough to vote!!") elif age > 100: print("You're more than 100 years?!? Have you checked the obituaries?? ") print("If you're not in there, go ahead and vote") else: print("Wait til' you're 18 and then you can vote")
true
b2dd7887583c3d0af946550fb0603ac9ce35e158
amitchoudhary13/Python_Practice_program
/string_operations.py
661
4.4375
4
#!usr/bin/python ''' Basic String operations Write a program to read string and print each character separately.     a) Slice the string using slice operator [:] slice the portion the strings to create a sub strings.     b) Repeat the string 100 times using repeat operator *     c) Read string 2 and concatenate with o...
true
5713a0f09fbf8439b257469c668d67170992e716
amitchoudhary13/Python_Practice_program
/odd_or_even.py
263
4.125
4
#!/usr/bin/python '''Write a program to find given number is odd or Even''' #variable declaration a = 10 b = a % 2 if b == 0 : #if Implementation for even print "Given number is", a, "even" else: #if Implementation for odd print "Given number is", a, "odd"
true
c41cb4db3290f33593118e98dbc208ec7a9bd332
amitchoudhary13/Python_Practice_program
/fibonacci_series.py
719
4.375
4
#!/usr/bin/pyhton '''20.Write a program to generate Fibonacci series of numbers. Starting numbers are 0 and 1, new number in the series is generated by adding previous two numbers in the series. Example : 0, 1, 1, 2, 3, 5, 8,13,21,..... a) Number of elements printed in the series should be N numbers, Where N is any +ve...
true
e6cfee1b13d05dd52fdf6ee8312688bfcadf8098
SaiPhani-Erlu/pyScript
/3_DeepDive/CaseStudy1/01_CompactRobot.py
1,038
4.34375
4
import math from functools import reduce ''' Q1. A Robot moves in a Plane starting from the origin point (0,0). The robot can move toward UP, DOWN, LEFT, RIGHT. The trace of Robot movement is as given following: UP 5, DOWN 3, LEFT 3, RIGHT 2 The numbers after directions are steps. Write a program to compute the distan...
true
beee7adf77fca1ddfc925ffdc7b8fbc93f86d248
SaiPhani-Erlu/pyScript
/2_Seq_FileOps/seqInput.py
1,758
4.1875
4
''' A website requires a user to input username and password to register. Write a program to check the validity of password given by user. Following are the criteria for checking password: 1. At least 1 letter between [a-z] 2. At least 1 number between [0-9] 3. At least 1 letter between [A-Z] 4. At least 1 character fr...
true
48d1d8d121393dd646ca1cf801afb34bcaab8fac
radam9/CPB-Selfmade-Code
/02 Keywords and Statements/L4E7_ListComprehensions.py
1,294
4.46875
4
#List comprehensions #first lets check the beginners way mys = 'hello' myl =list() #we can use a shorter way as follows "myl = []" for l in mys: myl.append(l) print(myl) #now lets apply list comprehensions mys = 'Hello' myl = [l for l in mys] print(myl) #example myl = [x for x in 'word'] print(myl) #example 2 myl =...
false
ab9f452e8e1c711da3e27f8fdc101d274a860061
radam9/CPB-Selfmade-Code
/07_Decorators.py
1,990
4.3125
4
#Decorators #Mainly used for web developement (Flask and Django) def func(): return 1 def hello(): return 'Hello!' hello greet = hello greet print(greet()) # def hello(name='Adam'): print('The hello() function has been executed!') def greet(): return '\t This is the greet() function inside hello...
true
0f82666397eba43041ecc911652e22d28d6876e8
sravyapara/python
/icp3/vowels.py
408
4.375
4
str=input("enter the string") def vowel_count(str): # Intializing count to 0 count = 0 # Creating a set of vowels vowel = {"a","e","i","o","u"} # to find the number of vowels for alphabet in str: # If alphabet is present then count is incremented if alphabet in vowel: ...
true
dc661840ce903a643db2dd851329fb1bbce006ac
MrRa1n/Python-Learning
/Tuple.py
388
4.53125
5
# Tuples are used to store a group of data # Empty tuple tuple = () # One item tuple = (3,) # Multiple items personInfo = ("Diana", 32, "New York") # Data access print(personInfo[0]) print(personInfo[1]) # Assign multiple variables at once name,age,country,career = ("Diana", 32, "United States", "CompSci") print(c...
true
043f54f44d0fa3f3c3448940cf7ff7decd6fc148
wpy-111/python
/month01/day03/exercise03.py
490
4.15625
4
# 练习 录入数字/运算符/数字 # 如果运算是+ - * / 打印结果, number_one = float(input("请输入第一个数字:")) operate = input("请输入运算符:") number_two = float(input("请输入第二个数字:")) if operate == "+": print(number_one + number_two) elif operate == "-": print(number_one - number_two) elif operate == "*": print(number_one * number_two) elif opera...
false
1af3ff323ec577e65b93ad38a88979a105ef21e4
wpy-111/python
/DataStructure/day03/03_queue.py
771
4.3125
4
""" python实现队列模型 - 顺序存储 思路: 1.先进先出 2.设计:列表的头部最为队头pop(0),列表尾部最为队尾,进行入队操作append """ class Queue: def __init__(self): self.queue = [] def is_empty(self): return self.queue == [] def enqueue(self,value): return self.queue.append(value) def dequeue(self): ...
false
6e806db5f739d0f27684809d85b179261b6968d7
wpy-111/python
/month01/day07/exercise07.py
350
4.125
4
""" 一个筛子(1-6) 打印出三个筛子所有数字 """ list_result=[] for i in range(1,7): for a in range(1,7): for c in range(1,7): list_result.append((a, i, c)) print(list_result) print(len(list_result)) list_result=[(a, i, c) for i in range(1, 7) for a in range(1, 7) for c in range(1, 7)] print(list_result)
false
2ac6e2ccbbb8b1c16136932f1b89cca9bb62da3c
wpy-111/python
/month01/day08/homework.py
607
4.3125
4
""" 字符串的函数 """ name="清华 的 校训:持之 以 恒 . " print(name.center(5,"-")) # print(name.replace("清华","我的",1)) print(name.find("校训")) print(name.isspace())#空白 print(name.count(" ")) name01=name.lstrip()#删除开头空白 print(name01) name02=name.rstrip()#删除末尾空白 print(name02) name03=name.strip()#删除开头和末尾空白 print(name03) letter="我的sasfs...
false
c5495793730e501b12c5f91dd60edd0a8a3adc41
wpy-111/python
/month01/day16/exercise03.py
543
4.15625
4
#练习1.使用迭代思想,获取元祖中所有元素(“a","b","C") #练习2.使用迭代思想,获取字典中所有记录(“a":1,"b":2,"C":3) tuple=("a","b","C") iteration=tuple.__iter__() # while True: while True: try: item=iteration.__next__() print(item) except StopIteration: break dict={"a":1,"b":2,"c":3} iterations=dict.__iter__() while True: ...
false
0e51d3c7ebe267947f9142ad7c38f1581e87a7f8
GuilhermRodovalho/Algoritmos-e-estruturas-de-dados
/programaçao-dinamica/03-ola_universo.py
1,564
4.1875
4
""" Estamos no ano 3210 e há muitos e muitos anos atrás descobrimos que não estamos sozinhos no Universo. Porém, em 2021 isso ainda era questionado. Muitas civilizações em planetas da nossa galáxia, a Via-Láctea, já entraram em contato com a Terra. Alguns até mantêm diálogos em busca de nossos avançados algoritmos ...
false
88c45d54bcf39138644d20b592b17ed02083c45e
courtneyng/GWC-18-PY
/gwc_py/programs/lists/liststuff.py
739
4.28125
4
friends = ["Camille", "Sarah", "Jade", "Aadiba", "Aishe"] onepiece = ["Luffy", "Zoro", "Nami", "Usopp", "Sanji", "Chopper", "Robin", "Frankie", "Brook"] friend = "RajabButt" two = [friends, onepiece] print(*friends) #list w/o brackets and commas print(friends) #list with brackets and commas but also quotes fo...
true
0ad9fd99507f9d1e1a14e43ce9b4f11b0850a80e
3deep0019/python
/Input And Output Statements/Command_Line_Arguments.py
947
4.1875
4
# ------> argv is not Array it is a List. It is available sys Module. # -----> The Argument which are passing at the time of execution are called Command Line # Arguments. # Note: ---------->argv[0] represents Name of Program. But not first Command Line Argument. # argv[1] represent First...
true
a6e01da933653dca7493296ad2c255bcb6ab2609
3deep0019/python
/basic01/ListDataType.py
414
4.15625
4
# if we want to represent a group of values as a single entity where insertion order required # to preserve and duplicates are allowed are allowwed then we should go for list data type . list=[10,20,30,40] print(list[0]) print(list[-1]) print(list[1:3]) list[0]=100 for i in list:print(i) # --- **** lis...
true
97e513a0f616d804bf623dba4456b663da277b8a
3deep0019/python
/Input And Output Statements/Input.py
2,548
4.40625
4
# 2)input(): # input() function can be used to read data directly in our required format.We are not # required to perform type casting. # x = input("Enter Value) # type(x) # 10  int # "durga" str # 10.5  float # True  bool # ***Note: # -------> But in Python 3 we have only input() method and raw...
true
bfb02ba9318aeeceb7f7888063ba57036e965e7f
3deep0019/python
/basic01/RelationalOperator.py
700
4.1875
4
# > , <= , < , <= a=10 b=20 print("a > b is ",a>b) print("a >= b is ",a>=b) print("a < b is ",a<b) print("a <= b is ",a<=b) a > b is False a >= b is False a < b is True a <= b is True # *** We can apply relational operators for str types also. # a="durga" b="durga" print("a >...
true
9ffbab16675a9972956979ae653b3c2d283c860e
3deep0019/python
/basic01/AssignmentOperators.py
616
4.28125
4
# Assignment operators # -----------> We can use assignment operator to assign value to the variable. # Eg: # x = 10 # ****** We can combine asignment operator with some other operator to form compound # assignment operator. # Eg: # x += 10  ...
true
68025058491424f25b1b8ff2054283b6c50c8729
3deep0019/python
/STRING DATA TYPE/Replacing a String with another String.py
1,227
4.5
4
# Replacing a String with another String # --------------------->>>>>>>>>> s.replace(oldstring, newstring) # inside s, every occurrence of old String will be replaced with new String. # Eg 1: s = "Learning Python is very difficult" s1 = s.replace("difficult","easy")...
true
519e9ba48d09ed3d68f2cf1e552d4d2fbe689a7c
andremenezees/CursoPython
/Aulas/4_Orientada_a_objetos/7_Heranca_Multipla.py
1,990
4.625
5
""" Heraca Multipla Como nome ja diz é a habilidade de uma classe herdar atributos e metodos de outras multiplas classes. """ # Exemplo 1 - Multiderivacao direta class Base1: pass class Base2: pass class MultiDerivada(Base1, Base2): pass # Exemplo 2 - Multiderivacao indireta class Base1: pas...
false
6e506dc51b848e1f400f80aeaff57635c6eccfb4
andremenezees/CursoPython
/Aulas/2_Meio/Lambdas.py
1,603
4.875
5
""" Utilizando lambdas Conhecidas por expressões Lambdas, ou simplesmente Lambdas, são funções sem nome, ou seja, funçÕes anonimas. """ def funcao(x): return 3 * x + 1 print(funcao(4)) #Expressão lambda lambda x: 3 * x + 1 #E como utilizar a empressão lambda? calc = lambda x: 3 * x + 1 print(calc(4)) #Pod...
false
f221ff27ef1580ef0bcda2c69a06931b88a55dd4
oldmuster/Data_Structures_Practice
/sort/python/bubble_sort.py
2,254
4.125
4
#!/usr/bin/env python #coding:utf-8 """ 冒泡排序: 1. 比较相邻的元素。交换逆序对 2. 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。 最后一趟可以确定最后一个为最大元素 3. 对[0, max-i] 的元素集重复上述操作 记忆口诀: 交换逆序对(if n[j]>n[j+1]:n[j],n[j+1]=n[j+1],n[j]) 划分左未排序区间和右已排序区间(range(0,n-1)->range(0,n-i-1)), 第一次遍历需要空出最后一个元素,否则nums[j+1]就会溢出。 优化1:某一趟遍历如果没有数据交换,则说明已经排好序了,直接break退出排...
false
6d8097e4c80ab7ebebaca9900840cef7bf50f55e
oldmuster/Data_Structures_Practice
/stack/__init__.py
2,052
4.1875
4
#!/usr/bin/env python #coding:utf-8 """ Stack based upon linked list 基于链表实现的栈 Author: Wenru """ class Node(object): def __init__(self, data, next=None): self._data = data self._next = next class LinkedStack(object): """用链表实现的链式栈 """ def __init__(self): ...
false
d7bf9dfa2783e4797471551de7852fc9fc5f438b
alvas-education-foundation/CSE-K-Thrishul-4AL17CS038
/Machine Learing Class/02-Sept/P3_02-Sept.py
219
4.21875
4
''' 3. Write a Python program to test whether a passed letter is a vowel or not ''' def is_vowel(ch): All_vowels = 'aeiou' return ch in All_vowels char = input("Enter a Character : ") print(is_vowel(char))
false
aef7af59132217b8002b44d4083a951f89a37b4d
1F659162/Palindrome
/Palindrome.py
707
4.125
4
# 6206021620159 # Kaittrakul Jaroenpong IT 1RA # Python Chapter 5 Example 3 print(">> Program Palindrome Number <<") number = input("Enter integer number : ") count = -1 for i in range(len(number)//2): if number[i] == number[count] : print(f"Digit {number[i]} equal to Digit {number[count]}") ...
false
2a8d3f1ee39455d37885011c0e0aad5aa5173ecd
gum5000/The-Soap-Mystery
/Main.py
1,821
4.25
4
# Python program for implementation of MergeSort def mergeSort(arr): if len(arr) >1: mid = len(arr)//2 #Finding the mid of the array L = arr[:mid] # Dividing the array elements R = arr[mid:] # into 2 halves mergeSort(L) # Sorting the first half mergeSort(R) # Sorti...
true
4ea5fe095bb8b14c78421fd592e1198e92e2338f
anthonywww/CSIS-9
/prime_numbers.py
632
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Program Name: prime_numbers.py # Anthony Waldsmith # 07/12/2016 # Python Version 3.4 # Description: Print out prime numbers between 3 to 100. # Optional import for versions of python <= 2 from __future__ import print_function # Loop between 3(start) to 100(end) for i i...
true
3cc6d21d24190988ef9c970cbb4e808607cd8e1f
anthonywww/CSIS-9
/is_triangle.py
1,249
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Program Name: is_triangle.py # Anthony Waldsmith # 07/14/2016 # Python Version 3.4 # Description: A function that checks if a triangle can be formed with the following parameters (a, b, c) import random # isTriangle function def isTriangle(a,b,c): # Check if the length...
true
9b9305de824ee3d38dcc69da90a2f26ea150979e
anthonywww/CSIS-9
/TEMPLATE.py
636
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Program Name: <ENTER PROGRAM NAME> # <ENTER NAME> # <ENTER DATE> # Python Version 3.4 # Description: <ENTER DESCRIPTION> # Optional import for versions of python <= 2 from __future__ import print_function # Do this until valid input is given while True: try: # Tex...
true
debec9fcf3c46ab975dd0d88c5bc822cc64cab11
anthonywww/CSIS-9
/mult_add.py
472
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Program Name: mult_add.py # Anthony Waldsmith # 07/14/2016 # Python Version 3.4 # Description: A function that takes in 3 parameters (a,b,c) and does the following operation a*b+c # multAdd function def multAdd(a,b,c): return ((a*b)+c) # Main function def main(): a...
false
1006690d7e272732f7c61093227966af0096e9cc
aymenbelhadjkacem/holbertonschool-higher_level_programming
/0x06-python-classes/4-square.py
974
4.21875
4
#!/usr/bin/python3 """Module square empty""" class Square: """Square class def""" def __init__(self, size=0): """if size not integer test raise expectation""" """ attribute size (int): Size of square""" self.__size = size """are function defintion""" def area(self): ""...
true
c51065c4ecbe92b79f967e72a8953498bede8c7c
albertsuwandhi/Python-OOP
/abstract_class.py
624
4.1875
4
# ABC = abstract base class from abc import ABC, abstractmethod #inheritance form ABC class Button(ABC): @abstractmethod def onClick(self): pass class pushButton(Button): def onClick(self): print("Push Button Clicked") class radioButton(Button): # pass # onClick must be implement...
true
b1398fa7502fa47412ba7986d3727b1c944ffc46
J-sudo-2121/codecademy_projects
/players.py
1,291
4.71875
5
# Working with a specific group of items in a list is called a slice (slicing) # in Python. players = ['charles', 'martina', 'michael', 'florence', 'eli'] print(players[0:3]) # You can generate any subset of a list. print(players[1:4]) # If you omit the first index in a slice Python automatically starts your slice # ...
true
cc0742449bd9a5353248bb4d2d33a597c030d505
J-sudo-2121/codecademy_projects
/toppings.py
2,570
4.5
4
# When you want to determine whether two values are not equal use (!=). ! # represents not. requested_topping = 'mushrooms' if requested_topping != 'anchovies': print("Hold the anchovies!") # Most of the conditional expressions you write will test for equality. / # Sometimes you'll find it more efficient to test for ...
true
1afdd366fccc022e4d4dd66ad7a881c79db8eb3b
J-sudo-2121/codecademy_projects
/cars2.py
1,926
4.34375
4
# Using an if statement. cars = ['audi', 'bmw', 'subaru', 'toyota'] for car in cars: if car == 'bmw': print(car.upper()) else: print(car.title()) # Python uses the values of True and False to decide whether the code in an if / # statement should be executed. # Conditional Tests. car = 'subaru' print("Is car == ...
true
102d1b647849efe444787a335e3aeb610e92447e
Yao-Ch/OctPyFun2ndDayPM
/Exercise4.py
773
4.28125
4
french=("Mer","Ville","Voiture","Ciel","Couleur") english=("Sea","Town","Car","Sky","Color") fr_en=dict(zip(french, english)) # or more directly: # fr_en={"Mer":"Sea","Ville":"Town","Voiture":"Car", # "Ciel":"Sky", # "Couleur":"Color"} while True: answerOrg=input("Enter a french wo...
false
a647288d4d031ffc705c807166d7c2332e1d9638
vandyliu/small-python-stuff
/madLibs.py
1,955
4.1875
4
#! python3 # Takes a mad libs text file and finds where an ADJECTIVE, NOUN, ADVERB, VERB should be replaced # and asks users for a suggestion then saves the suggestion to a text file in the same directory # Idea from ATBS # To run type python.exe madLibs.py <path of madlibs text> # Eg. python.exe C:\Users\Vandy\Pychar...
true
5150d24094b79bea9df2d5a4faccca56210075b7
JhonattanDev/Exercicios-Phyton-05-08
/ex14.py
691
4.46875
4
# Explicando o programa print("=================================================================") print("|Digite o valor do salário para aplicar um aumento de 15% a ele!|") print("=================================================================") # Pedir ao Usuário inserir o valor do salário salarioIncial = in...
false
94c160e31517b75bfb75b43550ddc059762f7099
fengluodb/a-simple-snake-game
/AutoMove.py
1,628
4.125
4
# 简单的自动寻路逻辑 def simple(snake_x, snake_y, food_x, food_y, direction): if direction is None: if snake_x < food_x: direction = "right" if snake_x > food_x: direction = "left" else: if snake_y < food_y: direction = "down" elif snake...
false
fcfd80443b1dc4eba5b25056252a465057362201
gravityrahul/PythonCodes
/AttributeConcepts.py
2,119
4.34375
4
''' Python attribute tutorial based on Sulabh Chaturvedi's online tutorial www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html #method-resolution-order ''' class C(object): ''' This example illustrates Attribute concepts ''' classattribute="a class attribut...
true
0dc3b3104f4470e167227184602631f12951dab3
ImprovementMajor/New
/Task1.py
250
4.1875
4
temp = float(input("Welcome to the temperature converter! Please enter a temperature and its units: ")) if units == F : print(temp_f) else : print(temp_c) temp_f = (9/5) * temp_c + 32 print(temp_f) temp_c = temp_f - 32 * 5/9 print(temp_c)
true
0863297aca2ecae6ce8b6dd76fc268fc4fa1de67
kishanSindhi/python-mini-projects
/minipro8.py
358
4.28125
4
# Author - Kishan Sindhi # date - 30-5-2021 # discription - this function take the year as input from the user # and in return it tells that the entered tear us a leap yaer or not year = int(input("Enter a year you want to check that is a leap year or not:\n")) if year % 4 == 0: print("Year is leap year") ...
true
f2d20dbd5ccb633702e4ef6f07ade72bfe1b5b65
6hack9/python-workshop
/python-stucture/set.py
664
4.28125
4
s5 = {1,2,3,4} s6 = {3,4,5,6} """ Use the | operator or the union method for a union operation: """ print(s5 | s6, '\n') print(s5.union(s6),'\n') """ Now use the & operator or the intersection method for an intersection operation: """ print(s5 & s6, '\n') print(s5.intersection(s6),'\n') """ Use the – operator o...
false
e5947d044940b0d42e446919219b6727211a5e6e
tusharsappal/GeneralInterViewquestions
/GeeksForGeeks Questions/LinkedListPrograms/SimpleOrderedLinkedList.py
1,445
4.15625
4
class Node(object): def __init__(self,initData): self.data = initData self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self,newData): self.data = newData def setNext(self,nextNode): self.next =...
true
f834cbb5c946259bf32c29c033c2603779f63579
tusharsappal/GeneralInterViewquestions
/GeeksForGeeks Questions/ArrayPrograms/BinarySearch.py
1,083
4.15625
4
# A simple class demonstrating Binary Search class BinarySearch(object): def binarySearch(self): print "Enter the Sorted Array \n" string_input = raw_input() input_list = string_input.split() input_list = [int(a) for a in input_list] print "Array to be searched", input_list ...
true
b396c5e7c99690636400614be744a0bb83d21659
tusharsappal/GeneralInterViewquestions
/GeeksForGeeks Questions/ArrayPrograms/LeadersInArray.py
924
4.125
4
# This program checks for the leader in the array #An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. class FindLeaderInArray(object): def findLeaderInArray(self): print "Enter the Array " string_input = raw_input() i...
true
f7b74aa32c21042a530ddac4df0655348dfcf8ce
tusharsappal/GeneralInterViewquestions
/GeeksForGeeks Questions/DynamicProgramming/SumOfAllSubStringRepresentingString.py
1,370
4.125
4
'''This program prints Sum of all substrings of a string representing a number We will be using the Concept of Dynamic Programing We can solve this problem using dynamic programming. We can write summation of all substrings on basis of digit at which they are ending in that case, Sum of all substrings = sumofdigit[0] +...
true
9fb575247b44fd6cb944b68f0d077285dd80797f
AlyonaKlekovkina/JetBrains-Academy-Multilingual-Online-Translator
/translator.py
275
4.125
4
inp = input('Type "en" if you want to translate from French into English, or "fr" if you want to translate from English into French: \n') word = input('Type the word you want to translate: \n') print('You chose "{}" as the language to translate "{}" to.'.format(inp, word))
true
99b5e59a7ea63f7900a144b9540f48c241c9094a
15johare/mockexam.py
/mockexam.py
1,226
4.1875
4
while True: mood=input("choose what mood you are feeling") print("this is a program that shows you what music to listen to depending on your mood") print("all you have to do is type what mood you are and a link to a song will come up") if mood=="happy": print("https://www.youtube.com/watch?v=ZbZSe6N_BXs"...
true
90f715e0e18587b6bc42fdf46e99e3fae7124666
wisitlongsida1999/Project-Battleship.py
/battleship.py
1,743
4.1875
4
from random import randint def print_board(board): for row in board: print(row) def random_row(board): return randint(0, len(board) - 1) def random_col(board): return randint(0, len(board[0]) - 1) def play(): board = [] for x in range(0, 5): board.append(["O"] * 5) print_board(b...
false
fd88fd1e55b79c6ef5e64f749c8255d2872dbfe8
Anshikaverma24/if-else-meraki-ques
/if else meraki ques/q7.py
314
4.21875
4
# take a number as input from the user. Convert this input to integer. Check if it is equal to varx. # If the number is equal to varx, print "Equal" else print "Not equal".varx = 300 - 123 varx = 300 - 123 answer=int(input("enter the answer : ")) if answer==varx: print("equal") else: print("not equal")
true
a0f65d7e301ffaa85add12475cd8859afc18b095
Anshikaverma24/if-else-meraki-ques
/if else meraki ques/q16.py
281
4.1875
4
# meraki debugging questions in if else # number = input("please enter a decimal number") # print ("your number divided by 2 is equal to = " + number/2) # ANSWER number = int(input("please enter a decimal number")) print ("your number divided by 2 is equal to = ", + number/2)
true
18a3633fd7a091250cee523189a7943a8de516a3
tbaraza/Bootcamp_7
/Day-3/data_types.py
770
4.1875
4
def data_type(x): """ Takes in an argument x: - For an integer , return x ** 2 - For a float, return x/2 - For a string, returns "Hello " + x - For a boolean, return "boolean" - For a long, return squaroot of x """ if isinstance(x, int): ...
true
9f4d6ae9ee32c1a152c1dca4a0ae343390637983
shenbomo/LintCode
/Implement Queue by Stacks.py
1,024
4.125
4
""" As the title described, you should only use two stacks to implement a queue's actions. The queue should support push(element), pop() and top() where pop is pop the first(a.k.a front) element in the queue. Both pop and top methods should return the value of first element. Example For push(1), pop(), push(2), push...
true
e25987866fe6ef5041487014192e412e58144749
genrobaksel/Home_Work_2
/Lesson3_part1/01_days_in_month.py
938
4.40625
4
# -*- coding: utf-8 -*- # (if/elif/else) # По номеру месяца вывести кол-во дней в нем (без указания названия месяца, в феврале 28 дней) # Результат проверки вывести на консоль # Если номер месяца некорректен - сообщить об этом # Номер месяца получать от пользователя следующим образом user_input = input("Введите, пож...
false
e317fdcd87ccf6f8fb70b3255b99862d615ca219
Alexanra/graphs-
/Guess_my_number_working.py
1,309
4.125
4
print ("Please think of a number between 0 and 100!") minimum = 0 maximum = 100 guess = minimum + (maximum-minimum)//2 print ("Is your secret number " + str(int(guess)) + "?") ans = str (input("Enter 'h' to indicate the guess is too high. "+\ "Enter 'l' to indicate the guess is too low. "+\ ...
true
e17ad79242ce3fba5a259fa68d49436d210f2a41
malarc01/Data-Structures
/binary_search_tree/Data Structures in Python- Singly Linked Lists -- Insertion .py
1,353
4.21875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): curr_node = self.head while curr_node: print(curr_node.data) curr_node = curr_node.next ...
true
4ac0c78234417136cc65611724eb635eeb072b57
ThakurSarveshGit/CrackingTheCodingInterview
/Chapter 1 Arrays and Strings/1_5.py
779
4.21875
4
# -*- coding: cp1252 -*- // What is this? # Problem 1.5 # Write a method to replace all spaces in a string with %20. # I doubt if any interviewer would give this question to be solved in python # Pythonic Way def replace(string): modified_string = string.replace(" ", "%20") print modified_string ...
true
7dc54efd48efa8bd557e3171322479ce3e0bd98a
ThakurSarveshGit/CrackingTheCodingInterview
/Chapter 1 Arrays and Strings/1_2.py
708
4.28125
4
# -*- coding: cp1252 -*- # No clue why this came up :/ # Problem 1.2 # Write code to reverse a C-Style String. #(C-String means that abcd is represented as five characters, including the null character.) def reverse_in_c(string): # Python Style of Reversing a string Reverse_String_Python = string[...
true
0ad19a3410b0ebd0a981474cc79da9305402b3b4
rcisternas/PyhonEjercicios
/Factorial.py
331
4.1875
4
Numero = int(input("Ingrese Numero: ")) def Factorial(Number): Numero_salida = 0 contador = 1 Numero_actual = 1 while (contador<=Number): Numero_salida = contador*Numero_actual contador+=1 Numero_actual = Numero_salida return Numero_salida print("El factorial es: ", Factori...
false
1c6c4044f85036d9b81550ab031283a070c3e205
Damishok/PP2
/TSIS1/9.py
573
4.25
4
#1 fruits = ["apple", "banana", "cherry"] print(fruits[1]) #2 fruits = ["apple", "banana", "cherry"] fruits[0] = "kiwi" #3 fruits = ["apple", "banana", "cherry"] fruits.append("orange") #4 fruits = ["apple", "banana", "cherry"] fruits.insert(1,"lemon") #5 fruits = ["apple", "banana", "cherry"] fru...
false
c02cc82c080c24f7b9441c9fd7b4ea35a1f7c464
Saptarshidas131/Python
/p4e/exercises/ex7_1.py
470
4.40625
4
""" Exercise 1: Write a program to read through a file and print the contents of the file (line by line) all in upper case. Executing the program will look as follows: """ filename = input("Enter filename: ") # try opening file try: fileh = open(filename) except: print("Invalid filename ",filename) exit() ...
true
ac308ee29c9e87118d51cb92273aa4fd0d2616f4
Saptarshidas131/Python
/p4e/exercises/ex3_2.py
663
4.125
4
""" Exercise 2: Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program. The following shows two executions of the program """ # prompt for hours and rate per hour try: hours = float(input("Enter Hours: ")) rate = flo...
true
3c77543a0ab17cadcee5e91695ead226115b1f6e
rohitj205/Python-Basics-Code
/LOOPS.py
2,096
4.34375
4
#Loops "for loop:" #If we want to execute some action for every element present in some sequence # (it may be string or collection)then we should go for for loop. #Eg #To Print Character represented in String s = "Sachin Tendulkar" for x in s: print(x) #For loop exp = [2310,5000,2500,4500,4500] total...
true