blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
101f7b9e37b22819c534e66c6319e363a4cfa99f
Ahmodiyy/Learn-python
/pythonpractice.py
1,142
4.21875
4
# list comprehension number_list = [1, 2, 3, 5, 6, 7, 8, 9, 10] oddNumber_list = [odd for odd in number_list if odd % 2 == 1] print(oddNumber_list) number_list = [1, 2, 3, 5, 6, 7, 8, 9, 10] oddNumber_list = [odd if odd % 2 == 1 else None for odd in number_list] print(oddNumber_list) # generator as use to get Iterato...
true
2c3370cfb32e84cc709f9fbeaa99e961aa0a8ce0
Asresha42/Bootcamp_day25
/day25.py
2,902
4.28125
4
# Write a program to Python find the values which is not divisible 3 but is should be a multiple of 7. Make sure to use only higher order function. def division(m): return True if m % 3!= 0 and m%7==0 else False print(division(23)) print(division(35)) # Write a program in Python to multiple the element of list by...
true
d0f1e4c5434d246faf1d73097a00a8b87af298b4
anjmehta8/learning_python
/Lecture 1.py
1,113
4.375
4
print(4+3+5) #this is a comment """ hello this is a multiline comment """ #values #data types #date type of x is value. #Eg. 4 is integer. The 4 is value, integer is data type """ #integer 4 7 9 15 100 35 0 -3 #float 3.0 4.6 33.9 17.80 43.2 """ print(6/3) print(6//3) print(7/2) print(7//2) #// rounds downward ...
true
278942c8419ff38e9fe29adfb040ab2607afa0f7
geekmj/fml
/python-programming/panda/accessing_elements_pandas_dataframes.py
2,626
4.21875
4
import pandas as pd items2 = [{'bikes': 20, 'pants': 30, 'watches': 35}, {'watches': 10, 'glasses': 50, 'bikes':15,'pants': 5 } ] store_items = pd.DataFrame(items2, index = ['Store 1', 'Store 2']) print(store_items) ## We can access rows, columns, or individual elements of the DataFrame # by usin...
true
900ff84b08de1fb33a0262702f2e79dd11125470
geekmj/fml
/python-programming/panda/accessing_deleting_elements_series.py
2,231
4.75
5
import pandas as pd # Creating a Panda Series that stores a grocerry list groceries = pd.Series(data = [30, 6, 'Yes', 'No'], index = ['eggs', 'apples', 'milk', 'bread']) print(groceries) # We access elements in Groceries using index labels: # We use a single index label print('How many eggs do we need to buy:', groc...
true
dc0168556ef464beab6eb6371d24d7a726a08df0
ads2100/pythonProject
/72.mysql3.py
1,748
4.15625
4
# 71 . Python MySql p2 """ # The ORDER BY statement to sort the result in ascending or descending order. # The ORDER BY keyword sorts the result ascending by default. To sort the result in descending order, use the DESC keyword # Delete: delete records from an existing table by using the "DELETE FROM" statement # ...
true
e3476d68e724f57e66131177f595e38d0ec492fe
ads2100/pythonProject
/15.list.py
658
4.34375
4
# 15. List In python 3 """ # List Methods len() the length of items append() add item to the list insert() add item in specific position remove() remove specified item pop() remove specified index, remove last item if index is not specified clear() remove all items """ print("Lesson 15: List M...
true
61a30c2c64aa88706a32b898c7fca786775c8ae1
ads2100/pythonProject
/59.regularexpression3.py
994
4.4375
4
# 59. Regular Expressions In Python p3 """ # The sub() function replaces the matches with the text of your choice: # You can control the number of replacements by specifying the count parameter. sub('','',string,no) # Match Object: A Match Object is as object containing information about the search and the result....
true
4c36b5214ebd5c63b66233c33a2c3bc59701e770
ads2100/pythonProject
/16.tuple.py
655
4.1875
4
# 16. Tuple in Python """ # A tuple is a collection which is ordered and unchangeable. # In Python tuples are written with round brackets (). # if the tuple has just one item... ("item",) # acces item in tuple with referring [index] # You cannot change its values. Tuples are unchangeable. # You cannot add item...
true
4054eb15aa4e1c1a406a7766e5874288d321232b
tianyunzqs/LeetCodePractise
/leetcode_61_80/69_mySqrt.py
956
4.15625
4
# -*- coding: utf-8 -*- # @Time : 2019/7/3 9:44 # @Author : tianyunzqs # @Description : """ 69. Sqrt(x) Easy Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and...
true
7eed19d8675227c947b74aa3143c0745126f08b8
tianyunzqs/LeetCodePractise
/leetcode_61_80/74_searchMatrix.py
2,010
4.375
4
# -*- coding: utf-8 -*- # @Time : 2019/7/9 10:43 # @Author : tianyunzqs # @Description : """ 74. Search a 2D Matrix Medium Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first in...
false
f87328e58228e7fd3e3d16ffd999638ff38cf8f9
AlanRufuss007/Iceberg
/python day1.py
319
4.125
4
num1 = 10 num2 = 20 sum = num1+num2 print("sum of {0} and {1} is {2}".format(num1,num2,sum)) num1 = input("Enter the number:") num2 = input("/n Enetr the number:") sum = float(num1)+float(num2) print("The sum of {0} and {1} is {2}".format(num1,num2,sum)) a = 10 b = 20 maximum = max(a,b) print(maximum)
true
f7c446009fd894559fb63c4a6b928ad6fc4a61e1
eddy-v/flotsam-and-jetsam
/checkaba.py
1,114
4.21875
4
# eddy@eddyvasile.us # how to check validity of bank routing number (aba) # multiply the first 8 digits with the sequence 3, 7, 1, 3, 7, 1, 3, 7 and add the results # the largest multiple of 10 of the sum calculated above must be equal to the 9th digit (checkDigit) import math def validateABA(aba): checkDigit=int(a...
true
acf9b029ab99b1b978b2e6a41fc2c7feb9cb4f36
gdiman/flask
/sql/sqljoin.py
710
4.15625
4
import sqlite3 with sqlite3.connect("new.db") as connection: c = connection.cursor() try: c.execute("""CREATE TABLE regions (city TEXT, region TEXT)""") except: print("Exists!") cities = [ ('San Franciso', 'Far West'), ('New York City', 'Northeast'), ('Chicago', 'Northcentral'), ('Phoenix', 'Southwest'), ...
false
084af05776f7ae422b74a67e08f68046b7acbd8c
AhirraoShubham/ML-with-Python
/variables.py
1,771
4.65625
5
########################################################################## # Variabels in Python # # * Variables are used to store information to be referenced and # manipulated in computer program. They also provide a way of labeling # data with a decriptive name, so our progams can be understood more # cle...
true
cf6db1cfb7ba5ebff8bf62f9d55eb93071f03e5f
noserider/school_files
/speed2.py
539
4.125
4
#speed program speed = int(input("Enter speed: ")) #if is always the first statement if speed >= 100: print ("You are driving dangerously and will be banned") elif speed >= 90: print ("way too fast: £250 fine + 6 Points") elif speed >= 80: print ("too fast: £125 + 3 Points") elif speed >= 70: prin...
true
8dcdef576c7fb51962fc4c2537742c92f51976f5
noserider/school_files
/sleep.py
580
4.125
4
#int = interger #we have two variable defined hourspernight & hoursperweek hourspernight = input("How many hours per night do you sleep? ") hoursperweek = int(hourspernight) * 7 print ("You sleep",hoursperweek,"hours per week") #round gives a whole number answer or a specific number of decimal points hourspermo...
true
a3b6246985aa7ea86a440da73a96cefdd4eb6dc3
noserider/school_files
/sleep1.py
291
4.1875
4
hourspernight = input("How many hours per night do you sleep? ") hoursperweek = int(hourspernight) * 7 print ("You sleep",hoursperweek,"hours per week") hourspermonth = float(hoursperweek) * 4.35 hourspermonth = round(hourspermonth) print ("You sleep",hourspermonth,"hours per month")
true
99d347780e81ca24c4537231f538cec5cbef1175
Arcus71/GC50-files
/UserInput.py
224
4.15625
4
#Set up two numbers a = int(input("Enter your first number: ")) b = int(input("Enter your second number: ")) #Output manipulations print("Sum: " + str(a + b)) print("Product: " + str(a * b)) print("Quotient: " + str(a / b))
false
1fb48b796d55cd2988bfb74060178f327b6b549e
helectron/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-append_write.py
282
4.28125
4
#!/usr/bin/python3 '''module 2-append_write Function: append_write(filename="", text="") ''' def append_write(filename="", text=""): '''Function to append a text in a file''' with open(filename, mode="a", encoding="utf-8") as myFile: return myFile.write(text)
true
e85febfe1079f48fac3e990073f76067e4902b6f
alexangupe/clasesCiclo1
/P45/Clase8/requerimientoFor.py
1,852
4.1875
4
#Requerimiento: escribir una función que valide que un correo electrónico #ingresado, solamente tenga una arroba, mostrar en pantalla la posición de las #arrobas que estén sobrando #Objetivo -> Número válido de arrobas den un correo (única arroba) # #Algoritmo (Pseudocódigo) # 1) Ingresa el correo electrónico # 2) I...
false
89f6aaf3951880cbacbf717942940359860c5cc7
bdsh-14/Leetcode
/max_sum_subarray.py
615
4.21875
4
''' Given an array of positive numbers and a positive number ‘k,’ find the maximum sum of any contiguous subarray of size ‘k’ Input: [2, 1, 5, 1, 3, 2], k=3 Output: 9 Explanation: Subarray with maximum sum is [5, 1, 3] educative.io ''' def max_sum(k, nums): windowStart = 0 windowSum = 0 max_sum = 0 ...
true
24cbb5b9b020dfa0c9547a74b4ec2f77a26a027d
bdsh-14/Leetcode
/Queue_Intro.gyp
1,170
4.15625
4
#Linear queue class Queue: def __init__(self): self.queueList = [] def is_empty(self): return len(self.queueList) == 0 def front(self): if self.is_empty(): return None return self.queueList[0] def back(self): if self.is_empty(): return ...
false
4d31e99dd4c78ab8f25bd0de0662b39a1fe7e739
vazquezs123/EULER
/euler19.py
1,613
4.15625
4
#!/usr/bin/env python class Month(object): def __init__(self, month, days): """Return a month object with current month, and total days in month """ self.month = month jan = Month('January', 31) feb = Month('February', 28) mar = Month('March', 31) apr = Month('April', 30) may = Month('May', 31) ...
false
a09123591f18b44d4c10b1f134a7c74c7600d15d
M1sterDonut/Exercises_Python-Crash-Course_Eric-Matthes
/stages_of_life.py
375
4.28125
4
age = 42 if age < 2: print (str(age) + " years? You're a baby!") elif age <= 3: print (str(age) + " years? You're a toddler!") elif age <= 12: print (str(age) + " years? You're a kid!") elif age <= 19: print (str(age) + " years? You're a teenager!") elif age <=64: print (str(age) + " years? You're an adult!"...
false
0fa2259f7b692512ccfd9fc074ffd8640762853a
racer97/ds-class-intro
/python_basics/class02/exercise_6.py
2,246
4.25
4
''' Edit this file to complete Exercise 6 ''' def calculation(a, b): ''' Write a function calculation() such that it can accept two variables and calculate the addition and subtraction of it. It must return both addition and subtraction in a single return call Expected output: res = calculation(40, 10) print...
true
30132cd72458b94cd244412d9dcdc108a5674c6f
yatikaarora/turtle_coding
/drawing.py
282
4.28125
4
#to draw an octagon and a nested loop within. import turtle turtle= turtle.Turtle() sides = 8 for steps in range(sides): turtle.forward(100) turtle.right(360/sides) for moresteps in range(sides): turtle.forward(50) turtle.right(360/sides)
true
f0962e44eee61bfcb7524c68c346c7fb620269ec
EllipticBike38/PyAccademyMazzini21
/es_ffi_01.py
1,128
4.34375
4
# Write a function insert_dash(num) / insertDash(num) / InsertDash(int num) that will insert dashes ('-') between each two odd numbers # in num. For example: if num is 454793 the output should be 4547-9-3. Don't count zero as an odd number. # Note that the number will always be non-negative (>= 0). def insertDash(...
true
ba6e0574e900be6eed7368ef339d1c1407ea1450
noahmarble/Ch.05_Looping
/5.0_Take_Home_Test.py
2,949
4.28125
4
''' HONOR CODE: I solemnly promise that while taking this test I will only use PyCharm or the Internet, but I will definitely not ask another person except the instructor. Signed: ______________________ 1. Make the following program work. ''' print("This program takes three numbers and returns the sum.") total = 0 ...
true
c83665d8eb9bcff974737e4705bb285b8b3384cf
FFFgrid/some-programs
/单向链表/队列的实现.py
1,528
4.125
4
class _node: __slots__ = '_element','_next'#用__slots__可以提升内存应用效率 def __init__(self,element,next): self._element = element #该node处的值 self._next = next #下一个node的引用 class LinkedQueue: """First In First Out""" def __init__(self): """create an empty queue""" self._hea...
true
3081b981b3c1cc909ea8a84005bb3a47150af8db
Kelsi-Wolter/practice_and_play
/interview_cake/superbalanced.py
2,487
4.1875
4
# write a function to see if a tree is superbalanced(if the depths of any 2 leaf nodes # is <= 1) class BinaryTreeNode(object): '''sample tree class from interview cake''' def __init__(self, value): self.value = value self.left = None self.right = None def insert_left(self, value...
true
d7955a29d3177efa8b6f558a9a26bd3a7c5f2c61
mulualem04/ISD-practical-4
/ISD practical4Q8.py
282
4.15625
4
# ask the user to input their name and # asign it with variable name name=input("your name is: ") # ask the user to input their age and # asign it with variable age age=int(input("your age is: ")) age+=1 # age= age + 1 print("Hello",name,"next year you will be",age,"years old")
true
9c3a98dc0117de376277591b5ac77807d2b2cf86
vmgabriel/async-python
/src/async_func.py
1,031
4.125
4
"""Async function""" # Libraries from time import sleep async def hello_world(): """Print hello world""" sleep(3) return 'Hello World' class ACalculator: """Class Async Calculator""" async def sum(self, a, b): """function sum a + b""" sleep(2) return a + b async def...
false
25405511319bff04521132f09d027eb1bedc6e7a
MahidharMannuru5/DSA-with-python
/dictionaryfunctions.py
1,826
4.5625
5
1. str(dic) :- This method is used to return the string, denoting all the dictionary keys with their values. 2. items() :- This method is used to return the list with all dictionary keys with values. # Python code to demonstrate working of # str() and items() # Initializing dictionary dic = { 'Name' : 'Nandini', 'Ag...
true
0bfff01de4d4b739f08c6d5499734d9039df55fc
octavian-stoch/Practice-Repository
/Daily Problems/July 21 Google Question [Easy] [Matrix].py
1,618
4.15625
4
#Author: Octavian Stoch #Date: July 21, 2019 #You are given an M by N matrix consisting of booleans that #represents a board. Each True boolean represents a wall. Each False boolean #represents a tile you can walk on. #Given this matrix, a start coordinate, and an end coordinate, #return the minimum number...
true
8ed67ae3d95f7ab983bd9b4d2374ac60bf1d44cb
tonycao/CodeSnippets
/python/1064python/test.py
1,882
4.125
4
import string swapstr = "Hello World!" result = "" for c in swapstr: if c.islower(): result += c.upper() elif c.isupper(): result += c.lower() else: result += c print(result) string1 = input("Enter a string: ") string2 = input("Enter a string: ") string1_changed ...
true
d7f42953edff49b748c99be05a79759fa6b994fc
zk18051/ORS-PA-18-Homework02
/task2.py
361
4.125
4
print('Convert Kilometers To Miles') def main(): user_value = input('Enter kilometers:') try: float(user_value) print(float(user_value),'km') except: print(user_value, 'is not a number. Try again.') return main() user_miles = float(user_value) * 0.62137 print(user_val...
true
7a15ba5ec8fbfc22d569193c326f5b50aef40f63
manali1312/pythonsnippets
/HR_Func_leapyr.py
336
4.1875
4
def leapYear(): year = int(input("Enter an year:")) if year%4==0 or year%400==0: if year%100==0 and year%400!=0: print("Not a leap year") else: print("It is a leap year") else: print("This is not a leap year") if __name__ == '__main__': leap...
false
b49a8155088c794799e763a3d43d12bd5fba57d6
alokjani/project-euler
/e4.py
845
4.3125
4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. # # Find the largest palindrome made from the product of two 3-digit numbers. def reverse(num): return int(str(num)[::-1]) def isPalindrome(num): if num == reverse(num): ...
true
b0b332d4796c8e4ba777d2c725bd2321f5123b06
Neha-Nayak/Python_basics
/Basics/iteration_sum.py
208
4.15625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 9 23:11:45 2021 @author: Neha Nayak """ import fun_sum_of_natural_numbers num=int(input("enter the number=")) print(fun_sum_of_natural_numbers.iteration_sum(num))
false
ee3f43d9120efc1037d5de4aefe93bcd4ea9fcad
DomfeLacre/zyBooksPython_CS200
/module3/AutoServiceInvoice/AutoServiceInvoice1_with_dict.py
2,232
4.25
4
# Output a menu of automotive services and the corresponding cost of each service. print('Davy\'s auto shop services') # Creat dict() to store services : prices servicePrices = { 'Oil change' : 35, 'Tire rotation' : 19, 'Car wash' : 7, 'Car wax' : 12 } print('Oil change -- $35') print('Tire rotation -...
true
0a17bfb11cdda597d527c25d658ee78bf727ad90
DomfeLacre/zyBooksPython_CS200
/module7/MasterPractice_List_Dicts.py
670
4.125
4
##### LISTS ##### # Accessing an Index of a List based on user input of a number: Enter 1 -5 ageList = [117, 115, 99, 88, 122] # Ways to to get INDEX value of a LIST: print(ageList.index(99)) # --> 2 # Use ENUMERATE to get INDEX and VALUE of LIST: for index, value in enumerate(ageList): print(index) print('...
true
a530473ca06eaf44b8cf4d400510366ddc31be78
JoraKaryan/Repository_600
/Home-01/ex-7.py
447
4.1875
4
#ex-7 bar = "What! is! this book about !this book! is about python coding" def foo(bar:str): for i in range(len(bar)): if 0 <= ord(bar[i]) <= 31 or 33<= ord(bar[i])<=64 or 91 <= ord(bar[i]) <= 96 or 123 <= ord(bar[i]) <= 127: bar= bar.replace(bar[i], "") return bar bar =...
false
3b3c1110fd920f34e35dbc55beb38d9b3ecb16cc
calvinjlzhai/Mini_quiz
/Mini_quiz.py
2,737
4.28125
4
#Setting score count score = 0 #Introducation for user taking the quiz print("Welcome to the quiz! Canadian Edition!\n") #First question with selected answers provided answer1 = input("Q1. What is the capital of Canada?" "\na. Toronto\nb. Ottawa\nc. Montreal\nd.Vancouver\nAnswer: ") # Account for...
true
256990003e5d17856435c73e2faac0e495a2001f
DavidQiuUCSD/CSE-107
/Discussions/Week1/OTP.py
2,104
4.375
4
import random #importing functions from Lib/random """ Author: David Qiu The purpose of this program is to implement Shannon's One-Time Pad (OTP) and to illustrate the correctness of the encryption scheme. OTP is an example of a private-key encryption as the encryption key (K_e) is equal to the decrypti...
true
15f91012d9614d46fe03d9b4ff7b83dd53ad31b5
vihahuynh/CompletePythonDeveloper2021
/break-the-ice-with-python/question81.py
321
4.21875
4
""" By using list comprehension, please write a program to print the list after removing numbers which are divisible by 5 and 7 in [12,24,35,70,88,120,155]. """ my_lst = [12,24,35,70,88,120,155] # using filter print(list(filter(lambda i: i % 35, my_lst))) # using comprehensive print([i for i in my_lst if i % 35])...
true
9cc284d8bb87873882c68440c1ee19f0d4bcf094
vihahuynh/CompletePythonDeveloper2021
/break-the-ice-with-python/question4.py
336
4.1875
4
""" Input: Write a program which accepts a sequence of comma-separated numbers from console Output: generate a list and a tuple which contains every number.Suppose the following input is supplied to the program """ seq = input('Please in out a sequence of comma-separated numbers\n') print(seq.split(",")) print(tuple(s...
true
3503e1859b0f61b18254c8eb58e5501773c4a84f
vihahuynh/CompletePythonDeveloper2021
/break-the-ice-with-python/question39.py
241
4.1875
4
""" Write a program to generate and print another tuple whose values are even numbers in the given tuple (1,2,3,4,5,6,7,8,9,10). """ my_tup = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) even_tup = tuple(i for i in my_tup if i % 2 == 0) print(even_tup)
false
154f1639865eb98d55ea566ccb0894b949ad14d3
vihahuynh/CompletePythonDeveloper2021
/break-the-ice-with-python/question28.py
291
4.15625
4
""" Define a function that can receive two integer numbers in string form and compute their sum and then print it in console. """ def sum_2_num(): num1 = input('Input the first number: \n') num2 = input('Input the second number: \n') print(int(num1) + int(num2)) sum_2_num()
true
0800b959b8ff2a1687b1c883135a06d5cec4776c
Pritheeev/Practice-ML
/matrix.py
1,665
4.1875
4
#getting dimension of matrix print "enter n for nxn matrix" n = input() matrix1 = [] matrix2 = [] #taking elements of first matrix print "Enter elements of first matrix" for i in range(0,n): #taking elements of first column print "Enter elements of ",i,"column, seperated by space" #raw_input().split() will...
true
a586bcfe643f3d205136714172bf386a7b8c0e1f
wmaxlloyd/CodingQuestions
/Strings/validAnagram.py
1,380
4.125
4
# Given two strings s and t, write a function to determine if t is an anagram of s. # For example, # s = "anagram", t = "nagaram", return true. # s = "rat", t = "car", return false. # Note: # You may assume the string contains only lowercase alphabets. # Follow up: # What if the inputs contain unicode characters? Ho...
true
54f9eee09ecc211fc0cc378746ceb92c6ca76c8b
wdlsvnit/SMP-2017-Python
/smp2017-Python-maulik/extra/lesson8/madLibs.py
909
4.40625
4
#! python3 #To read from text files and let user add their own text anywhere the word- #ADJECTIVE, NOUN, ADVERB or VERB import re,sys try: fileAddress=input("Enter path of file :") file = open(fileAddress) except FileNotFoundError: print("Please enter an existing path.") sys.exit(1) fileContent = file...
true
fe59db7b1a08053585d40019fa344a8afe2564aa
j-a-c-k-goes/replace_character
/replace_this_character.py
2,085
4.21875
4
""" For a list containing strings, check which characters exist, then replace that character with a random character. """ # ................................................................ Imports from random import * # ................................................................ Main Function def make_words(words=...
false
b18cb0ad7ea82d7658bfb957eec60bb047c55971
darkknight161/crash_course_projects
/pizza_toppings_while.py
513
4.21875
4
prompt = "Welcome to Zingo Pizza! Let's start with Toppings!" prompt += "\nType quit at any time when you're done with your pizza masterpiece!" prompt += "\nWhat's your name? " name = input(prompt) print(f'Hello {name}!') toppings = [] topping = "" while topping != 'quit': topping = input('Name a toppi...
true
640c1b68233d7fe7ee1cdc0a44b30dd0afce9c1b
umangag07/Python_Array
/array manipulation/changing shape.py
1,019
4.625
5
""" Changing shapes 1)reshape() -:gives a new shape without changing its data. 2)flat() -:return the element given in the flat index 3)flatten() -:return the copied array in 1-d. 4)ravel() -:returns a contiguous flatten array. """ import numpy as np #1 array_variable.reshape(newshape) a=np.arange(...
true
31050593b4252bf94fb491e37e0a0628017d2b69
90-shalini/python-edification
/collections/tuples.py
785
4.59375
5
# Tuples: group of items num = (1,2,3,4) # IMUTABLE: you can't update them like a list print(3 in num) # num[1] = 'changed' # will throw error # Faster than list, for the data which we know we will not change use TUPLE # tuple can be a key on dictionary # creating/accessing -> () or tuple xyz = tuple(('a', 'b')) print(...
true
91039029eb70633744498be6f68fe1435f08ba96
annafeferman/colloquium_2
/45.py
950
4.3125
4
"""Перетин даху має форму півкола з радіусом R м. Сформувати таблицю, яка містить довжини опор, які встановлюються через кожні R / 5 м. Anna Feferman""" import math # імпортуємо math radius = int(input('Введіть радіус: ')) # користувач вводить радіус interval = radius / 5 # зазначаємо інтервал встановлення ...
false
3aa3292bad982d13aa181250c738804b14af68ca
ssenthil-nathan/DSA
/linkedlistdelwithkey.py
1,628
4.21875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node def Delete(se...
true
61739837cf983d73229378376144c6465d798813
sevresbabylone/python-practice
/quicksort.py
744
4.34375
4
"""Quicksort""" def quicksort(array, left, right): """A method to perform quicksort on an array""" if left < right: pivot = partition(array, left, right) quicksort(array, left, pivot-1) quicksort(array, pivot+1, right) def partition(array, left, right): """Returns new pivot after ...
true
f853cecddcac4e12ec8d8d2f60e01e80ad840f98
mclavan/Work-Maya-Folder
/2014-x64/prefs/1402/if_01_notes.py
1,239
4.5625
5
''' Lesson - if statements ''' ''' Basic if statement if condition: print 'The condition is True.' ''' if True: print 'The condition is True.' if False: print 'The condition is True' ''' What is the condition? 2 == 2 2 == 3 ''' ''' Operators == Equals != Not Equals > Greater Than >= Greater Than or equal...
true
c297bfde92c1cfdd5e1784ff548374a9f17e6aa5
Courage-GL/FileCode
/Python/month01/day08/demo03.py
557
4.21875
4
""" 局部变量:小范围(一个函数)内使用的变量 全局变量:大范围(多个函数)内使用的变量 """ b = 20 def func01(): # 局部作用域不能修改全局变量 # 如果必须修改,就使用global关键字声明全局变量 global b b = 30 func01() print(b) # ? c = [30] def func02(): # 修改全局变量c还是修改列表第一个元素?? # 答:读取全局变量中数据,修改列表第一个元素 # 此时不用声明全局变量 c[0] = 300 func02() print(c) ...
false
3580a2af2a21f9f5d08bbb3115b7c3f7daf70f44
Courage-GL/FileCode
/Python/month01/day13/student_info_system.py
1,531
4.40625
4
""" 学生信息管理系统 """ class StudentModel: """ 学生信息模型 """ def __init__(self, name="", score=0, age=0, sid=0): self.name = name self.score = score self.age = age # 全球唯一标识符:系统为数据赋予的编号 self.sid = sid class StudentView: """ 学生信息视图:负责处理界面逻辑 """ ...
false
259a2f1710323a6aa1a905996af1563143528424
Courage-GL/FileCode
/Python/month01/day09/exercise02.py
491
4.1875
4
# 练习:定义数值累乘的函数 # list01 = [4,54,5,65,6] # result = 1 # for item in list01: # result *= item # print(result) def multiplicative(*args): # 合 result = 1 for item in args: result *= item return result print(multiplicative(43, 4, 5, 6, 7, 8)) print(multiplicative(43, 4)) print(multiplicative(43, 4...
false
b6d39d5c2f062fcf2dbafbf739f0c03f1c7ce3f4
Courage-GL/FileCode
/Python/month01/day10/exercise02.py
983
4.40625
4
""" 练习:对象计数器 统计构造函数执行的次数 使用类变量实现 画出内存图 class Wife: pass w01 = Wife("双儿") w02 = Wife("阿珂") w03 = Wife("苏荃") w04 = Wife("丽丽") w05 = Wife("芳芳") print(w05.count) # 5 Wife.print_count()# 总共娶了5个老婆 """ cl...
false
f0bb994dcb9fdc3bc96177da99f96a928a9e6ebf
Courage-GL/FileCode
/Python/month01/day04/demo03.py
547
4.375
4
""" for + range函数 预定次数的循环 使用 for 根据条件的循环 使用 while 练习:exercise04 """ # 写法1: # for 变量 in range(开始,结束,间隔): # 注意:不包含结束值 for number in range(1, 5, 1): # 1 2 3 4 print(number) # 写法2: # for 变量 in range(开始,结束): # 注意:间隔默认为1 for number in range(1, 5): # 1 2 3 4 print(number) # 写法3: # for 变量 in...
false
c6d89bcaeb162b59041dd05b4acbef04f09c38fe
Courage-GL/FileCode
/Python/month01/day18/demo02.py
587
4.15625
4
""" 排列组合 全排列(笛卡尔积) 语法: 生成器 = itertools.product(多个可迭代对象) 价值: 需要全排列的数据可以未知 """ import itertools list_datas = [ ["香蕉", "苹果", "哈密瓜"], ["牛奶", "可乐", "雪碧", "咖啡"] ] # 两个列表全排列需要两层循环嵌套 # n n list_result = [] for r in list_datas[0]: for c in list_datas[...
false
4560ae75b9c66bbb4cf36973f48db46b620e10a8
pedronora/exercism-python
/prime-factors/prime_factors.py
458
4.125
4
def factors(value): factors_list = [] # Divisible by 2: while value % 2 == 0: factors_list.append(2) value = value / 2 # Divisible by other primes numbers: sqrt = int(value**0.5) for i in range(3, sqrt + 1, 2): while value % i == 0: factors_list.appen...
true
e991e53d24b80d8d91fabdf7696faefcfa3a61d3
weijiang1994/Learning-note-of-Fluent-Python
/character01/sample1-2.py
872
4.28125
4
""" @Time : 2020/6/11 9:59 @Author : weijiang @Site : @File : sample1-2.py @Software: PyCharm """ from math import hypot class Vector: def __init__(self, x=0, y=0): self.x = x self.y = y # print类实例不在以<class object --- at --->的形式输出,而已字符串进行输出,称作为'字符串表示形式' def __repr__(self): ...
false
62b0c62e5d1f93a770ffc64b37b522b41c979b4b
HernanFranco96/Python
/Curso de Python/Intro-python/Python/7_controlflujo.py
941
4.3125
4
#if 2 < 5: # print('2 es menor a 5') # a == b # a < b # a > b # a != b # a >= b # a <= b #if 2 == 2: # print('2 es igual a 2') #if(2 > 1): # print('2 es mayor a 1') #if(2 < 1): # print('1 no es mayor a 2') #if(2 != 3): # print('2 es distinto que 3') #f(3 >= 2): # print('3 es mayor o igual a 2') #i...
false
f52568ec7ea273dbb1f45b4415ce35f462783ef1
j94wittwer/Assessment
/Informatik/E3/task_4.py
460
4.1875
4
is_prime = False n = int(input("Please enter a number, to check if it's prime: ")) factors = [1] if n <= 1: is_prime = False elif n == 2: is_prime = True elif n % 2 == 0: is_prime = False else: for i in range(2, n): if n % i == 0: factors.append(i) if len(factors) > 2: ...
false
fd7a963ec1bbba262d7f0cb3348995198a805674
isobelyoung/Week4_PythonExercises
/Saturday_Submission/exercise_loops.py
2,201
4.15625
4
# Q1 print("***QUESTION 1***") # Sorry Hayley - I had already written this bit before our class on Tuesday so didn't use the same method you did! all_nums = [] while True: try: if len(all_nums) == 0: num = int(input("Enter a number! ")) all_nums.append(num) else: ...
true
e6e3fe4c8e42ba41bfdabdc0df75ef1d40584fb8
rigzinangdu/python
/practice/and_or_condition.py
984
4.3125
4
# We have to see [and] [or] conditions in pythons : #[and] remember if both the conditions true than output will be true !!! if it's one of condition wrong than it's cames false ----> !! #[or] remember one of the condition if it's true than its will be came true conditions -----> !! #<-----[and]------> name = "python...
true
ee8f4dfc81534a9dcfb4952e2ebd1f10e2c52be5
kaltinril/pythonTeaching
/assignments/rock_paper_scissors/sabreeen rock paper sisscors.py
864
4.25
4
import random turns_left = 3 while turns_left > 0: turns_left = turns_left - 1 player = input("Pick (R)ock, (P)aper, or (S)cissors:") computer = random.randint(1, 3) if computer == 1: computer = "r" elif computer == 2: computer = "p" elif computer == 3: computer = "s" ...
false
ca6f741a9a9300c892550aa72f17e1bcbb8197cf
Marwan-Mashaly/ICS3U-Weekly-Assignment-02-python
/hexagon_perimeter_calculator.py
461
4.3125
4
#!/usr/bin/env python3 # Created by Marwan Mashaly # Created on September 2019 # This program calculates the perimeter of a hexagon # with user input def main(): # this function calculates perimeter of a hexagon # input sidelength = int(input("Enter sidelength of the rectangle (cm): ")) # proces...
true
75a3d8a466b9e3ba5e531a327c8e1d65f311e509
SureshKumar1230/mypython
/Lists.py
1,476
4.21875
4
data1=[1,2,3,4] data2=['x','y','z'] print(data1[0]) print(data1[0:2]) print(data2[-3:-1]) print(data1[0:]) print(data2[:2]) #list operator list1=[10,20] list2=[30,40] list3=list1+list2 print(list3) list1=[10,20,30] print(list1+[40]) print(list1*2) list1=[1,2,3,4,5,6,7] print(list1[0:3]) #appending the ...
false
1fca15a02681ee918c1ca292e0ced7ece90f53a5
AlekseiSpasiuk/python
/l2ex1.py
768
4.34375
4
#!python3 # 1. Создать список и заполнить его элементами различных типов данных. # Реализовать скрипт проверки типа данных каждого элемента. Использовать функцию type() для проверки типа. # Элементы списка можно не запрашивать у пользователя, а указать явно, в программе. array = [] array.append(None) array.append(123...
false
269fa0433fc048b50a8f24cc449a278c8b0b959c
kyumiouchi/python-basic-to-advanced
/11.73. Commun Errors.py
2,023
4.25
4
""" Common Errors It is important to understand the error code SyntaxError - Syntax error- not part of Python language """ # printf('Geek University') # NameError: name 'printf' is not defined # print('Geek University') # 1) Syntax Error # 1 # def function: # SyntaxError: invalid syntax # print('Geek Univers...
true
5c288cf56bcccd91d9188d0123433678cb5f9876
kyumiouchi/python-basic-to-advanced
/10.67. Min e Max.py
2,874
4.15625
4
""" Min and Max max() -> the biggest number list_sample = [1, 8, 4, 99, 34, 129] print(max(list_sample)) # 129 tuple_sample = (1, 8, 4, 99, 34, 129) print(max(tuple_sample)) # 129 set_sample = {1, 8, 4, 99, 34, 129} print(max(set_sample)) # 129 dict_sample = {'a': 1, 'b': 8, 'c': 4, 'd': 99, 'e': 34, 'f'...
false
631632c5fd1c857d8ec88288d114f5ca499a6a46
elgun87/Dictionary
/main.py
1,211
4.25
4
# Created empty dictionary to add word and then to check if the word in the dictionary # If yes print the meaning of the word ''' dictionary = {} while True: word = input("Enter the word : ") if word in dictionary: #checking if the word in the list print(f'I have this word in my dictionary : {dictiona...
true
704045f6eaaa5c51d088b11ceb7877a7cf69b2d3
hannahmclarke/python
/dice_roll.py
1,199
4.28125
4
# -*- coding: utf-8 -*- """ Created on Tue May 21 21:02:54 2019 @author: Hannah """ """ Program will roll a pair of dice (number of sides will be randomly determined) and ask the user to guess the total value, to determine who wins Author: Hannah """ from random import randint from time import sleep def get_sides...
true
a16aeb45a19ab709ab4aca7412b93f2cbcd4fb00
supervisaproject/Escuela-Analitica
/Bloque 1/Sesion 1/Ejemplos/Ejemplos - Operadores/ej13_logico.py
1,237
4.3125
4
#Ejemplo 13 #operadores de identidad #is. #si dos variables son dienticas devuelve True si no devuelve False #identity operators #is. #if two variables are scientific it returns True if it does not return False x = "hola" y = "hola" resultado = x is y print(resultado) #diferencia entre is y == #difference between is ...
false
8a7c58ba13a2295ffbf4866d61eaef210814a58b
supervisaproject/Escuela-Analitica
/Bloque 1/Sesion 2/HomeWorks/HomeWork 2 - Macedonia de frutas/hw2.py
633
4.28125
4
# - *- coding: utf- 8 - *- #ejercicio 4 #sin modificar el listado de frutas crea un codigo que muestre el siguiente mensaje #without modifying the fruit list, create a code that displays the following message #Mis frutas favoritas son: #uva #platano #limon #naranja frutas = ["manzana", "pera", "uva", "cebolla", "pla...
false
18440ad27f90f49a1c08f5df08ffe73d743d6967
Lanottez/IC_BA_2020
/1st Term/Data_Structure_and_Algorithms/Codes/Exercises/ses02/ses02_extra.py
2,174
4.4375
4
def middle_of_three(a, b, c): """ Returns the middle one of three numbers a,b,c Examples: >>> middle_of_three(5, 3, 4) 4 >>> middle_of_three(1, 1, 2) 1 """ # DON'T CHANGE ANYTHING ABOVE # YOUR CODE BELOW return ... def sum_up_to(n): """ Returns the sum of integers ...
true
8ee4f7214d13842468a03b05f7fdd25e3947c7fc
Lanottez/IC_BA_2020
/1st Term/Data_Structure_and_Algorithms/Codes/Exercises/ses02/ses02.py
1,057
4.375
4
def sum_of_squares(x, y): """ Returns the sum of squares of x and y Examples: >>> sum_of_squares(1, 2) 5 >>> sum_of_squares(100, 3) 10009 >>> sum_of_squares(-1, 0) 1 >>> x = sum_of_squares(2, 3) >>> x + 1 14 """ # DON'T CHANGE ANYTHING ABOVE # YOUR CODE BELOW...
true
0c143e6c44d259294ada8ee2cda95c37f74a15ff
Lanottez/IC_BA_2020
/1st Term/Data_Structure_and_Algorithms/Codes/Exercises/ses06/ses06_extra.py
1,525
4.5625
5
def caesar_cipher_encrypt(str_to_encrypt, n): """ Encrypt string using Caesar cipher by n positions This function builds one of the most widely known encryption techniques, _Caesar's cipher_. This works as follows: you should be given a string str_to_encrypt and an encoding integer n, wh...
true
409ef5ba6745db47dbff12729c87e41eb9761e21
dpochernin/Homework_2
/Homework_2_6.py
266
4.125
4
list_1 = [] while len(list_1) < 3: list_1.append(int(input("Enter number:"))) i = 0 if list_1[0] == list_1[1] or list_1[1] == list_1[2] or list_1[0] == list_1[2]: i = 2 if list_1[0] == list_1[1] == list_1[2]: i = 3 print("In list is ", i, "mach digits")
false
7d3e24b89e54f42068ce2b8dca77ca5e3fc2abed
santhosh15798/k
/sa.py
233
4.15625
4
ch=input() if(ch=='a'or ch=='e'or ch=='i'or ch=='o' or ch=='u' or ch=='A' or ch=='E'or ch=='I'or ch=='O' or ch=='U'): print ("Vowel") elif((ch>='a' and ch<='z') or (ch>='A' and ch<='Z')): print("Consonant") else: print("invalid")
false
638cd82594d426b03aa471ead40ee21e696ca814
hyuraku/Python_Learning_Diary
/section1/dictionary.py
1,183
4.125
4
#辞書型のデータの基本的な作り方。 d={'x':10,'y':20} print(d) print(type(d)) #> <class 'dict'> print(d['x'],d['y']) #xの値を100にする。 d['x']=100 print(d['x'],d['y']) #> 100 20 #'z':200 を追加する d['z']=200 #'1':50 を追加する d[1]=50 print(d) #> {'x': 100, 'y': 20, 'z': 200, 1: 50} #これも辞書型データの作り方 d2=dict(a=10,b=20) print(d2) #> {'a': 10, 'b': 20...
false
a858fbfb5b2570d28a04edf7ef7d99fae6cd1038
mcwiseman97/Programming-Building-Blocks
/adventure_game.py
1,829
4.1875
4
print("You started a new game! Congratulations!") print() print("You have just had a very important phone call with a potential employer.") print("You have been in search of a new job that would treat you better than you had been at your last place of emplyement.") print("John, the employer, asked you to submit to him ...
true
440d7421e3f5a138f13f43f9ce1b79d170ef8eb4
Soooyeon-Kim/Object-Oriented-Programming
/Practice/Encapsulation_PointClass.py
946
4.4375
4
#2차원 평면상의 점(point)을 표현하는 클래스 Point를 정의하라. import math class Point: def __init__(self, x=0.0, y=0.0): self.__x = x self.__y = y @property def x(self): return self.__x @property def y(self): return self.__y def move(self, x, y): self...
false
26eeca2fda332e7113887da66b91edf8ad362a2c
nerminkekic/Guessing-Game
/guess_the_number.py
912
4.4375
4
# Write a programme where the computer randomly generates a number between 0 and 20. # The user needs to guess what the number is. # If the user guesses wrong, tell them their guess is either too high, or too low. import random # Take input from user guess = int(input("Guess a number between 0 and 20! ")) # Number of...
true
e0fd54fe84a10dc5d8e15ded5538fd5674b40e6e
kilmer7/workspace_python
/Curso em Video/desafio16.py
345
4.21875
4
import math num = float(input('Digite um número real: ')) num = math.trunc(num) print('O número inteiro do algarismo que você escreveu é {}'.format(num)) ''' Outra forma de resolver sem adicionar bibliotecas. num = float(input('Digite um valor')) print('O valor digitado foi {} e a sua porção inteira é {}'.format(nu...
false
4844eb4416c99f709e8d8d7d4219bee020c7adb6
nbpillai/npillai
/Odd or Even.py
205
4.3125
4
print("We will tell you if this number is odd or even.") number = eval(input("Enter a number! ")) if number%2==0: print("This is an even number!") else: print ("This number is an odd number!")
true
ee4bb01eb029819b15ee23c478edab0aada9608b
ari-jorgensen/asjorgensen
/SimpleSubstitution.py
1,140
4.15625
4
# File: SimpleSubstitution.py # Author: Ariana Jorgensen # This program handles the encryption and decryption # of a file using a simple substitution cipher. # I created this algorithm myself, only borrowing the # randomized alphabet from the Wikipedia example # of substitution ciphers # NOTE: For simplicity, all char...
true
f09176c324c14916ee1741dd82077dd667c86353
cbarillas/Python-Biology
/lab01/countAT-bugsSoln.py
903
4.3125
4
#!/usr/bin/env python3 # Name: Carlos Barillas (cbarilla) # Group Members: none class DNAString(str): """ DNAString class returns a string object in upper case letters Keyword arguments: sequence -- DNA sequence user enters """ def __new__(self,sequence): """Returns a copy of sequenc...
true
8db2c042802cacea93d08efe36084db87a410409
hkaushalya/Python
/ThinkPythonTutorials/exer_10_1.py
595
4.125
4
def capitalize_all(t): res = [] for x in t: res.append(x.capitalize()) return res ###################### # This can handle nested list with upto depth of 1. # i.e. a list inside a list. # not beyond that, like , list in a list in a list!!! ###################### def capitalize_nested(t): res =...
false
92db81dc42cd42006e58a7acb64347ef443b4afc
mattin89/Autobiographical_number_generator
/Autobiographic_Numbers_MDL.py
1,542
4.15625
4
''' By Mario De Lorenzo, md3466@drexel.edu This script will generate any autobiographic number with N digits. The is_autobiographical() function will check if numbers are indeed autobiographic numbers and, if so, it will store them inside a list. The main for loop will check for sum of digits and if the number of...
true
801c588912b99c98b0076b70dbbd8d7b2184c23e
garetroy/schoolcode
/CIS210-Beginner-Python/Week 2/counts.py
1,410
4.4375
4
""" Count the number of occurrences of each major code in a file. Authors: Garett Roberts Credits: #FIXME Input is a file in which major codes (e.g., "CIS", "UNDL", "GEOG") appear one to a line. Output is a sequence of lines containing major code and count, one per major. """ import argparse def count_codes(majors_f...
true
40cd6d4d249a74f144be83a371b8cb1c1d383cb0
MrSerhat/Python
/Fibonacci_Serisi.py
323
4.15625
4
""" Fibonacci Serisi yeni bir sayıyı önceki iki sayının toplamı şeklinde oluşturur. 1,1,2,3,5,8,13,21,34... a,b=b,a+b "a nın değerine b nin değerini atıyoruz" """ a=1 b=1 fibonacci=[a,b] for i in range(20): a,b=b,a+b print("a:", a,"b:",b) fibonacci.append(b) print(fibonacci)
false
2e18fd51ae66bc12003e51accf363523f227a76e
agzsoftsi/holbertonschool-higher_level_programming
/0x06-python-classes/5-square.py
1,007
4.46875
4
#!/usr/bin/python3 """Define a method to print a square with #""" class Square: """Class Square is created""" def __init__(self, size=0): """Initializes with a size""" self.size = size @property def size(self): """method to return size value""" return self.__size ...
true