blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0633fefb8c5bc1d1399916ffc86e4e1c3e0cbc28
kgomathisankari/PythonWorkspace
/beautiful_soup_programs/develop_flipkart_scraping/menu.py
645
4.28125
4
from app import * user_choice = """ Enter : - 'h' to know the commands - 'a' to list all the Laptops - 'b' to list the best Laptops - 'c' to list the cheapest Laptops - 'q' to quit """ print(user_choice) user_input = input("Enter Here : ") user_input = user_input.strip().lower() while user_input != 'q': if use...
false
b6c8d7f466056cd4f5ed7d8a7fcd5cddf908ef2f
kgomathisankari/PythonWorkspace
/function_and_class_programs/arthimetic_program.py
845
4.15625
4
user_input = input("Enter what Arithmetic operator you want to preform : ") user_input = user_input.strip() user_input = user_input.upper() input_num1 = int(input("Enter a number : ")) input_num2 = int(input("Enter another number : ")) def addition(num1, num2) : return num1 + num2 def subtraction(num1, num2) : ...
false
80282dbf6abf81960e5714850eb1455cd147009a
kgomathisankari/PythonWorkspace
/function_and_class_programs/palindrome_calling_function_prgram.py
561
4.25
4
user_input = input("Enter your name : ") def reverseString(user_input) : reverse_string = "" for i in range (len(user_input) - 1, -1 , -1) : reverse_string = reverse_string + user_input[i] return reverse_string def isPalindrome(user_input) : palindrome = "What you have entered is a Palindrome"...
true
b61cc6e6fbac22a3444fd6827d4cbf84cc554924
kgomathisankari/PythonWorkspace
/for_loop_programs/modified_odd_and_even_program.py
503
4.3125
4
even_count = 0 odd_count = 0 getting_input = int(input("How many numbers do you want to enter? ")) for i in range (getting_input) : getting_input_2 = int(input("Enter the number : ")) even = getting_input_2 % 2 if even == 0 : even_count = even_count + getting_input_2 elif even != 0 : odd...
true
f4ad192198588faed881318cbee95bed57fbbdd2
kgomathisankari/PythonWorkspace
/for_loop_programs/largest_smallest_program.py
421
4.21875
4
no_count = int(input("How many numbers do you want to enter? ")) list = [] for i in range (no_count) : num = int(input("Enter the number : ")) list.append(num) largest = list[0] smallest = list[1] for j in list : if largest < j : largest = j elif smallest > j : smallest = j print("The l...
true
ccf69b387d5b3feba7885fa215ec73d4a6995231
kgomathisankari/PythonWorkspace
/dictionary_programs/dictionary_sample.py
1,584
4.4375
4
month = {'JANUARY' : 31 , 'FEBRUARY': 28 , 'MARCH' : 31 , 'APRIL': 30 , 'MAY' : 31 , 'JUNE' : 30 , 'JULY' : 31 , 'AUGUST': 31 , 'SEPTEMBER' : 30 , 'OCTOBER' : 31 , 'NOVEMBER' : 30 , 'DECEMBER' : 31} month_input = input("...
false
fe9366843f9bdeac7a0687b6bb2abb26357007aa
vTNT/python-box
/test/func_doc.py
290
4.4375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- def printmax(x, y): '''print the max of two numbers. the two values must be integers.''' x = int(x) y = int(y) if x > y: print x, 'is max' else: print y, 'is max' printmax(3, 5) #print printmax.__doc__
true
d331f247e1ad6183997de06a8323dd27f56794ad
vTNT/python-box
/app/Tklinter2.py
932
4.21875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- from Tkinter import * class LabelDemo( Frame ): """Demonstrate Labels""" def __init__( self ): """Create three Labels and pack them""" Frame.__init__( self ) # initializes Frame instance # frame fills all available space self....
true
658a3ba9560615ba04aebaa444e09e91f763c668
dscheiber/CodeAcademyChallenge
/binaryconversion.py
2,185
4.46875
4
# 3. Convert a decimal number into binary # Write a function in Python that accepts a decimal number and returns the equivalent binary number. # To make this simple, the decimal number will always be less than 1,024, # so the binary number returned will always be less than ten digits long. ##author note: ok, so i h...
true
206bfc1fc295e7803c04d70a69ee8445ad308201
yellowb/ml-sample
/py3_cookbook/_1_data_structure/deduplicate_and_maintain_order.py
979
4.125
4
""" Sample for removing duplicated elements in list and maintain original order """ import types names = ['tom', 'ken', 'tim', 'mary', 'ken', 'ben', 'berry', 'mary'] # Use `set()` for easy deduplicate, but changes the order print(set(names)) # Another approach: use loop with a customized hash function def dedupe(it...
true
892801363f4edc79ed1ed9ce38f9bdbd483ab02d
wjaneal/ICS3U
/WN/Python/VectorField.py
1,295
4.34375
4
#Vector Field Program #Copyleft 2013, William Neal #Uses Python Visual Module to Display a Vector Field #as determined by an equation in spherical coordinates #Import the required modules for math and graphics: import math from visual import * #Set a scale factor to determine the time interval for each calculation:...
true
ae30d9d7532905ac7e32a7b728a9a42c24c55db8
shripadtheneo/codility
/value_part_array/same_val_part_arr.py
910
4.1875
4
""" Assume the input is an array of numbers 0 and 1. Here, a "Same Value Part Array" means a part of an array in which successive numbers are the same. For example, "11", "00" and "111" are all "Same Value Part Arrays" but "01" and "10" are not. Given Above, implement a program to return the longest "Same Value Part ...
true
12f98922c3aaeaed6e05d773976ac18892897b27
aishwarya-narayanan/Python
/Python/Turtle Graphics/turtleGraphicsAssignment.py
812
4.34375
4
import turtle # This program draws import turtle # Named constants START_X = -200 START_Y = 0 radius = 35 angle = 170 ANIMATION_SPEED = 0 #Move the turtle to its initial position. turtle.hideturtle() turtle.penup() turtle.goto(START_X, START_Y) turtle.pendown() # Set the animation speed. turtle.speed(ANIMATION_SPEED)...
true
c40cce2d02c26b5c48bbc0e8f2f6f35c702d6be2
lkogant1/Python
/while_str.py
272
4.15625
4
#strong number or not #sum of each digit factorial is equal to given number n = int(input("enter #: ")) t = n s = 0 while(n>0): d = n%10 f = 1 i = 1 while(i<=d): f = f*i i = i+1 s = s+f n = int(n/10) if(s == t): print("strong #") else: print("not a strong #")
false
a035fc1998182c99f9b9d3f6a007f023584f532e
LeviMollison/Python
/PracticingElementTree.py
2,682
4.4375
4
# Levi Mollison # Learning how to properly use the XML Tree module try: from lxml import etree print("running with lxml.etree") except ImportError: try: # Python 2.5, this is the python we currently are running import xml.etree.cElementTree as etree print("running with cElementTree ...
true
6fea835bad3e56232e2c9dfd965f8834fe1b7ceb
topuchi13/Res_cmb
/res.py
952
4.125
4
try: file = open ("./list.csv", "r") except FileNotFoundError: print ("*** The file containing available resistor list doesn't exist ***") list = file.read().split('\n') try: target = int(input("\nPlease input the target resistance: ")) except ValueError: print("*** Wrong Value Entered!!! Please enter only o...
true
224cebe24edb6007f91782c94bfbcc61210a2604
kzd0039/Software_Process_Integration
/Assignment/makeChange.py
1,261
4.15625
4
from decimal import Decimal def makeChange(amount = None): """ Create two lists: money: store the amount of the bill To perform exact calculations, multiply all the amount of bills by 1000, which should be [20,10,5,1,0.25,0.1,0.05,0.1] at first, then all the calculations ...
true
3adbd132cc9b8ebefb006fd7868a41ff1d9c485c
BadAlgorithm/juniorPythonCourse1
/BitNBites_JuniorPython/Lesson3/trafficLightProgram.py
1,292
4.3125
4
# %%%----------------Standard task------------------%%% lightColour = input("Light colour: ") if lightColour == "green": print("go!") elif lightColour == "orange": print("slow down") elif lightColour == "red": print("stop") else: print("Invalid colour (must be; red, orange or green)") # %%%------------...
true
ed993bfb13aa74509c73311863700c762421b622
clearlove-LeBron/python_work
/Python编程从入门到实践/chapter_4/numbers.py
1,057
4.28125
4
# coding=gbk # ӡֵ5 for value in range(1,5): print(value) # ʹlistɽһϵתб numbers = list(range(1,5)) print(numbers) # rangeָ # ӡ1-10ż even_numbers = list(range(2,11,2)) print(even_numbers) # һб1-10ƽ squares = [] for value in range(1,11): square = value ** 2 squares.append(square) print(squares) # ʹбʵִһ...
false
a47d166561f94e27e1759b83b6c9a62e585de59e
KevinKnott/Coding-Review
/Month 02/Week 01/Day 02/d.py
2,222
4.1875
4
# Binary Tree Zigzag Level Order Traversal: https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ # Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between). # Definition for...
true
ecd2a22e759163ce69be192752e81a19f023f98e
KevinKnott/Coding-Review
/Month 03/Week 01/Day 02/a.py
1,059
4.125
4
# Invert Binary Tree: https://leetcode.com/problems/invert-binary-tree/ # Given the root of a binary tree, invert the tree, and return its root. # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right...
true
7f886aacfb48d99bcfe6374cc0c819a24d90bc02
KevinKnott/Coding-Review
/Month 02/Week 03/Day 05/a.py
2,835
4.34375
4
# Convert Binary Search Tree to Sorted Doubly Linked List: https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/ # Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place. # You can think of the left and right pointers as synonymous to the predecessor and successo...
true
1d8e25cdf7d3725c40c4f4f156fb1e13d375ed2b
KevinKnott/Coding-Review
/Month 03/Week 03/Day 03/b.py
1,363
4.25
4
# Symmetric Tree: https://leetcode.com/problems/symmetric-tree/ # Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self...
true
53b49618af403a3a0d416f3297e7e2a9ca9db70f
KevinKnott/Coding-Review
/Month 03/Week 02/Day 06/a.py
2,135
4.15625
4
# Merge k Sorted Lists: https://leetcode.com/problems/merge-k-sorted-lists/ # You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. # Merge all the linked-lists into one sorted linked-list and return it. # This problem can be broken down into two steps one merging two separate...
true
b1e501d257b5fb3c6f9c13e3aee3d9899f93da72
beidou9313/deeptest
/第一期/杭州-冬/第二次任务/dict_eg.py
1,240
4.21875
4
#--coding:--utf-8-- #关于dict ##dict用键-值对(key-vaue)存放元素对象,通过key找到对应value,速度比较快,好比查字典 ##其中key不能重复,可以是tuple str 数字,不能是list ##value 可重复,可以是任何定义的py对象 if __name__=="__main__": dict_1={1:"a",2:"b"} #内置函数:len() str() ##len():dict长度 即key总数 print(len(dict_1)) print(dict_1) ##str():相当于在dict前后加"",以字符串方式输出di...
false
a8249f2a68300a74ad88874878844e0d3a0b9e71
beidou9313/deeptest
/第一期/广州_Cc果冻_龄/006tupleTest.py
717
4.15625
4
#coding=utf-8 if __name__ == "__main__": tuple1 = (1,2,3,4,5,6) tuple2 = ('a','b','c','d') list1 = [1,2,3,4,5,6,7] print("tuple1元组个数:") print(len(tuple1)) print("tuple1元组最大值:") print(max(tuple1)) print("tuple1元组最小值:") print(min(tuple1)) print("tuple1和tuple2合并:") print(t...
false
5632e5ddb31c6a0b3f56e1b8215b779fd6cfc425
beidou9313/deeptest
/第二期/上海_Igor/第一次任务/四则运算.py
1,304
4.3125
4
#实现一个四则运算的类,要求实现任意两个数的加减乘除运算 class Calc: # 初始化 def __init__(self, a, b): self.a = a self.b = b # 加法 def add(self): return self.a + self.b # 减法 def sub(self): return self.a - self.b # 乘法 def mul(self): return self.a * self.b # 除法 def di...
false
d8c1e84aed8f82ae5bb29c29c86161e2be7986bc
beidou9313/deeptest
/第一期/苏州-早安阳光/第2次作业/kehouxiti/009-1.py
332
4.15625
4
''' Created on 2018年1月21日 @author: 早安阳光 ''' # 循环打印练习,in、range # range(10) 转换成list(range(0,10)) for i in range(0,10): print('我爱Python') for i in list(range(0,10)): print('测试是一种挑战') for i in range(0,10,2): print('编程改变命运')
false
b74afd16bdd41c9a4a4f8fa8917c0acfd8442637
beidou9313/deeptest
/第一期/广州-33/快学python3示例练习代码/list_cut.py
694
4.15625
4
# coding = utf-8 # 列表运用python的切片机制 if __name__ == "__main__": print("列表切片的示例:") list1 = ["This", "is", "a", "sample", "for", "list"] # 读取第二个元素is,注意索引下表从0开始 e = list1[1] print("列表第二个元素是:") print(e) # 读取倒数第二个for e = list1[-2] print("列表倒数第二个元素是:") print(e) #...
false
25a5779e6803e9f2ded1321be53a5074307bd30f
beidou9313/deeptest
/第一期/深圳-大霞/Task3/第二天/day2_json.py
2,422
4.1875
4
""" json解析 JSON 语法规则:在javascript语言中,一切都是对象。因此,任何支持的类型都可以通过json来表示,例如字符串、数字、对象、数组等。 但是对象和数组是比较特殊且常用的两种类型: 对象表示为键值对 数据由逗号分隔 花括号保存对象 方括号保存数组 """ # python json解析模块 # 第一步,导入json模块 import json """ python json解析常用函数: json.dumps:将python对象编码成json字符串 json.loads:将已编码的json字符串解码为pthon对象 """ class jjson: #封装一个json函数,解析通用类 de...
false
56aeaf90cfc098a579365ed8f87809f8f9ad986e
beidou9313/deeptest
/第一期/深圳-大霞/Task2/day2_for.py
1,686
4.1875
4
""" 在Python中for循环可以遍历任何序列,例如元组、列表、字符串、字典、集合等等 for 变量 in 序列: # 代码块 else: # 代码块 # 通常情况下,我们不用else """ if __name__=="__main__": tuple1=(1,2,3,4,5,6,7,8,9,0) for t in tuple1: print(t,end=" ") print(" ") list1=[1,2,3,4,5,6,7,8,9,0] for l in list1: print(l,end=" ") print(" ...
false
13fbf1e32680e049002157b86db2899b0f87f801
beidou9313/deeptest
/第一期/广州-33/快学python3示例练习代码/tuple_sample.py
462
4.125
4
# coding=utf-8 # 内置函数用于元组 if __name__ == "__main__": tuple_demo = (1, 2, 3, 4, 5, 6, 7, 8, 9, 0) # 计算tuple_deom中元素个数 print(len(tuple_demo)) # 返回tuple_demo中最大值的元素 print(max(tuple_demo)) # 返回tuple_demo中最小值的元素 print(min(tuple_demo)) # 将list转换成元组 list = [1, 2, 3, 4, 5, 6] tuple1...
false
950021f0226231e91991a29cb3e722e79f5706af
beidou9313/deeptest
/第一期/杭州-冬/第二次任务/datetime_eg.py
1,647
4.15625
4
#--coding:utf-8- #本折是关于日期时间处理.在py的datetime包中.常见的三个处理类:date time dattime from datetime import date from datetime import time from datetime import datetime if __name__=="__main__": #date类提供日期处理 ##其类方法常有 today() ##其类属性有 max min等 实例属性有 year month day ##实例方法如 weekday() isoweekday() replace() #得到datet...
false
ea7d70f36d68d9f544b31b6e0419d643aed7826e
VEGANATO/Learned-How-to-Create-Lists-Code-Academy-
/script.py
606
4.1875
4
# I am a student trying to organize subjects and grades using Python. I am organizing the subjects and scores. print("This Year's Subjects and Grades: ") subjects = ["physics", "calculus", "poetry", "history"] grades = [98, 97, 85, 88] subjects.append("computer science") grades.append(100) gradebook = list(zip(grades...
true
2fdd7901f6ff2b80df39194d6c47e81d2e9cf9c8
dilayercelik/Learn-Python3-Codecademy-Course
/8. Dictionaries/Project-Scrabble.py
1,800
4.25
4
#Module: Using Dictionaries - Project "Scrabble" letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] #Question 1 Create a dictionary regro...
true
69c588b6f00b5cb6ce9ab31141b6f9d0e8639854
HaydnLogan/GitHubRepo
/algorithms/max_number.py
547
4.21875
4
# Algorithms HW1 # Find max number from 3 values, entered manually from a keyboard. # using built in functions # 0(1) no loops def maximum(a, b, c): list = [a, b, c] # return max(list) return max(a, b, c) # not using built in functions def find_max(a, b, c): if a > b and a > c: return a if...
true
b3fd7bfe7bf698d287bb30ce2d5e161120f83f2e
HaydnLogan/GitHubRepo
/algorithms/lesson_2/anagrams.py
1,004
4.21875
4
""" Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is another string that contains the same characters, only the order of characters can be different. For example, "abcd" and "dabc" are an anagram of each other. """ def is_anagram(s1, s2): if len(s1) ...
true
3f58e4c513b95f514573d106db25fb6edbb82f7a
yilinanyu/Leetcode-with-Python
/implementstack.py
974
4.15625
4
#push(x) -- 使用queue的push to back操作. #pop() -- 将queue中除队尾外的所有元素pop from front然后push to back,最后执行一次pop from front #top() -- 将queue中所有元素pop from front然后push to back,使用辅助变量top记录每次弹出的元素,返回top #empty() -- 使用queue的is empty操作. class Stack: # initialize your data structure here. def __init__(self): self.queue = ...
false
a6ddcc0a48091c5608ab62a905d2216b8a56944b
elOXXO/Tarea-04
/Ventadesoftware.py
2,217
4.125
4
#encoding: UTF-8 #Autor: Alberto López Reyes #Descripción: Este programa imprime el total a pagar de acuerdo a un descuento calculado basado en el número de paquetes otorgados. #Esta función calcula el descuento -también lo imprime- y cuánto se debe de pagar de acuerdo al número de paquetes otorgados. def CalcularPag...
false
a98f95088d163de04f30c58ce03e8ee770ec4a63
meagann/ICS4U1c-2018-19
/Working/Classes Practice/practice_point.py
1,302
4.375
4
""" ------------------------------------------------------------------------------- Name: practice_point.py Purpose: Author: James. M Created: 21/03/2019 ------------------------------------------------------------------------------ """ import math class Point(object): def __init__(self, x, y):...
true
5e71075642c7ed5f4315d0a0cf4192a3b76d3fe6
suryakiranmg/Hello-Python
/hellopython_4.py
1,504
4.21875
4
import random import sys import os '''Conditional Statements ----------------- if else elif == != > >= <= and or not white space used to group blocks of code -------------------------------------------''' age = 30 if age >= 21: print('You are old enough to drive a tractor trailer') elif age >= 16: ...
false
5b494b06748c5e2a319d8bcaf82668c02c7cd5cc
amdslancelot/stupidcancode
/questions/group_shifted_strings.py
1,672
4.15625
4
""" Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence: "abc" -> "bcd" -> ... -> "xyz" Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence. For...
true
eacc496766f745c8df335d462d8846427f04d229
jtambe/Python
/ArrayOfPairs.py
503
4.3125
4
# this function checks if all elements in array are paired # it uses bitwise XOR logic def IsArrayOfPairs(arr): var = arr checker = 0 for i in range(len(arr)): checker ^= ord(arr[i]) if checker == 0: print("All pairs") else: print("At least one odd entry") def main(): ...
true
3236f07ea6ae2d19f9fbaf3b219e9d6c64f1d9d8
jtambe/Python
/PyFibonacci.py
956
4.21875
4
#fibonacci series using dynamic programming # O(n) def fibonacci(length): #create array of length values = [0]*length values[0] = 0 values[1] = 1 for i in range(2,length): values[i] = values[i-1]+ values[i-2] print(values) def fiboRecursive(n): if n == 0: return 0 el...
false
f0968a9c1fbc572a482ba161d0c19d2d846d8f41
greece57/Reinforcement-Learning
/cardgame/player.py
2,346
4.25
4
""" Abstract Player """ class Player(): """ This class should not be initialized. Inherit from this to create an AI """ def __init__(self, name): """ Initialize Variables """ self.name = name self.cards = [] #inGame self.last_enemy_move = -1 self.points = 0 ...
true
b8414a54bb25b12fed98ebd497433d10eae8c591
tjnovak58/cti110
/M6T1_Novak.py
473
4.6875
5
# CTI-110 # M6T1 - Kilometer Converter # Timothy Novak # 11/09/17 # # This program prompts the user to enter a distance in kilometers. # It then converts the distance from kilomters to miles. # conversion_factor = 0.6214 def main(): kilometers = float(input('Enter the distance traveled in kilometers:'...
true
1bc7f7295f1c8ad8d8f3cf278a976cedcef64895
tjnovak58/cti110
/M2HW1_DistanceTraveled_TimothyNovak.py
581
4.34375
4
# CTI-110 # M2HW1 - Distance Traveled # Timothy Novak # 09/10/17 # # Define the speed the car is traveling. speed = 70 # Calculate the distance traveled after 6 hours, 10 hours, and 15 hours. distanceAfter6 = speed * 6 distanceAfter10 = speed * 10 distanceAfter15 = speed * 15 # Display the distance trav...
true
75e0f2685f912d3fa048ef83ecdfd0eb11dca378
NiamhOF/python-practicals
/practical-13/p13p5.py
1,073
4.46875
4
''' Practical 13, Exercise 5 Program to illustrate scoping in Python Define the function f of x: print in the function f define x as x times 5 define y as 200 define a as the string I'm in a function define b as 4 to the power of x print the values of x, y, z, a and b return x define val...
true
5e11d2d9c14c56b9ad0686eff5b6754b7989b50d
NiamhOF/python-practicals
/practical-9/p9p2.py
685
4.21875
4
''' Practical 9, Exercise 2 Ask user for a number Ensure number is positive while number is positive for all integers in the range of numbers up to and including the chosen number add each of these integers print the total of these integers ask the user to enter a number again If the number is les...
true
29856ffe797d9b60da6735c46773a9d005f7d59d
NiamhOF/python-practicals
/practical-9/p9p5.py
1,958
4.125
4
''' Practical 9, Exercise 5 Ask user for number of possible toppings Ask user for numer of toppings on standard pizza Get the number of the possible toppings minus the number of toppings on a pizza Tell the user if either number is less than 0 or if the difference is less than zero else: calculate factorial of al...
true
22cf0ac6f1532d8bce0c66d1f95201a092b3680a
NiamhOF/python-practicals
/practical-9/p9p4.py
849
4.1875
4
''' Practical 9, Exercise 4 Ask user for a number while the number is greater than or equal to 0 if the number is 0, the factorial is 1 if the number is 1, the factorial is 1 if the number is greater than 1: define fact as 1 for all numbers i of the integers from 1 to number fac...
true
7b698768332c8b9d5a78dd1baee6b3e0c0f65ac9
NiamhOF/python-practicals
/practical-2/p2p4.py
630
4.34375
4
#Practical 2, exercise 4 #Note: index starts at 0 #Note: going beyond the available letters in elephant will return an error animal='elephant' a=animal[0] b=animal[1] c=animal[2] d=animal[3] e=animal[4] f=animal[5] g=animal[6] h=animal[7] print ("The first letter of elephant is: " + a) print ("The second letter of el...
true
63f49c0b8878c2cf5871e726c2115a10acfc51c9
NiamhOF/python-practicals
/practical-18/p18p5-2.py
1,500
4.125
4
''' Practical 18, Exercise 5 alternate Define a function hasNoPrefix that takes two parameters index and s: if index is equal to zero return true else if the index position - 1 is a period return False else: return True Define a function is XYZ that takes the parameter s: assign containsXYZ th...
true
db81b3d2fc46faaf6bc940c3a8532d3fb486374d
preity788/200240126017
/biggestnumber.py
344
4.1875
4
number1 = int(input("Enter number 1: ")) number2 = int(input("Enter number 2: ")) number3 = int(input("Enter number 3: ")) if (number1>number2 ) and (number1>number3): largestNumber = number1 elif(number2>number1) and (number2>number3): largestNumber = number2 else: largestNumber = number3 print("Largest n...
false
12fd6a2bee1337443c7f2dbc7d1948aad581622c
PrimoWW/mooc
/hamming_distance.py
437
4.125
4
""" return hamming distance eg: input(1, 4) return 2 because 1(0001) 4(1000) they have two different bits. 思路很简单,python提供轮子了。xy做异或找到不相同的位,再统计1出现的个数 """ def hamming_distance(x, y): """ :param x: int :param y: int :return: int """ return bin(x ^ y).count('1') if __name__ == "__main__": x =...
false
686e88a30cbd711f849a7610e87a7be7950091d4
Irissf/Python_Inicio
/Tuplas.py
859
4.125
4
#se ejecutan más rápido que las listas #puede no llevar paréntesis, pero mejor ponerlos from typing import List tuplaEjemplo = ("Iris",22,True,'a',"Iris") print(tuplaEjemplo[:]) #convertir tupla a lista, se puede al revés miLista = list(tuplaEjemplo) print(miLista[:]) #de lista a tupla sería -> miTuple = tuple(miLi...
false
eb7d25ee8fd40c35ab061dde337f1b185b01607f
edwardmoradian/Python-Basics
/List Processing Part 1.py
290
4.1875
4
# Repetition and Lists Numbers = [8,6,7,5,3,0,9] # Using a for loop with my list of numbers for n in Numbers: print(n,"",end="") print() # Another example, list processing total = 0 for n in Numbers: Total = n + Total print ("Your total is", Total)
true
4b600ba28bb297ca75b0880b746510576afcc4d6
edwardmoradian/Python-Basics
/Read Lines from a File.py
645
4.21875
4
# read lines from a file # steps for dealing with files # 1. Open the file (r,w,a) # 2. Process the file # 3. Close the file ASAP. # open the file f = open("words.txt", "r") # process it, remember that the print function adds a newline character - two different ways to remove newline character line1 = f.r...
true
cbb70013b4ff8ee5d2218244d58d67180aa4d2d1
edwardmoradian/Python-Basics
/List Methods and Functions.py
1,735
4.59375
5
# Let's look at some useful functions and methods for dealing with lists # Methods: append, remove, sort, reverse, insert, index # Access objects with dot operator # Built-in functions: del, min, max # Append = add items to an existing list at the end of the list # takes the item you want added as an argument ...
true
dc1d00f4d881c456baff43f1a54cb24bd34392f1
Sandip-Dhakal/Python_class_files
/class7.py
824
4.1875
4
# String formating using % operator and format method # name='Sam' # age=20 # height=5.7 # txt='Name:\t'+name+"\nAge:\t"+str(age)+"\nHeight:\t"+str(height) # print(txt) # txt="Name: %s Age: %d Height: %f"%(name,age,height) # print(txt) # num=2.54 # txt="Numbers in different decimal places %f,%.1f,%.2f,%.3f"%(num,num,nu...
true
d72fb44e0d0b9d0e7fbcb16a11cb76fd9b66f605
dragonsarebest/Portfolio
/Code/5October2020.py
1,535
4.3125
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None # Function to print the list def printList(self): node = self output = '' while node != None: output += str(node.val) output += " " nod...
true
8d532130ed4482209e92f343cb947eafdd639357
francisrod01/udacity_python_foundations
/03-Use-classes/Turtle-Mini_project/drawing_a_flower.py
660
4.25
4
#!~/envs/udacity-python-env import turtle def draw_flower(some_turtle): for i in range(1, 3): some_turtle.forward(100) some_turtle.right(60) some_turtle.forward(100) some_turtle.right(120) def draw_art(): window = turtle.Screen() window.bgcolor("grey") # Create the ...
true
e8b187cf82b994c099b135796eb251459f17b1e9
Aryank47/PythonProgramming
/sanfoundary.py
377
4.125
4
# sanfoundary program to add element to a list n=int(input("Enter the no of elements to be read:")) a=[] for i in range(0,n): y=int(input("Enter the elements: ")) a.append(y) print(a) # sanfoundary program to print the multiplication table of the input number res=sum(a)/n print(res) n=int(input("Enter the numb...
true
747991d9889ebfa7f627f7a54e706e8d7ba1eaa3
AbhishekBabuji/Coding
/Leetcode/balaned_paranthesis.py
1,832
4.1875
4
""" The following contains a class and methods to check for a valid patanthesis """ import unittest class ValidParanthesis: """ The following class contains a static method to check for valid paranthesis """ def check_paran(self, input_paran): """ Args: input_paran(s...
true
4e914e273e91739c55e8f9f95532e2dcfa778e3d
ioqv/CSE
/Edgar lopez Hangman.py
1,198
4.28125
4
""" A general guide for Hangman 1.Make a word bank - 10 items 2.Pick a random item from the list 3.Hide the word (use *)4.Reveal letters already guessed 5.Create the win condition """ import string import random guesses_left = 10 list_word = ["School", "House", "Computer", "Dog", "Cat", "Eat", "Hospital", "supreme", ...
true
fbb5cf72b35858269f21e8fd8e0803ae966bc791
Crolabear/record1
/Collatz.py
1,078
4.1875
4
# goal: write a program that does the following... # for any number > 1, divide by 2 if even, and x3+1 if odd. # figure out how many steps for us to get to 1 # first try: import sys class SomeError( Exception ): pass def OneStep(number, count): #number = sys.argv[0] if type(number) is int: if number...
true
1540db701ceb4907f050bef4dd59922ddd8d3e44
connorhouse/Lab4
/lists.py
1,855
4.1875
4
stringOne = 'The quick brown fox jumps over the lazy dog' print(stringOne.lower()) def getMostFrequent(str): NO_OF_CHARS = 256 count = [0] * NO_OF_CHARS for i in range(len(str)): count[ord(str[i])] += 1 first, second = 0, 0 for i in range(NO_OF_CHARS): if count[i] < count[first...
true
2bac1697c0a3d09092b86088c84ba7e7418094e3
Dipeoliver/python_class
/estrutura_controle_projetos/Class_93_Fibo.py
529
4.25
4
#!/usr/local/bin/python3 # fibonacce -- sequencia de numeros somados ao seu antecessor. # exemplo # 0, 1, 1, 2, 3, 5, 8, 13, 21 ... # vou determinar a quantidade de repetições que quero def fibonacci(quantidade): resultado = [0, 1] for i in range(2, quantidade): resultado.append(sum(resultado[-2:])) ...
false
71a8b714ed0be13af16a9ec2f62360a62c5c6593
Dipeoliver/python_class
/Fundamentos/Class_46_Listas.py
431
4.34375
4
# tupla e uma estrutura indexada lista=[1,2,3,4,5,6,7,8] print(lista) print(lista[::-1]) # inverter a lista lista.append(1) # adiciona itens na lista lista.append(5) # adiciona itens na lista print(lista) nova_lista = [1,5,'Ana', "bia"] # lista pode ser hetereogenia print (nova_lista) nova_lista.remove(5) # r...
false
1a064c17ae1d941a9a055ad6c768d4ea78e7f9dc
anishverma2/MyLearning
/MyLearning/Advance Built In Functions/useofmap.py
510
4.6875
5
''' The map function is used to take an iterable and return a new iterable where each iterable has been modified according to some function ''' friends = ['Rolf', 'Fred', 'Sam', 'Randy'] friends_lower = map(lambda x: x.lower(), friends) friends_lower_1 = (x.lower for x in friends) #can also be used as a generator ...
true
f656b8af133e150be6ee518d0528122a399afbc7
DanaSergali/kili
/bonus/4.py
428
4.1875
4
print("Кирпичный язык это..") letters=set("ЁУЕЫАОЭЯИЮёуеыаоэяию") word=input("Введите слово или фразу, и прога переведет его на «кирпичный язык: ") for letter in letters: word=word.replace(letter,letter+"c"+letter) #replace заменяет все вхождения одной строки на другую print(word)
false
646bf608be98acbf0b0f8d14501c8c0549fe71e5
laboyd001/python-crash-course-ch6
/people.py
743
4.3125
4
# add 3 dictionaries of people. loop through the list. print everything you know abou the person. people = { 'person1': { 'first_name': 'jenn', 'last_name': 'kuhlman', 'city': 'nashville', }, 'person2': { 'first_name': 'kathy', 'last_name': 'boyd', ...
false
b0cd65ee2540ec7abbece259639628d808672c81
brianjgmartin/codingbatsolutions
/String-1.py
1,158
4.1875
4
# Solutions to Python String-1 # Brian Martin 14/04/2014 # Given a string name, e.g. "Bob", return a greeting of the form "Hello Bob!". def hello_name(name): return "Hello " + name + "!" # Given two strings, a and b, return the result of putting them together in # the order abba, e.g. "Hi" and "Bye" returns "Hi...
true
7db18f6d7a61e5a2d802a5a417e5dbfc0acd6a6a
mcgarry72/mike_portfolio
/knights_tour_problem.py
2,595
4.125
4
# this is an example recursion problem # classic: given a chessboard of size n, and a starting position of x, y # can the knight move around the chessboard and touch each square once import numpy as np def get_dimension_input(): cont_processing = True have_received_input = False while not have_received_i...
true
a4511d2618f04c1f44b75c855c24fd051a97346d
HidoiOokami/Projects-Python
/Basico/String.py
742
4.15625
4
''' String ''' nome = "Ana Paula" nome[0] # Tras A nome[6] # Tras u nome[-3] # Tras Au começa de tras para frente nome[4:] # Começando apartir do 4 Paula nome[-5:] # Começa de tras para frente tras Paula também nome[:3] # Começa do 3 mas ele mesmo não conta tras Ana indice 0 1 e 2 nome[2:5] #tras a P porque o 5 não...
false
06bc5434592a0904879bba3ca8aeeb9eb17d3990
HidoiOokami/Projects-Python
/Funcoes/packing.py
749
4.125
4
#Retornando lista e Dicionarios de uma função # poderia passar da seguinte forma """ nums = (1,2,3) # poderia ser uma lista print(soma(*nums)) #Nesse caso iria desempacotar e somar a tupla para passar os dados """ def soma(*numeros): #Como aqui espera uma tupla empacotamento soma = 0 for n in numeros: ...
false
bac727960b8e93f16d210ebc60dae8e576e8aa10
Andida7/my_practice-code
/45.py
2,148
4.46875
4
"""Write a program that generates a random number in the range of 1 through 100, and asks the user to guess what the number is. If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the program should display “To...
true
164a205f30278d2ca0e01cb7e38f8fd39f481ec8
JeffGoden/HTSTA2
/python/homework 1-8/task3.py
742
4.21875
4
number1= int(input("Enter 1 number")) number2= int(input("Enter a 2nd number")) if(number1 == number2): print("Its equal") else: print("Its notr equal") if(number1!= number2): print("Its not equal") else: print("its equal") if(number1>number2): print("number 1 is greater than number 2") else: p...
true
2f5befb1e3213da290381566175cf6e63a1f735b
DeenanathMahato/pythonassignment
/Program4.py
593
4.28125
4
# Create a program to display multiplication table of 5 until the upper limit is 30 # And find the even and odd results and also find the count of even or odd results and display at the end. (using do while loop,for loop,while) # 5 x 1 = 5 # 5 x 2 = 10 # 5 x 30 = 150 e= [] o= [] for a in range(1,31): if (a*5)%2==0:...
true
c317b5a617d4c84d83762e8f6eafe87995ad9fba
velicu92/python-basics
/04_Functions.py
1,301
4.21875
4
############################################################################## ####################### creating a basic Function ########################## ############################################################################## def sumProblem(x, y): sum = x + y print(sum) sentence = 'Th...
true
d163ea2611bfefb44382b904d0ae992e22ca1b52
nishantchy/git-starter
/dictionary.py
487
4.3125
4
# accessing elements from a dictionary new_dict = {1:"Hello", 2:"hi", 3:"Hey"} print(new_dict) print(new_dict[1]) print(new_dict.get(3)) # updating value new_dict[1] = "namaste" print(new_dict) # adding value new_dict[4] = "walla" print(new_dict) # creating a new dictionary squares = {1:1, 2:4, 3:9, 4:16, 5:25} print(...
true
55becfe8359b724322ec2693f382a4096150efd5
NatSuraden/Problem-Solving-01
/3D/3.py
278
4.125
4
def reverse_while_loob(s): sl = " " length = len(s)-1 while length >= 0: sl = sl+s[length] length = length-1 return sl input_str = "INE-KMUTNB" if __name__ == "__main__": print('Reverse String using for loob =',reverse_while_loob(input_str))
false
c0ca1b30858f14f0ce0ef5d1ca63ff293936a4b4
allenabraham999/Bubble-sort
/bubble sort.py
789
4.21875
4
# bubble sort import random def bubble_sort(arr): length = len(arr) for j in range(length): for i in range(1, length): if arr[i - 1] > arr[i]: temp = arr[i - 1] arr[i - 1] = arr[i] arr[i] = temp print(f"array after {j} sor...
false
36fe9d6331cbba021979ee032d176fb6b000436e
Syldori/modulo2_0
/02 - Funciones.py
1,224
4.34375
4
''' Funciones: -bloque de código al que le hemos puesto un nombre y unos parámetros (que pueden ser de distintos tipos) (devuelve un resultado) -Tipos: -primera clase: son aquellas que pueden trabajrse con ellas como con los valores/son equivalentes a los datos > es decir pueden asignarse, meterse en funciones, pa...
false
376f4ec3b329664db6648f5ea0cb81f219215ad4
feihu-jun/beginning
/autohello.py
324
4.21875
4
#自动给输入姓名的人hello程序01# name = input ('please enter your name:') print('\n' * 5) print('heelo,',name) print('\n' * 2)#此处可以写成 n=5 | print ('\n'*n) input('enter to <close>')#为了解决直接闪退设置的。还可以raw_input() 随机输入的意思。因为python运行完就直接关闭了
false
9ed6b0d01e7e6329a7bf8e04ac10e426175b91f2
Rafaelbarr/100DaysOfCodeChallenge
/day018/001_month_number.py
2,320
4.15625
4
# -*- coding: utf-8 -*- def run(): # Variable declaration months = 'JanFebMarAprMayJunJulAugSepOctNovDec' done = False # Starting the main loop while done == False: # Ask the user for a numeric input of a number month_number = int(raw_input('Enter the number of a month ...
true
ccb9b7391c5237afac9114c268bf44c68f7ca450
lubing1101/brandon
/040.py
561
4.25
4
#!/usr/bin/python # -*- coding: UTF-8 -*- counter = 100 # 赋值整型变量 miles = 1000.0 # 浮点型 name = "John" # 字符串 print counter print miles print name print '------+++++++' #!/usr/bin/python # -*- coding: UTF-8 -*- str = 'Hello World!' print str # 输出完整字符串 print str[0] # 输出字符串中的第一个字符 print str[2:5] # 输出字符串中第三个至第五个之间的字符串 pr...
false
33607951f930f0bc40e7b3dbf5b14f081507a695
ferry-luo/ferry_pycharm_projects
/ferry_devel/views/practice/类型转换.py
1,311
4.1875
4
#encoding:utf-8 #Python字典、列表、字符串之间的转换 #1.列表与字符串转换 #列表转字符串: x = ['a','b','c'] s = ''.join(x) print(str(x)) print(s) #字符串转列表: s = "['a','b','c']" x = eval(s) #eval()函数用来执行一个字符串表达式,并返回表达式的值。 print(x) #2.列表与字典转换 #两个列表转成字典 x1 = ['a','b','c'] x2 = [1,2,3] x3 = zip(x1,x2) #zip返回 打包为元组的列表,如[('a',1),('b',2),('c',3)] print(x3) ...
false
16ff87190cf9599da27b7dc5e912cb376959f1e4
the-mba/progra
/week 5/exercise4.py
520
4.3125
4
valid = False number_of_colons = 0 while not valid: attempt = input("Please enter a number: ") valid = True for c in attempt: if c == '.': number_of_colons += 1 elif not c.isdigit(): valid = False break if number_of_colons > 1: valid = False ...
true
e203bc43e7d2fac93785b8ad563c742084e80a6b
Dave-dot-JS/LPHW
/ex15.py
376
4.125
4
from sys import argv script, filename = argv # opens the specific file for later use txt = open(filename) # reads the designated file print(f"Here's your file {filename}:") print(txt.read()) # re-takes input for file name to open print("Type the filename again:") file_again = input("> ") # opens new file txt_again = o...
true
1e2ea00b37d89d7763805e8a7a0a57c2f1da7d3d
Socialclimber/Python
/Assesment/untitled.py
1,684
4.1875
4
def encryption(): print("Encription Function") print("Message can only be lower or uppercase letters") msg = input("Enter message:") key = int(input("Eneter key(0-25): ")) encrypted_text = "" for i in range(len(msg)): if ord(msg[i]) == 32: #check if char is a space encrypted_text += chr(ord(msg[i])) # cocnca...
true
50a092982e0f3182094714e2c3cf565226545900
jerster1/portfolio
/class2.py
1,080
4.28125
4
#lesson 1 #firstName = raw_input("what is your name? ") #lasttName = raw_input("what is your last name? ") #address = raw_input("what is your address? ") #phonenumber = raw_input("what is your phone number? ") #age = input("How old are you? ") # #lesson 2 #firstname = raw_input("what is ur name? ") # #print "...
true
925a2c4ad9b411c4da3704b21792a5e33a024e4d
bmarco1/Python-Journey
/yup, still going.py
1,117
4.21875
4
def build_person(first_name, last_name): """Return a dictionary of information about a person.""" person = {'first': first_name, 'last': last_name} return person musician = build_person('jimi', 'hendrix') print(musician) print("\n") def build_person(first_name, last_name, age=''): """Return...
true
a702d1f6fe1d827965529dd0fe6a6abbdbf24f7b
marianopettinati/test_py_imports
/car.py
2,303
4.46875
4
class Car(): """A simple attemp to represent a car.""" def __init__(self, make, model, year): """Initialize attributes to describe a car.""" self.marca = make self.modelo = model self.año = year self.odometro = 0 def get_descriptive_name(self): """Return a n...
true
45322acef06cfee51721433fb4f101e46cb96458
dtheekshanalinux/rock_paper_scissor_game
/rps.py
982
4.21875
4
# import the random module to create the random numbers # Hellow world while(True): import random # gui for user interface print("you have three choices they are") print("rock paper scissors") # variables c_won = "computer won!" u_won = "Congratulation you won!" # assign computer choices...
false
617cab393cb8f65cb4f60fb554452b00ef99f78e
Artimbocca/python
/exercises/python intro/generators/exercises.py
865
4.21875
4
# Write an infinite generator of fibonacci numbers, with optional start values def fibonacci(a=0, b=1): """Fibonacci numbers generator""" pass # Write a generator of all permutations of a sequence def permutations(items): pass # Use this to write a generator of all permutations of a word def w_perm(w): ...
true
42a836d108a4933a59e3609c40d2502919b18f11
Artimbocca/python
/exercises/python intro/google/calculator.py
657
4.4375
4
# You can use the input() function to ask for input: # n = input("Enter number: ") # print(n) # To build a simple calculator we could just rely on the eval function of Python: # print(eval(input("Expression: "))) # e.g. 21 + 12 # Store result in variable and it can be used in expression: while True: exp = input...
true
f5185b0c3426961a3577c5a8aca34a1de250f50d
KAZURYAN/python-study-0
/study_four/kadai1.py
1,242
4.15625
4
### 商品クラス class Item: def __init__(self,item_code,item_name,price): self.item_code = item_code self.item_name = item_name self.price = price def get_price(self): return self.price ## オーダークラス class Order: def __init__(self,item_master): self.item_order_list = [] ...
false
9483b859d50c28ecf5c0edaf4114a63b111eab8c
francisaddae/PYTHON
/FillBoard.py
2,322
4.4375
4
# NAME OF ASSIGNMENT: To display a tic-tac-toe borad on a screen and fill the borad with X # INPUTS: User inputs of X's # OUTPUTS: Tic-Tac-Toe board with X # PROCESS (DESCRIPTION OF ALGORITHM): The use of nested for loops and while loops. # END OF COMMENTS # PLACE ANY NEEDED IMPORT STATEMENTS HERE: import string imp...
true
649392e5c71d432b2c6dfb738f76bed0c4b90c42
J4rn3s/Assignments
/MidtermCorrected.py
2,166
4.375
4
################################################################# # File name:CarlosMidterm.py # # Author: Carlos Lucio Junior # # Date:06-02-2021 # # Classes: ITS 220: Programming Languages & Concept...
true