blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e1149ba3d4f87b3c3969341602823a13b1ac0b93
Rajno1/PythonBasics
/variables/MultipleValuesToVariable.py
543
4.28125
4
""" Python allows you to assign many values to multiple variables we can assign one value to multiple variables if you have a collection of values in a list, Python allows you to extract the values to variables- this called unpacking """ # assigning many values to multiple variables x,y,z="Raju",2,True print(x+" is",ty...
true
2bdd24b3e5fbc8c8e0af0e76ee4b179811a0532f
DipendraDLS/Python_Basic
/08. Dictionary/loops_in_dictionary.py
1,046
4.5625
5
# Iterations on Dicionary # Example 1: details = {'name': 'Ram', 'age': 24} # details vanni yeuta dictonary ho. Yesma Key and value huncha "curly bracket" leh vancha yo dictionary ho. print(details.items()) # For looping through values for x in details.values(): print(x) # For LOOPING THROUGH KEYS for k in deta...
false
94ec66938d15c309a1358f77ebd76391ca4e8990
DipendraDLS/Python_Basic
/05. List/list_enumerate().py
219
4.125
4
# Syntax: # Syntax ==> enumerate(iterable, start_index) # Example 1: list = [10, 50, 75, 83, 98, 84, 32] for x, res in enumerate(list): print(x, ":", res) for x, res in enumerate(list, 0): print(x, ":", res)
false
9ff4aee52115a0b8582c751ef58607da41b9b404
DipendraDLS/Python_Basic
/18. Working_with_text_file/reading_and_writing.py
455
4.125
4
# # Example 1 : reading from one file and writing to another file with open("file1.txt") as f: content = f.read() with open("file2.txt", 'w') as f: f.write(content) # # Example 2 : Reading from old file and writing to the new file and finally deleting the old file import os oldname = "file1.txt" newname = "...
true
c6d31b991fdbf9b991517d72bda2055cd39d96c2
DipendraDLS/Python_Basic
/05. List/accessing_list.py
307
4.3125
4
# Accessing value of list a = [1, 2, 4, 56, 6] # Example 1: # Access using index using a[0], a[1], a[2] print(a[2]) # Assigning Values ( i.e change the value of list using) a[0] = 10 print(a) a_list = [1,2,3] a_list[1] = 4 print(a) #list repeatation list4 = [1, 2] list5 = list4 * 3 print(list5)
true
012797ebeff24d2a2453e2296cfc0d239b8e057c
DipendraDLS/Python_Basic
/13. Lambda_Function/lambda_function_with_map.py
785
4.40625
4
# The map() function in Python takes in a function and a list. # The function is called with all the items in the list and a new list is returned which contains items returned by that function for each item. # Example 1 : program to double each item in the list using map() function. my_list = [1, 5, 4, 6, 8, 11, 3, 1...
true
a74d594c5cc9d009acad884b4dc313b08acead88
DipendraDLS/Python_Basic
/05. List/list_creation.py
770
4.375
4
# In python, list size can always be dynamic (i.e list ko size badna or ghatna sakcha).. no need to be worry of creating dynamic size like in C & C++ # lists are mutable (meaning that, values or items in the list can be changed or updated) # Syntax 1 : for Creating empty list in python first_list = [] print('Type of f...
true
2b54cb7e8716146aa9a754c89c636539c7421a61
wharward/CourseWork
/Python/Tutorial/Python in a day/Ch4-Stings.py
395
4.1875
4
date = "11/12/2013" #Go through string and split #where there is a '/' date_manip = date.split('/') #Show the outcome print date_manip print date_manip[0] print date_manip[1] print date_manip[2] print 'Month: ' + date_manip[0] print 'Day: ' + date_manip[1] print 'Year: ' + date_manip[2] print('Month: ' + date_mani...
false
13abef90c48da1dadfb1e1556edb9abfa3309a77
Datbois1/Dat_bois1
/Number 3.py
217
4.1875
4
Number=input("Enter Number") Number=int(Number) if Number > 10: print(str(Number)+" is greater than 10") elif Number < 10: print(str(Number)+" is less than 10") else: print(str(Number)+" is equal to ten")
true
d7e5111382f2368564d228026c1d212c882a5284
Fatihnalbant/deneme_2
/sozcukListe.py
649
4.1875
4
""" Bir yazı okuyunuz. Yazı boşluk karakterleriyle ayrılmış sözcüklerden oluşmuş olsun. Aynı sözcükleri atarak sözcükleri bir listeye yerleştiriniz. Örneğin girilen yazı şöyle olsun: bugün hava evet bugün çok hava güzel güzel Sonuç olarak şöyle bir liste elde edilmeli: ['bugün', 'hava', 'evet', 'çok', 'güzel']...
false
5bf19e52f679cea80074807211bfcca522b215f0
Tochi-kazi/Unit4-04
/function_program.py
1,113
4.125
4
# Created by: Tochukwu Iroakazi # Created on: Nov 2016 # Created for: ICS3U # This program displays marks def marks_number(number): if level == '4+' : score = 95 return score elif level == '4': score = 90 return score elif level == '4-' : score = 80 return score ...
false
50eb55ab4c06453ea292a630967fa1cb3369b477
blacklemons/python_lecture
/Data_Structure/set/set.py
713
4.15625
4
s1 = set([1,2,3]) print(s1) s2 = set("HELLO") print(s2) s3 = set([2,3,4]) print(s3) # access item print("H" in s2) # convert to list l1 = list(s1) print(l1) l2 = list(s2) print(l2) # add ## item s2.add('A') print(s2) ## set s2.update(s3) print(s2) # remove ## remove s2.remove('A') print(s2) ## discard s2.discard...
false
245c748c47b25a75ea18cddb1a79af1e097db93a
blacklemons/python_lecture
/Data_Structure/dictionary/dictionary.py
1,015
4.1875
4
dic = {'name':'pey', 'phone':'0119993323', 'birth': '1118'} # key , value # key : can only be strings and numbers (can't list, tuple) # add item dic['email'] = 'dic@gmail.com' print(dic) dic[3] = '3' print(dic) # get value by key print(dic.get('name')) print(dic['name']) ## fail to get value by key print(dic.get('...
false
3c99e735729ff6283b0aec80b4ae3bd47e41fa5f
SACHSTech/ics2o-livehack1-practice-laaurenmm
/windchill.py
717
4.1875
4
""" Name: windchill.py Purpose: This program allows the user to input a the degree in celsius and windspeed to calculate the Author: Mak.L Created: 08/02/2021 """ print ("******Windchill******") print("") #User will input temperature and wind speed temp_c = float(input("Enter the temperature in cel...
true
ad8927ec17caa8739aeb326c8965aa7641faf4d0
renatronic/data_structures_and_algorithms
/finders.py
2,101
4.25
4
from node import Node from linked_list import LinkedList ''' The grace of the both solutions is that both have O(n) time complexity, and O(1) space complexity. We always use two variables to represent two pointers no matter what size the linked list is). ''' # returns the nth to last element def nth_last_node(linke...
true
00b44f0765a7ae38024e85efdcd9d17982f2ca33
Ezeaobinna/algorithms-1
/Pending/dijkstra.py
1,042
4.15625
4
#!/usr/bin/python # Date: 2018-01-27 # # Description: # Dijkstra's algo can be used to find shortest path from a source to destination # in a graph. Graph can have cycles but negative edges are not allowed to use # dijkstra algo. # # Implementation: # - Initialze graph such that distance to source is set to 0 and othe...
true
89b5f2768d44829fb6bdd7eb7ce39dadf10791d5
ashidagithub/C1906AL1
/03-summation.py
957
4.125
4
# -*- coding: UTF-8 -*- # Filename : 03-summation.py # author by : (学员ID) # 目的: # 掌握基本的赋值,加减乘除运算,输入及输出方法 # 掌握 print 代入模式 # ------------------------------- # 练习一 # 用户输入数字 # 注:input() 返回一个字符串,所以我们需要使用 float() 方法将字符串转换为数字 num1 = float(input('输入第一个数字:')) num2 = float(input('输入第二个数字:')) # 求和 sum = num1 + num2 # 显示计算结果 ...
false
1248e8d20a1cc116f046311c10e44a443572a871
mikemontone/Python
/make_album2.py
747
4.15625
4
#!/opt/bb/bin/python3.6 def make_album(artist_name,album_title, tracks=''): """ Builds a dictionary describing a music album. """ album = { 'artist' : artist_name , 'album' : album_title} if tracks: album['tracks'] = tracks return album #album1 = make_album('beach boys','pet sounds', tracks=14) #alb...
true
c3246f6b7419d2eef546fe82ae3809fda7201175
mikemontone/Python
/Chapter08/sandwich_order.py
655
4.125
4
toppings = [] #prompt = "\nPlease tell me what toppings you want on your sandwich: " #prompt += "\n (Enter 'quit' when you are finished adding toppings.) " #while True: # topping = input(prompt) # if topping == 'quit': # break # else: # print("Adding " + topping + " to your sandiwch.") def make_sa...
true
6efee5952d9eb05913d735135d2377215c54fc65
Cherry93/coedPractices
/demos/W1/day4/03Fate.py
916
4.5
4
''' ·随机生成颜值 ·如果颜值超过90,输出“恭喜,您的颜值简直逆天” ----- ·否则输出“呵呵,您的颜值很亲民” ----- ·如果超过90,输出“恭喜,您的颜值简直逆天” ·60~90,输出“呵呵,您的颜值很亲民” ·否则输出“我们聊天气吧” ''' import random looking = random.randint(0,100) print(looking) #1.0 单分支 # if looking > 90: # print("恭喜,您的颜值简直逆天") #2.0 双分支 # if looking > 90: # print("恭喜,您的颜值简直逆天") # else: # ...
false
e113cbc67495858f87609e4751af24b7c93f4540
sandeep2823/projects
/Python/derek banas learning/05_Functions/05_calculate_area.py
824
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 9 23:26:25 2018 @author: sandeepsingh """ import math def get_area(shape): shape = shape.lower() if shape == "circle": circle_area() elif shape == "rectangle": rectangle_area() else: ...
true
d893029766441bdfbf03370f60c8a7ed227dc9e7
sandeep2823/projects
/Python/derek banas learning/01_simple_code/02_convert_miles_to_kilometers.py
396
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 2 22:33:09 2018 @author: sandeepsingh """ # Problem : Receive miles and convert to kilometera miles = input("Please enter the miles : ") # Convert miles to kilometer and store into kilometer kilometer = int(miles) * 1.60934 # Print the kilomet...
true
67c8802e4e5e7d7df8f240bd10165d10b6d26b77
CAM603/Python-JavaScript-CS-Masterclass
/Challenges/bst_max_depth.py
1,207
4.125
4
# Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right d...
true
24db06c139aee2fcb826460d2db06b598a64634a
carlosbazilio/lp
/python/conceitos-oo.py
2,727
4.3125
4
''' Autor: Carlos Bazilio Descricao: Este programa ilustra: * Uma hierarquia de classes em Python e como classes abstratas podem ser implementadas * Definicao e uso de propriedades para encapsulamento de atributos. * Tratamento de Excecoes Python disponibiliza o modulo abc para implementar classes abstratas ABC e a...
false
46652424284c4f5e8bdda17b735b6afc94959b24
BagalDipti/Python_basics
/Inheritance.py
1,797
4.28125
4
# ------------Single Inheritance----------------------- class A: def Show(self): print("Parent class") class B(A): def Disply(self): print("Child Class") p=A() c=B() c.Show() c.Disply() # -----------Multiple Inheritance------------------------------- class A: def...
false
a877f7d37cac84d65a89bcd2a700785fa30ccdda
RephenSoss/ToDoList
/todolist.py
777
4.25
4
def show_help(): print ('What should we pick up at the store?') print (""" Enter "DONE" to stop adding items. Enter "HELP" to stop adding items. Enter "SHOW" to stop adding items. """) show_help() def add_to_list(new_item): shop_list.append(new_item) print("Added {}. List now had {} items.".format(new_item,...
true
ae55dc7e9efaee988360b0d751a853211cce037b
Karadesh/Homework
/Homework_1/Hours, minutes and seconds.py
544
4.25
4
#2. Пользователь вводит время в секундах. # Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. # Используйте форматирование строк. seconds = int(input('Введите количество секунд: ')) minutes = int(seconds/60) hours = int(minutes/60) seconds = seconds - (minutes*60) minutes = minutes - (hours*60) ...
false
3eddd6fc6998c0d7bd0bfdd125693754a11bb7af
rehanhkhan/Assignment2
/Exercise_4-10.py
914
4.75
5
'''*********************************************************************************************** 4-10. Slices: Using one of the programs you wrote in this chapter, add several lines to the end of the program that do the following: • Print the message, The first three items in the list are:. Then use a slice to prin...
true
ad779c776ddc4fd8e4c219c65b55062cb7bdeba9
alex3kv/PythonWebinar
/Lesson3/Task6.py
1,369
4.28125
4
# 6. Реализовать функцию int_func(), принимающую слово из маленьких латинских # букв и возвращающую его же, но с прописной первой буквой. Например, # print(int_func(‘text’)) -> Text. # # Продолжить работу над заданием. В программу должна попадать строка из слов, # разделенных пробелом. Каждое слово состоит из латин...
false
60dbf192f402385cdefb861e0b548aa5d65000d0
chendddong/Jiuzhang-Ladder
/5. Kth Largest Element.py
1,310
4.25
4
''' Find K-th largest element in an array. You can swap elements in the array Example Example 1: Input: n = 1, nums = [1,3,4,2] Output: 4 Example 2: Input: n = 3, nums = [9,3,2,4,8] Output: 4 Challenge O(n) time, O(1) extra memory. ''' # TAG:[Quick Sort, Quick Select, Two Pointers] class Solution: """ @par...
true
d91fd5064dcd962d29adc7e6cde8fae572a1a9ba
Minji0h/Introduce-at-CCO-with-python
/Semana3/exercicio2.py
260
4.21875
4
# Receba um número inteiro na entrada e imprima # Fizz # se o número for divisível por 3. Caso contrário, imprima o mesmo número que foi dado na entrada. numero = int(input("Digite um numero: ")) if numero%3 == 0: print("Fizz") else: print(numero)
false
b4dd714c784a2ddc28a06849e7d2bd089d8bf6c3
JayneJacobs/PythonHomeGrown
/decisionsComparison/defProceduresBasic (1).py
1,367
4.125
4
# Define a procedure, is_friend, that takes # a string as its input, and returns a # Boolean indicating if the input string # is the name of a friend. Assume # I am friends with everyone whose name # starts with either 'D' or 'N', but no one # else. You do not need to check for # lower case 'd' or 'n' def isDNfriend(pe...
true
0ae82e92caf97c01068f029c06cb12f3cf4453b6
cs-fullstack-2019-spring/python-review-loops-cw-cgarciapieto
/pythonreviewclasswork.py
1,119
4.21875
4
def main(): # exercise1 # Python program that prints all the numbers from 0 to 6 except 3 and 6. # with an expected output of 1245 # def exercise1(): # number = 0 # # # for number in range(6): # number = number + 1 # # if number == 3: # # continue # continue here # # elif number =...
true
045d40c58121721a843693ed35bb54a4600588b4
Jlobblet/px277
/Week 2/Excercises/second_col_second_row.py
217
4.3125
4
"""Consider the 2D array ((1, 2), (3, 4)). Extract and print the second column values, then print the second row values.""" import numpy as np array = np.array(((1, 2), (3, 4))) print(array[:, 1]) print(array[1, :])
true
1cd060f2e6d05ec6e84fd6d41b456d9d7d0e9f64
Jlobblet/px277
/Week 2/Assessment/04.py
525
4.21875
4
"""Write a function called "increasing(data)" that prints True if the input array is increasing or False otherwise. Hint: np.diff() returns the difference between consecutive elements of a sequence. """ import numpy as np def increasing(data): """Take an array and return whether the array is strictly increasing o...
true
254fc2da95d970ab3f7b0246a3f070c11bf76234
lixintong1992/Algorithms
/Sorting/Insert_Sort.py
351
4.125
4
def InsertSort(arr): for i in range(1, len(arr)): if arr[i - 1] > arr[i]: temp = arr[i] j = i while(j > 0 and arr[j - 1] > temp): arr[j] = arr[j - 1] j -= 1 arr[j] = temp arr = [1, -2, 4, 7, 6, 3, 2, 3] # arr = [3, 2, 3, 4, 6,...
false
b0a956d04b8dd38eb03c7b73fe14f9d8c8c4806d
rramr/fa-python
/1. Functions/Fourth tasks/Task 4.py
420
4.15625
4
# При помощи функций map/filter/reduce из списка списков извлечь элементы, содержащиеся во вложенных списках по индексу 1. # Например, [[1, 2, 3], [2, 3, 4], [0, 1 , 1 , 1], [0, 0]] -> [2, 3, 1, 0] def sort(elem): return elem[1] lst = [[1, 2, 3], [2, 3, 4], [0, 1 , 1 , 1], [0, 0]] lst = list(map(sort, lst)) pri...
false
7641bae755f2a9ef578b210dba022c33c8e8e79b
lucascopnell/Practicals
/prac_05/hex_colours.py
510
4.25
4
HEX_COLOURS = {"beige": "#f5f5dc", "bisque3": "#cdb79e", "black": "#000000", "brown": "#a52a2a", "burlywood": "#deb887", "cadetblue": "#5f9ea0", "chartreuse1": "#7fff00", "coral": "#ff7f50", "cornflowerblue": "#6495ed", "cyan3": "#00cdcd" } colour = input("Enter colour name: ").lower() while colour != ...
false
89680b2abb72179539bb70b06c3393ae7ac7ae25
agnirudrasil/12-practical
/src/question_14/main.py
1,368
4.21875
4
""" Write a python program to create CSV file and store empno,name,salary in it. Take empno from the user and display the corresponding name, salary from the file. Display an appropriate message if the empno is not found. """ import csv def create_csv(): with open("employee.csv", "w", newline='') as f: cw...
true
b92826b10de4dbceb54160948095735fde546e4a
alejandroorca/alejandroorca.github.io
/ejercicios_pc/01.py
434
4.125
4
#01. Crea una función que reciba un parámetro de entrada de tipo numérico y que devuelva un booleano con valor true si el número es par y false si es impar. Ejecuta 3 llamadas de ejemplo de la función creada. import sys def booleano(num): mod = num % 2 if mod == 0: es_par = True else: es_par = False return...
false
fc8e54b728e1e5bffb00d9adb31be697b40a39cb
jason0703/TEST2
/list-tuple.py
745
4.125
4
# 有序可變動列表 List grades=[12,60,25,70,90] print(grades) print(grades[0]) print(grades[3]) print(grades[1:4]) grades=[12,60,25,70,90] grades[0]=55 # 把 55 放到列表中的第一個位置 print(grades) grades=[12,60,25,70,90] grades[1:4]=[] # 連續刪除列表中從編號 1 到編號 4(不包括) 的資料 print(grades) grades=[12,60,25,70,90] grades=grades+[12,33] print(grades) g...
false
f8784cdefac24096ab69d20e3eef3d6867fe320b
rochaalexandre/complete-python-course
/content/3_first_milestone_project/milestone_1/app.py
1,109
4.21875
4
MENU_PROMPT = "\nEnter 'a' to add a movie, 'l' to see your movies, 'f' to find a movie by title, or 'q' to quit: " movies = [] def add(): title = input("Enter the movie title: ") director = input("Enter the movie director: ") year = input("Enter the movie release year: ") movies.append({'title': titl...
false
f7baac1dc2ae334a602291896ce6161a693ef2a5
Username77177/Learn_py
/guide/#2_Input_Output.py
1,242
4.1875
4
#Input_Output (Ввод, Вывод) #If you could print some, than write print('Some') #Если ты хочешь что-то вывести, тогда пиши print('Что-нибудь') b = str(97) print("Some") print("Что-нибудь") print("Some value "+ b +" '3'") #Можно совмещать строки знаком "+", это называется конкатенация (пример '3') #If u have a wish to in...
false
65a3e5322a7bcfc2c45d4a2bc2fedf6dd52d8c93
erdembozdg/coding
/python/python-interview/algorithms/sorting/insertion_sort.py
461
4.28125
4
def insertion_sort(arr): # For every index in array for i in range(1,len(arr)): # Set current values and position currentvalue = arr[i] position = i while position>0 and arr[position-1]>currentvalue: arr[position]=arr[position-1] ...
true
5aab761eaaf04322966c6c74c0fcad037477c9bc
uzairaj/Python_Programming
/Python_Tips_Tricks.py
807
4.21875
4
#Create a single string from all the elements in list a = ["My", "name", "is", "Uzair"] print(" ".join(a)) #Return Multiple Values From Functions def x(): return 1, 2, 3, 4 a, b, c, d = x() print(a, b, c, d) #Find The Most Frequent Value In A List test = [1, 2, 3, 4, 2, 2, 3, 1, 4, 4, 4] p...
true
14bca08dd4cd2d68fa62269829ba76f92db83d29
george-marcus/route-planner
/student_code.py
2,436
4.25
4
import math from queue import PriorityQueue # Used Concepts found on this link # https://www.geeksforgeeks.org/a-search-algorithm/ def shortest_path(map_grid, start_node, goal): initial_distance = 0 road_cost = {start_node: initial_distance} came_from = {start_node: None} # we use a priority queue...
true
bf967bb5919d2c0d1e4698b1439c213ed2ef7d89
Nasir1004/-practical_python-with-daheer
/if statement.py
202
4.125
4
name = input('enter your name') if name is ("sharu"): print("sharu you are a good freind") elif name is ("abbas"): print('you are one of the best ') else: print('you are very lucky to be my freind')
true
a9b70899b6b89662582efd58b8f1c6f7ab38b60b
Libraryman85/learn_python
/beal_katas/2_1_18.py
1,322
4.25
4
# strings can be in single or double quotes # str = 'test' # str2 = "test" # string interpolation {} # bool # boolean is true/false # bool = True # bool_false = False # int # int = 1 # int = -1 # floats are decimals # float = 1.0 # float_negative = -1.0 # casting # output = '1' + 1 # to convert string to int # i...
true
662df803670dd10231be1ef40c2dccbacddb9ecc
mediassumani/TechInterviewPrep
/InterviewPrepKit/Trees/height_balanced_tree.py
1,209
4.15625
4
''' Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the depth of the two subtrees of every node never differ by more than 1. ''' def getDepth(self, node): left_depth = 0 right_depth = 0 ...
true
b7c13aca4e20c253e1e792d690226138292172ee
Fusilladin/ListOverlap
/ListOverlap.py
956
4.1875
4
# LIST OVERLAP a = [1, 2, 3, 5, 8, 13, 15, 21, 27, 28, 29, 30, 34, 44, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 27, 43, 44, 45] c = [] d = [] for elem in a: if (elem in a) and (elem in b): c.append(elem) continue elif (elem in a): d.append(elem) else:...
true
1021858fc455addb151eee1cf4a11aedcbc787a5
claggierk/video_rental
/Customer.py
2,075
4.25
4
phone_number_length = 12 dob_length = 3 class Customer(object): """ a Customer to a DVD rental facility """ def __init__(self, f_name, l_name, phone, dob, email): """constructor; initialize first and last names, phone #, date of birth, and email""" self.first_name = f_name self....
true
89ce032171309536dae16bc55a3c49fae721c86a
sanjeevseera/Hackerrank-challenges
/strings/Love-Letter_Mystery.py
1,121
4.125
4
""" James found a love letter that his friend Harry has written to his girlfriend. James is a prankster, so he decides to meddle with the letter. He changes all the words in the letter into palindromes. To do this, he follows two rules: He can only reduce the value of a letter by , i.e. he can change d to c, but he c...
true
29a744f875d73c04464a5d5b4c357fe1d3bb28d0
sanjeevseera/Hackerrank-challenges
/30DaysOfCode-challenges/Day17_More_Exceptions.py
1,039
4.3125
4
""" Yesterday's challenge taught you to manage exceptional situations by using try and catch blocks. In today's challenge, you're going to practice throwing and propagating an exception. Check out the Tutorial tab for learning materials and an instructional video! Task Write a Calculator class with a single method:...
true
a28639b300eed5497da619b9e89bc4da7c9f9bbb
nitish24n/Topgear-Python-L1-set1
/15th.py
693
4.40625
4
"""Create a list of 5 names and check given name exist in the List.         a) Use membership operator (IN) to check the presence of an element.         b) Perform above task without using membership operator.         c) Print the elements of the list in reverse direction.""" names = ["hari","krishna","pawan","karan",...
true
b6c7db962cd190f5e9e5515e6c9a1b188cce376f
nitish24n/Topgear-Python-L1-set1
/18th.py
630
4.3125
4
""" Using loop structures print numbers from 1 to 100.  and using the same loop print numbers from 100 to 1 (reverse printing) a) By using For loop b) By using while loop c) Let mystring ="Hello world" print each character of mystring in to separate line using appropriate loop """ #for-loop 1 to 100 for i in range(1,...
true
786bc7bddf5415c7c40c964bba2e8295d1066252
nitish24n/Topgear-Python-L1-set1
/13th.py
810
4.125
4
"""Write a program to find the biggest of 4 numbers.    a) Read 4 numbers from user using Input statement.    b) extend the above program to find the biggest of 5 numbers. (PS: Use IF and IF & Else, If and ELIf, and Nested IF)""" first,second,third,forth = input().split() first,second,third,forth = int(first),int(seco...
true
64dfaf738eda5d3d558a423170d3f86c38370b42
FelipeGCosta/Introducao-a-Ciencia-da-Computacao-2018-2
/Lista 4/Lista de Exercícios 4 - Gabaritos/Lista 4 - Questão E.py
654
4.15625
4
""" Semelhante as questões 3 e 4, porém na função quadrado_pares quando temos todos os quadrados dos pares calculados e chegamos ao valor 1 nós chamamos a função entrada novamente para ler o próximo valor """ def entrada(): n = int(input()) if(n == 0): #Se n for 0 então paramos de ler valores do teclado ...
false
ecb479f13c16d41ab6f520d38e895bfa3ed0866f
whoislimos/Python-Codes
/Bubble_Sort.py
582
4.125
4
# Author: Abdulhalim Yusuf # Date: November 12, 2015 # Project: Bubble Sort #list = [3 , 2, 9 , 6 , 5] list =[23 ,42 ,4 ,16 ,8 ,15] print ("==== Bubble Sort Test begins ====\n") print ("Unsorted List", (list)) print ("The length of this list is", (len(list)), "\n") for j in range ((len(list)-1), 0, -1): ...
false
661af70ac0304040e409c3c122327ffb9d84d648
CHINASH29/hello-world
/duplicate.py
261
4.125
4
# Checking Duplicates in list my_list = ['a', 'a', 'b', 'c', 'd', 'd', 'e', 'e', 'e'] dupes = [] for values in my_list: if my_list.count(values) > 1: if values not in dupes: dupes.append(values) print('Duplicate values are :-', dupes)
true
3335a9c63f02bdc696f318a8c8b81ce966be3bc9
code-of-the-future/Python-Beginner-Tutorials-YouTube-
/Python_Types_and_Logical_Operators.py
626
4.21875
4
# Python Types # Basic types in python! print(type("Hello, world!")) print(type(13)) print(type(4.72)) print(type(True)) # Moving to integers print(4.72, int(4.72)) # Python rounds down! print(4.05, int(4.05)) # Rounding up! print(4.72, int(4.72), int(round(4.72))) # Moving strings to integers print("12345", int("...
true
bcc0f5f2518a37408bb025f494ae779ab7f373d0
EvansWinner/math-and-coding-exercises
/praxis_stalinsort_20210119.py
1,137
4.1875
4
"""Programming Praxis Stalin sort from https://programmingpraxis.com/2021/01/19/stalin-sort/ .""" # Going to do a proper, non-destructive version. def stalin(lst): """Sort a list by omitting any elements that are not sorted already.""" if not isinstance(lst, list): return [] if not lst: re...
false
c120d8292bfbc700efe17a59bfd70127bc47737b
mcburneyc/220
/labs/lab2/lab2.py
1,030
4.15625
4
""" Name: Cooper McBurney lab2.py """ import math def sum_of_threes(): upperbound = eval(input("Input your Upper Bound:")) x = 0 for num in range(3, upperbound + 1, 3): x= x + num print(x) #end for loop def multiplication_table(): for table in range(1,11): print(tab...
false
effe3f32bbd6abd042f25a407bf32226630ab2e7
EECS388-F19/lab-jcosens
/students.py
274
4.125
4
students = ["Daniel", "Kanu", "Olivia"] students.sort() print(students) first_name = students[0] first_name = first_name[:-1] print(first_name) length = 0 longest = ""; for x in students: if len(x) > length: longest = x; length = len(x) print(longest)
true
9b143c613b4a16b0d7653cc766dfa9d0376e46c3
aarreza/hyperskill
/CoffeeMachine/coffee_machine_v1.py
1,043
4.40625
4
#!/usr/bin/env python3 # Amount of water, milk, and coffee beans required for a cup of coffee WATER, MILK, COFFEE = (200, 50, 15) # Enter the available amount of water, milk, and coffee beans water_check = int(input("Write how many ml of water the coffee machine has: ")) milk_check = int(input("Write how many ml of mi...
true
bc16f961006f820799356fb52d92594137ccf9e9
limingwu8/ML
/NLP/demo02.py
440
4.15625
4
# test stopwords # filter words which included in stopwords from nltk.corpus import stopwords from nltk.tokenize import word_tokenize example_sentence = "This is an example showing off stop word filtration." stop_words = set(stopwords.words("english")) print(stop_words) words = word_tokenize(example_sentence) filtere...
true
426474b3f01c3ca40d212b7fcb4148908bde31bb
thegreedychoice/TheMathofIntelligence
/Gradient Descent - Linear Regression/gradient_descent.py
2,621
4.15625
4
import numpy as np import csv import matplotlib.pyplot as plt """ The dataset represents distance cycled vs calories burned. We'll create the line of best fit (linear regression) via gradient descent to predict the mapping. """ #Get Dataset def get_data(file_name): """ This method gets the data points from the csv...
true
155c460efdfd78af00513dbb1234b069dbbe93fe
Tomology/python-algorithms-and-data-structures
/Algorithms/sorting_algorithms/quicksort.py
1,181
4.1875
4
""" QUICK SORT Time Complexity Best Case O(n log n) Worst Case O(n^2) Space Complexity O(log n) """ def quickSort(arr, left=0, right=None): if right == None: right = len(arr) - 1 if left < right: pivotIndex = pivot(arr, left, right) # left quickSort(arr, left, ...
true
282b920f62219c096f5e4123f3222efb1d3f9e08
iApotoxin/Python-Programming
/14_whileLoop1.py
353
4.125
4
countNum1 = 0 while (countNum1 < 10): print ('The countNum1 is:', countNum1) countNum1 = countNum1 + 1 #------------------------------------------------- countNum2 = 0 while countNum2 < 10: print(countNum2, "True: countNum2 is less than 10") countNum2 = countNum2 + 1 else: print(countN...
true
1c64a0a40c89fc22509439b01afc5aa37751789f
shreeya917/sem
/python_mine/shreeeya/PycharmProjects/-python_assignment_dec15/unpack.py
246
4.15625
4
# Q5. Code a Function that simply returns ("Hello", 45, 23.3)and call this function and unpack the returned values and print it. def f(): return ["Hello", 45, 23.3] result = list(f()) print(result) #x,y,z=unpack()
true
c9f958bdf9318e66ae10596c08c2ea5210020d32
shreeya917/sem
/python_assignment_dec22/alphabetically_sort.py
363
4.34375
4
#Write a program that accepts a comma separated sequence of words as input # and prints the words in a comma-separated sequence after sorting them alphabetically. sequence=str(input("Enter the sequence of word: ")) words=sequence.split(',') print("The unsorted input is: \n",sequence) words.sort() print("The sor...
true
e0b130df14c6948bd4cbf1ae47b9337caf343090
raprocks/hackerrank-practice
/Python/leapcheck.py
497
4.21875
4
def is_leap(year): """TODO: Docstring for is_leap. :year: TODO :returns: TODO The year can be evenly divided by 4, is a leap year, unless: The year can be evenly divided by 100, it is NOT a leap year, unless: The year is also evenly divisible by 400. Then it is a leap year. """ leap = False yea...
true
6a522630136ef49df119a198addee80a7a4cd193
raprocks/hackerrank-practice
/FAANG/GreetMe.py
395
4.15625
4
name = input() # take only input as this is string time = int(input()) # take input and convert it to integer if time >= 0 and time <= 11: # simple if else statements based on problem statement print("Good Morning " + name + " sir.") elif time >= 12 and time <= 15: print("Good Afternoon " + name + " sir.") el...
true
af2011841db4dee24ffdc3d084b0731fdd258b98
davidalexander3986/PythonDataStructures
/heap/test.py
1,280
4.15625
4
import priorityQueue as pq PQ = pq.PriorityQueue() def printMenu(): print("Commands:") print("\tEnter a to add\n\tEnter p to pop\n\tEnter d to display contents") print("\tEnter t to top\n\tEnter Q to quit") command = input("Please enter a command: ") return command def add(): number = i...
false
b7916840e949bb9014b48d768ffa74136c99a520
davidalexander3986/PythonDataStructures
/Tries/test.py
914
4.125
4
import Trie as TST TST = TST.Trie() def printMenu(): print("Commands:") print("\tEnter i to insert\n\tEnter l to lookup") print("\tEnter Q to quit") command = input("Please enter a command: ") return command def insert(): string = input("Enter a string to insert: ") TST.insert(string...
false
21d46ef79e63a6d3ac7de06bb5d1a88b9434518c
PrhldK/NLTKTraining
/exercises/module2_2b_stopwords_NLTK.py
766
4.3125
4
# Module 2: Text Analysis with NLTK # Stop Words with NLTK # Author: Dr. Alfred from nltk.tokenize import word_tokenize from nltk.corpus import stopwords # print(stopwords.words('english')[0:500:25]) stop_words = set(stopwords.words("english")) text = """ Dostoevsky was the son of a doctor. His parents were very h...
true
9fbb5c647713f726f2435ccfaff604c43a50d325
Kamayo-Spencer/Assignments
/W1_A1_Q2_Spencer.py
1,046
4.4375
4
# Question. # In plain English and with the Given-required-algorithm table, write a guessing game # where the user should guess a secret number. After every guess, the problem tells the user whether their number # was too large or small. In the end, the number of tries needed should be printed # Given ifomation # Use...
true
de920ee9aea6686050e08e9abb6d620f954d57fb
skitoo/mysql-workbench-exporter
/mworkbenchexporter/utils.py
513
4.21875
4
def camel_case(input_string): return "".join([word.capitalize() for word in input_string.split('_')]) def lower_camel_case(input_string): first = True result = "" for word in input_string.split('_'): if first: first = False result += word.lower() else: ...
true
1c511220f1083194e354e2d9f73199d63d812128
Julzmbugua/bootcamp
/students.py
1,212
4.1875
4
student = { 'name': 'An Other', 'langs': ['Python', 'JavaScript', 'PHP'], 'age': 23 } student2 = { 'name': 'No Name', 'langs': ['Python', 'Java', 'PHP'], 'age': 24 } # Task 1: # Create a function add_student that takes a student dictionary as a parameter, # and adds the student in a list of st...
true
da086a88365d28d2b8172689780b0ffaf6fa17fc
agus2207/Cursos
/Python for Everybody/Extracting_Data.py
916
4.15625
4
#n this assignment you will write a Python program somewhat similar to https://py4e.com/code3/geoxml.py. #The program will prompt for a URL, read the XML data from that URL using urllib and then parse and #extract the comment counts from the XML data, compute the sum of the numbers in the file and enter the sum. ...
true
1af6b418d30b50f291803394b0d53006d349af09
thelmuth/cs110-spring-2020
/Class22/turtle_drawing.py
958
4.375
4
import turtle def main(): michelangelo = turtle.Turtle() turtle_drawing(michelangelo) def turtle_drawing(t): """ Write a function that takes a turtle, and then asks the user what direction the turtle should move using the WASD keyboard keys. The turtle should move up 30 pixels if the user enter...
true
d45d46386733cf5e97f8ac555f82e66e5111fde3
thelmuth/cs110-spring-2020
/Class04/year.py
533
4.375
4
""" Author: Class Description: This program calculates the year and number of days past Jan. 1 given some number of days. """ DAYS_IN_YEAR = 365 START_YEAR = 2020 def main(): days = int(input("Enter the number of days that have passed since Jan. 1 2020: ")) years = days // DAYS_IN_YEAR curre...
true
32d18a1cba9d4bbcd9d95e2281e5a834e678a7c2
thelmuth/cs110-spring-2020
/Class25/cards.py
2,288
4.21875
4
""" File: cards.py Author: Darren Strash + Class! Make playing card class for blackjack. """ import random #Rank RANKS = ["A", 2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K"] #Suit SUITS = ["D", "C", "S", "H"] class PlayingCard: """Represents a single playing card from a standard deck.""" def __init__(self, rank...
true
252b50d29c748b3ca9d95c359a43bed3c7c5fe3b
thelmuth/cs110-spring-2020
/Class16/grids.py
1,653
4.28125
4
def main(): # Create a grid of a map for a robot in a park map = [["grass", "puddle", "mud"], ["tree", "grass", "grass"], ["bush", "robot", "tree"], ["bush", "mud", "grass"]] # print(map) # print(map[2]) # print(map[2][3]) print_grid(map) ...
true
9dca3985fd5ee606d8b6fd1c8b53bd2fcf17f1f1
rand0musername/psiml2017-homework
/2 Basic file ops/basic_file_ops.py
733
4.1875
4
import re import os # regex that matches valid text files FILE_PATTERN = re.compile(r"^PSIML_(\d{3}).txt$") def count_files(root): """Return the number of files under root that satisfy the condition.""" num_files = 0 for dirpath, _, files in os.walk(root): for file in files: fmatch = F...
true
eeb3636504db21ac1a21807038e2213a5effa2a8
bhavanikumar10/Activities
/python_activity_5/comprehension.py
2,067
4.3125
4
prices = ["24", "13", "16000", "1400"] price_nums = [int(price) for price in prices] print(prices) print(price_nums) dog = "poodle" letters = [letter for letter in dog] print(letters) print(f"We iterate over a string into a list: {letters}") capital_letters = [letter.upper() for letter in letters] # another way of do...
false
da1721a0670435a000e319adf776fd5770b4af08
sidherun/lpthw
/ex_15a.py
950
4.25
4
# This line imports argument variable module from the sys library from sys import argv # This line identifies the arguments required when the script runs script, filename = argv # This line initiates a variable, 'txt' and assigns the open function on the file we created 'ex15_samples.txt', which means the contents of...
true
bc19e0f1be946edcdc032719be76c1c888519555
simonlc/Project-Euler-in-Python
/euler_0007
699
4.25
4
#!/usr/bin/env python """ By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? """ #http://www.daniweb.com/software-development/python/code/216880/check-if-a-number-is-a-prime-number-python def isprime(n): "Check if integer n is a p...
true
b064a9e9915c6a1b13993bf688dba5c09cd76e3c
richardmoonw/CRS_Bioinformatics
/Week_01/exercise04.py
985
4.25
4
# The careful bioinformatician should check if there are other short regions in the genome # exhibiting multiple occurrences of a n-mer and its complement. After all, maybe therse strings # occur as repeats throughout the entire genome, rather than just in the ori region. The goal is # to create a program to find all ...
true
4229331e91ef430e66bc1b0638e942680a54edf0
EswarAleti/Chegg
/Python/Curve_GPA/GPA.py
1,156
4.28125
4
#importing random to generate random numbers import random #declare a list called GPA GPA=[] #These indexes denotes the random number between startFrom to endAt i.e 0 to 40 startFrom=0 endAt=40 #This function generate GPA list using random() def generateRandomGPA(): #For 20 students for i in range(20): ...
true
e8484248385457e46082e0f1f7634e1094bd7ebf
MayaGuzunov/AssignementsPythonDTU
/Exercise1.py
534
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Oct 24 17:22:48 2021 @author: mayaguzunov """ import numpy as np def count_unique_rows(x): row=x unique_rows=0 row_del=x for i in range(len(row)): if row[i,0]==2: row_del=np.delete(row,i,axis=0) i=i+1 ...
false
cf3724943d030d91f00cac381d2c92a796d74c8c
MayaGuzunov/AssignementsPythonDTU
/functions1.py
273
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 8 22:25:35 2021 @author: mayaguzunov """ def evaluate_polynomial(x): a=5 b=-7 c=3 return a*x**2+b*x+c def evaluate_polynomial(x): a=5 b=-7 c=3 print(a*x**2+b*x+c)
false
9bf2a324689448777fd5ee8f564db7be204cd442
Da1anna/Data-Structed-and-Algorithm_python
/leetcode/其它题型/双指针/common/删除链表的倒数第N个节点.py
1,392
4.125
4
''' 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 示例: 给定一个链表: 1->2->3->4->5, 和 n = 2. 当删除了倒数第二个节点后,链表变为 1->2->3->5. 说明: 给定的 n 保证是有效的。 进阶: 你能尝试使用一趟扫描实现吗? 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' # Definition for singly-linked list. # class ListN...
false
db8a366891201e235e1c0c9cfb7cac94d2ef7a55
Da1anna/Data-Structed-and-Algorithm_python
/leetcode/其它题型/字典树/单词搜索.py
2,190
4.1875
4
''' 设计一个支持以下两种操作的数据结构: void addWord(word) bool search(word) search(word) 可以搜索文字或正则表达式字符串,字符串只包含字母 . 或 a-z 。 . 可以表示任何一个字母。 示例: addWord("bad") addWord("dad") addWord("mad") search("pad") -> false search("bad") -> true search(".ad") -> true search("b..") -> true 说明: 你可以假设所有单词都是由小写字母 a-z 组成的。 来源:力扣(LeetCode) 链接:https:...
false
68dd02c6e73c8461c7af2eb5c8ed9875f5b33ff9
AishaRiley/calculate-volume
/volumepyramid.py
404
4.125
4
##Write program to calculate volume of pyramid ##Have user give the base and the height of the pyramid def main(): print("Volume:",pyramidVolume(5, 9)) print("Expected: 300") print("Volume:",pyramidVolume(9, 10)) print("Expected: 0") def pyramidVolume(baseLength, height): baseArea = base...
true
a6691db3611b04de1322f6ecf30b87a6fc83d708
Yobretaw/AlgorithmProblems
/Py_leetcode/007_reverseInteger.py
1,122
4.1875
4
import sys import math """ Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 - If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100. - Did you notice that the reversed integer might overflow? Assume the input is a 32...
true
1373f3fbe475186d04a6f9ebdf7e001b1a3eb2ab
Yobretaw/AlgorithmProblems
/Py_leetcode/162_findPeakElement.py
1,039
4.25
4
import sys import math """ A peak element is an element that is greater than its neighbors. Given an input array where num[i] != num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fine. You may imagine th...
true
9df0e169aa2b24b89699b821127ab38962e87f98
Yobretaw/AlgorithmProblems
/EPI/Python/BinaryTree/10_1_testIfBalanced.py
1,575
4.15625
4
import sys import os import math import imp Node = imp.load_source('Node', '../BST/BST.py').Node bst_print = imp.load_source('Node', '../BST/BST.py').bst_print """ ============================================================================================ A binary tree is said to be balanced if for each node...
true
8462a52099b7ff85c921367ea3b26449da940299
Yobretaw/AlgorithmProblems
/EPI/Python/Array/6_13_permuteElementsOfArray.py
1,386
4.3125
4
import sys import os import re import math import random """ ============================================================================================ A permutation of an array A can be specified by an array P, where P[i] represents the location of the element at i in the permutation. A permutation can ...
true
b75f5219b092e837b2f4dfd19691c35c73b21f75
Yobretaw/AlgorithmProblems
/Py_leetcode/224_basic_calculator.py
1,805
4.34375
4
import re """ Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces. You may assume that the given expression is always valid. Some examples: ...
true
0119a76668ae12ebb589380e105137148adbc4cf
Yobretaw/AlgorithmProblems
/EPI/Python/Strings/7_4_reverseAllWordsInSentence.py
748
4.15625
4
import sys import os import re import math """ ============================================================================================ Implement a function for reversing the words in a string s. Assume s is stored in a array of characters ===========================================================...
true