blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
bfa4cd171831f50848856dd016fb4fdf0461bc47
davidjeet/Learning-Python
/PythonHelloWorld/MoreLists 2/MoreLists_2.py
948
4.125
4
z = 'Demetrius Harris' for i in z: print(i,end = '*') print() eggs = ('hello', 323, 0.5) print(eggs[2]) #eggs[1] = 400 # illegal #converting tuple to list a = list(eggs) a[1] = 500 b = tuple(a) print(b) spam = 42 cheese = 100 print(spam) print(cheese) #different than spam, because by-value spam = [0,1,2,3,4,5] c...
true
1c7472684b1621d64c77426d62733997f027b60d
LFValio/aprendendo-vetores
/vetores-aprendendo/ex-03.py
625
4.125
4
# Exercício 3: ler vários nomes mas só armazenar aqueles que começam com C. nome = [] cNome = 0 # contagem nome sNome = [] # string nome for x in range(1, 6): nome.append(str(input(f"{x}º Nome: "))) for x in nome: # varrerá o vetor nome, verificando todas as palavras que con...
false
aa1d86e1bd876632b1db4d2d5f9381a162db051f
wavecrasher/Turtle-Events
/main.py
416
4.21875
4
import turtle turtle.title("My Turtle Game") turtle.bgcolor("blue") turtle.setup(600,600) screen = turtle.Screen() bob = turtle.Turtle() bob.shape("turtle") bob.color("white") screen.onclick(bob.goto) #bob.ondrag(bob.goto) screen.listen() #The pattern above consists of circles drawn repeatedly at different angles -...
true
b9bc55c14baaf0d0f11234c3c8593fe4b5a4ba47
Benzlxs/Algorithms
/sorting/merge_sort.py
1,103
4.125
4
# merge sortting https://en.wikipedia.org/wiki/Merge_sort import os import time def merge(left, right): # merging two parts sorted_list = [] left_idx = right_idx = 0 left_len, right_len = len(left), len(right) while (left_idx < left_len) and (right_idx < right_len): if left[left_idx] <=...
true
cac68f6a0cb20080f211d0c83f6482a2827f60c7
Benzlxs/Algorithms
/sorting/selection_sort.py
784
4.40625
4
# merge sortting https://en.wikipedia.org/wiki/Selection_sort # time complexity is O(n^2) import os import time def selection_sort(list_nums): for i in range(len(list_nums)): lowest_value_index = i # loop through unsorted times for j in range(i+1, len(list_nums)): if list_nu...
true
251b46112a4ba9c6983a3baa6545bd2f47a10edb
PersianBuddy/emailsearcher
/main.py
1,039
4.25
4
#! Python 3 # main.py - finds all email addresses import re , pyperclip # user guid print('Copy your text so it saves into clipboard') user_response = input('Are you ready? y=\'yes\' n=\'no\' :') while str(user_response).lower() != 'y': user_response = input("Make sure type 'y' when you copied your desired text :...
true
7ce7b8965c78c0e772953895bc81b4bd9023f15a
pezLyfe/algorithm_design
/intro_challenges/max_pairwise_product_2.py
615
4.15625
4
# Uses python3 ''' The starter file provided by the course used nested for loops to calculate the solution as a result, the submission failed due to an excessive runtime. The list.sort() method in python works really fast, so use that to order the list and then multiply the largest entry in the list by the second large...
true
d5af7c56bda22cef4a6855838d23b33ade9ef340
WilliamMcCann/holbertonschool-higher_level_programming
/divide_and_rule/h_fibonacci.py
520
4.21875
4
'''prints out the Fibonacci number for a given input''' import threading class FibonacciThread(threading.Thread): def __init__(self, number): threading.Thread.__init__(self) try: val = int(number) except ValueError: print("number is not an integer") self.numb...
true
5ed3875dee928cc5a1b65ad7d9f1f582e2358660
ShruKin/Pre-Placement-Training-Python
/WEEK-3/1.py
215
4.625
5
# 1. Write a python program to check if a user given string is Palindrome or not. n = input("Enter a string: ") if(n == n[::-1]): print("Its a palindrome string") else: print("Its not a palindrome string")
true
9663393bb56c77a277bc1b62c44a3c6ae3b8b4ee
ShruKin/Pre-Placement-Training-Python
/WEEK-3/2.py
364
4.46875
4
# 2. Write a python program to take Firstname and lastname as input. # Check whether the first letter of both strings are in uppercase or not. # If not change accordingly and print reformatted string. fn = input('Firstname: ') ln = input('Lastname: ') if not fn[0].isupper(): fn = fn.title() if not ln[0].isupper(...
true
ceaf2f949eb9840fbeed64d74c0cd37b808f5816
kb7664/Fibonacci-Sequence
/fibonacciSequence.py
673
4.3125
4
############################## # Fibinacci Sequence # # Author: Karim Boyd ############################## # This program demonstrates one of the many ways to build the Fibonacci # sequence using recursion and memoization # First import lru_cache to store the results of previous runs to # memory from functools i...
true
d48b59a7708afea878e06c1d910ff304e2772316
hintermeier-t/projet_3_liberez_macgyver
/graph/maze.py
1,601
4.125
4
# -*coding: UTF-8-* """Module containing the MazeSpriteClass.""" import pygame as pg from . import gdisplay class MazeSprite (pg.sprite.Sprite): """Class displaying the maze sprite. Gathering all we need to display the walls sprites, and the path sprites. (position, source picture etc...). Inherit ...
true
be80b0aea58b2005699f667c15102be2d2398d42
riaz4519/python_practice
/programiz/_6_list.py
922
4.375
4
#list #create list myList = [5,6,7,8] print(myList) #mixed data type list myList = [5,8,'data',3.5] print(myList) #nested list myList = ['hello',[5,6]] print(myList) #accessing the list myList = ['p','r','o','b','e'] #by index print(myList[0]) #nested n_list = ["Happy", [2,0,1,5]] print(n_list[1][1]) print(n...
true
7be5d30cda7b2fea9dda47792dd011c530ebe639
riaz4519/python_practice
/problem_solving/_4_swap_case.py
305
4.15625
4
def swap_case(s): new_string = "" for lat in s: if lat.isupper() == True: new_string += (lat.lower()) else: new_string += (lat.upper()) return new_string if __name__ == '__main__': s = input().strip() result = swap_case(s) print(result)
false
51eb5831e885cff30bdefa175b7ba153222156ac
CupidOfDeath/Algorithms
/Bisection Search.py
402
4.15625
4
#Finding the square root of a number using bisection search x = int(input('Enter the number which you want to find the square root of: ')) epsilon = 0.01 n = 0 low = 1 high = x g = (low+high) / 2 while abs(g*g-x) >= epsilon: if (g*g) > x: high = g elif (g*g) < x: low = g g = (low+high) / 2 n += 1 print('The ...
true
42a8dcd380e302595f43a72bea8eb5c0c0a1fff3
mightymax/uva-inleiding-programmeren
/module-1-numbers/sequence.alt.py
1,530
4.25
4
highestPrime = 10000 number = 1 #Keep track of current number testing for prime nonPrimes = [] while number < highestPrime: number = number + 1 if (number == 2 or number % 2 != 0): #test only uneven numbers and 2 #loop thru all integers using steps of 2, no need to test even numbers for x in ra...
true
0bca3a56b899c73b9f63201d6eb1cb0070976972
lasj00/Python_project
/OOP.py
1,965
4.1875
4
import math class Rectangle: # the init method is not mandatory def __init__(self, a, b): self.a = a self.b = b # self.set_parameters(10,20) def calc_surface(self): return self.a * self.b # Encapsulation class Rectangle2(): def __init__(self, a, b): self.__...
true
36b585cb0372c121c7307bb04ecc3a1b220ad0a6
lasj00/Python_project
/abstract.py
917
4.59375
5
from abc import ABC import math # by inheriting from ABC, we create an abstract class class Shape(ABC): def __init__(self, a=0, b=0): self._a = a self._b = b def get_a(self): return self._a def get_b(self): return self._b def __str__(self): return "{0}: [{1},...
false
b451055efe0de3395b4c49beb4d67ee77694bece
KaylaBaum/astr-119-hw-1
/variables_and_loops.py
706
4.375
4
import numpy as np #we use numpy for many things def main(): i = 0 #integers can be declared with a number n = 10 #here is another integer x = 119.0 #floating point nums are declared with a "." #we can use numpy to declare arrays quickly y = np.zeros(n,dtype=float) ...
true
5fd79aec14f570b55d10153e52c7d67e751d5877
ch1huizong/study
/lang/py/cookbook/v2/19/merge_source.py
1,096
4.1875
4
import heapq def merge(*subsequences): # prepare a priority queue whose items are pairs of the form # (current-value, iterator), one each per (non-empty) subsequence heap = [] for subseq in subsequences: iterator = iter(subseq) for current_value in iterator: # subseq is not empty, therefor...
true
c7c2681a6ca8de03dc17e2fc584bc5a85db1de04
Jasbeauty/Learning-with-Python
/assn0/test3.py
2,967
4.1875
4
# -*- coding=utf-8 -*- # 获取对象信息 class MyObject(object): def __init__(self): self.x = 9 def power(self): return self.x * self.x obj = MyObject() print('hasattr(obj, \'x\') =', hasattr(obj, 'x')) # 有属性'x'吗? print('hasattr(obj, \'y\') =', hasattr(obj, 'y')) # 有属性'y'吗? setattr(obj, 'y', 19) # 设...
false
dec5ec698cc7d469dfbb97cebdc485e9603fc16e
luandeomartins/Script-s-Python
/ex028.py
810
4.28125
4
from math import radians,cos,sin,tan angulo = float(input('Digite um ângulo qualquer: ')) seno = sin(radians(angulo)) cosseno = cos(radians(angulo)) tangente = tan(radians(angulo)) print('O ângulo de {} tem o seno de {:.2f}.'.format(angulo, seno)) print('O ângulo de {} tem o cosseno de {:.2f}.'.format(angulo, cosseno))...
false
5afb03eae042cc84d9c770e3153fa07d12884906
shashikant231/100-Days-of-Code-
/Pascal Traingle.py
938
4.1875
4
'''Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Input: numRows = 5 Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] solution We are first creating an 2D array .our array after creatio...
true
6763a48aa0e4c976e75b68ae74f18394512b1e85
DrN3RD/PythonProgramming
/Chapter 3/c03e01.py
378
4.34375
4
#Volume calculator from math import * def main(): r = float(input("Enter the radius of the shpere to be calculated: ")) volume = (4/3)*pi*(r**3) area = 4*pi * r**2 print("The area of the Shpere is {0:0.1f} square meters ".format(area)) print("\n The Volume of the sphere is {0:0.1f} cubic m...
true
1ae36388c286daad1d37d101d9ca05db4bd7384a
mamatha20/ifelse_py
/IF ELSE_PY/if else4.py
276
4.34375
4
#write a program to check whethernit is alphabet digit or special character ch=input("enter any character=") if ch>="a" and ch<="z" or ch>="A" and ch<="Z": print("it is alphabet") elif ch>="0" and ch<="9": print("it is digit") else: print("it is special charcter")
true
75c9868ff8d055492da5bb749b20d5a919a440e8
mamatha20/ifelse_py
/IF ELSE_PY/if else25.py
658
4.125
4
day=input('enter any day') size=input('enter any size') if day=='sunday': if size=='large': print('piza with free brounick') elif size=='medium': print('piza with free garlick stick') else: print('free coca') elif day=='monday' or day=='tuesday': if size=='large': print('pizza with 10%discount') elif size=...
true
a566f238d1a9cc97699986160a108e3c9e88cbd5
yameenjavaid/bigdata2019
/01. Jump to python/Chap07/3_Python_Exercise/21.py
281
4.21875
4
import re # Write a Python program to find the substrings within a string. while True : original_setence = input("입력하세요 : ") if original_setence == "ㅈㄹ" : exit() m = re.findall("exercises", original_setence) for i in m : print(i)
true
9d6ea6b45c26fccabafd08a13e39d54ce906f918
yameenjavaid/bigdata2019
/01. Jump to python/Chap07/3_Python_Exercise/18.py
342
4.40625
4
import re # Write a Python program to search the numbers (0-9) of length between 1 to 3 in a given string. p = re.compile(r"([0-9]{1,3})") while True : original_setence = input("입력하세요 : ") if original_setence == "ㅈㄹ" : exit() m = p.finditer(original_setence) for i in m : print(i.gr...
true
29e8979d532b3060ed5a15ab0fd7971108987ce5
SKO7OPENDRA/python_start
/Урок 2. Переменные, ветвления/hw_02_01.py
830
4.15625
4
def lesson2(): print("Great Python Program!") print("Привет, программист!") name = input("Ваше имя: ") print(name, ", добро пожаловать в мир Python!") answer = input("Давайте поработаем? (Y/N)") # PEP-8 рекомендует делать отступ, равный 4 пробелам if answer == 'y' or answer == 'Y': ...
false
8822adfd5f0a1d8732e8fa92f0834af2de2764e2
shaheenery/udacity_ds_and_a_project2
/problem_5.py
2,548
4.375
4
# Blockchain # A Blockchain is a sequential chain of records, similar to a linked list. Each # block contains some information and how it is connected related to the other # blocks in the chain. Each block contains a cryptographic hash of the previous # block, a timestamp, and transaction data. For our blockchain we w...
true
efce9bd907d2493ea03807cd09ef298ac5facf58
zoecahill1/pands-problem-set
/collatz.py
1,060
4.34375
4
# Zoe Cahill - Question 4 Solution # Imports a function from PCInput which was created to handle user input from PCInput import getPosInt def collatz1(): # Calls the function imported above # This function will check that the number entered is a positive integer only num = getPosInt("Please enter a posit...
true
f9dfbf8b29d1a1673076aa512e2d89653af38b6a
codeshef/SummerInternship
/Day5/classesPython.py
483
4.125
4
# <------- Day 8 work -------> # classes in python class User: def __init__(self): print("Hello!! I am constructor of class user") def setUserName(self, fn, ln): print("I am inside setUserNameFunc") self.firstName = fn self.lastName = ln def printData(self): p...
true
bc502be94ca45d1750cce48ca3c39f0eb9dd389c
dergaj79/python-learning-campus
/unit5_function/test.py
959
4.125
4
# animal = "rabbit" # # def water(): # animal = "goldfish" # print(animal) # # water() # print(animal) # a = 0 # # # def my_function() : # a = 3 # print(a) # # # my_function() # print(a) # a=1 # def foo1(): # print(a) # foo1() # print(a) # def amount_of_oranges(small_cups=20, large_cups=10): # ...
true
9f8220cbed18b0e05822ae99a652b649c682b08f
sandeeppal1991/D08
/mimsmind0.py
2,527
4.5625
5
"""In this version, the program generates a random number with number of digits equal to length. If the command line argument length is not provided, the default value is 1. Then, the program prompts the user to type in a guess, informing the user of the number of digits expected. The program will then read the user in...
true
3adcd38f83d45e722077960cf50aaf3c435572ea
kncalderong/codeBackUp
/python/Rosalind_programming/stronghold/dna_as_rna.py
305
4.3125
4
dna=input('please enter your DNA sequence: ') rna=list() #!string to print a list as a string after.. string="" for nt in dna: if nt == 'T': rna.append('U') else: rna.append(nt) print('dna:',dna) #!with .join() I can print a list as a string: print('rna:', string.join(rna))
false
46888f48af85aa51067e50b537e670510dad01c8
asuddenwhim/DM
/own_text.py
776
4.125
4
from nltk import word_tokenize, sent_tokenize text = "Generally, data mining (sometimes called data or knowledge discovery) is the process of analyzing data from different perspectives and summarizing it into useful information - information that can be used to increase revenue, cuts costs, or both. Data mining softwa...
true
1e7db90033a0f66814ddd3eada5fbaf26424755d
rashedrahat/wee-py-proj
/hangman.py
1,407
4.25
4
# a program about guessing the correct word. import random i = random.randint(0, 10) list = [["H*ng*a*", "Hangman"], ["B*n**a", "Banana"], ["*wk*ar*", "Awkward"], ["B*n**", "Banjo"], ["Ba*pi*e*", "Bagpipes"], ["H*p**n", "Hyphen"], ["J*k*b*x", "Jukebox"], ["O*y**n", "Oxygen"], ["Num*sk*l*", "Numbskull"], ["P*j*m*...
true
6a2aad8c018ac579ba11c1ac1d7405e03950bf16
jslee6091/python_basic
/exercise/age_student.py
348
4.21875
4
# age = now year - born year +1 from datetime import datetime as dt current = dt.today().year print(current) my_year = int(input()) print(type(my_year)) age = current - my_year + 1 if 17 <= age < 20: print('you are high school student!') elif 20 <= age <= 27: print('you are university student!') else: pr...
false
ae8899b2735de9b712b11e1e20f95afcd5008be2
erikac613/PythonCrashCourse
/11-1.py
483
4.15625
4
from city_functions import city_country print("Enter 'q' at any time to quit.") while True: city = raw_input("\nPlease enter the name of a city: ") if city == 'q': break country = raw_input("Please enter the name of the country where that city is located: ") if country == 'q': ...
true
3e8767209a85af8982664909ec45c948c95eafb3
alridwanluthfi00/Labpy
/Lab 4/Syntax/Latihan 1.py
738
4.125
4
# list bebas a = [2, 4, 6, 8, 10] # akses list print(a[2]) # tampilkan elemen ke - 3 print(a[1:4]) # ambil nilai elemen ke - 2 sampai ke - 4 print(a[4]) # ambil elemen terakhir print('==================================================') # ubah elemen list a[3] = 12 # ubah elemen ke 4 nilai lainnya print(a) a[3:5]...
false
6db90e6de92dc5a3ca12f22a6e94577abd42a6c1
gungorefecetin/CS-BRIDGE-2020
/Day3PM - Lecture 3.1/khansole_academy.py
1,021
4.375
4
""" File: khansole_academy.py ------------------- This program generates random addition problems for the user to solve, and gives them feedback on whether their answer is right or wrong. It keeps giving them practice problems until they answer correctly 3 times in a row. """ # This is needed to generate random numb...
true
52963e18085b20a2f20020a0093b01ea26e34e0c
LucianoAlbanes/AyEDI
/TP1/Parte1/1/restrictions.py
250
4.125
4
## The purpose of the following code is to have certain functions ## that python provides, but they are restricted in the course. # Absolute Value (Aka 'abs()') def abs(number): if number < 0: return number*-1 else: return number
true
6735f531a626eb2dd8999e26136e950299a978d4
LucianoAlbanes/AyEDI
/TP6/1/fibonacci.py
1,058
4.25
4
# Calc the n-th number of the Fibonacci sequence def fibonacci(n): ''' Explanation: This function calcs and return the number at a given position of the fibonacci sequence. Params: n: The position of the number on the fibonacci sequence. Return: The number at the given position ...
true
c828a8ab988f60b7a7c73a79ca678e5d7264415e
navbharti/java
/python-cookbook/other/ex7.py
2,366
4.1875
4
''' Created on Sep 19, 2014 @author: rajni ''' months = ('January','February','March','April','May','June',\ 'July','August','September','October','November',' December') print months cats = ['Tom', 'Snappy', 'Kitty', 'Jessie', 'Chester'] print cats #fetching items from tupble and list print cats[2] print months[2]...
true
7357beca1c38efca4e040d1ade5fc2275e658942
nemeth-bence/exam-trial-basics
/pirates/pirates.py
775
4.25
4
pirates = [ {'Name': 'Olaf', 'has_wooden_leg': False, 'gold': 12}, {'Name': 'Uwe', 'has_wooden_leg': True, 'gold': 9}, {'Name': 'Jack', 'has_wooden_leg': True, 'gold': 16}, {'Name': 'Morgan', 'has_wooden_leg': False, 'gold': 17}, {'Name': 'Hook', 'has_wooden_leg': True, 'gold': 20}, ] # Write a fun...
false
fc7dd582f1d3fcff14bd071ddf53081faa20488a
mrmezan06/Python-Learning
/Real World Project-2.py
364
4.25
4
# Design a program to find avarage of three subject marks x1 = int(input("Enter subject-1 marks:")) x2 = int(input("Enter subject-2 marks:")) x3 = int(input("Enter subject-3 marks:")) sum = x1 + x2 + x3 avg = sum / 3 print("The average marks:", int(avg)) print("The average marks:", avg) # Formatting the float value pri...
true
c765b56d4d457bd428b05d59a0c882ccf7325910
kkkansal/FSDP_2019
/DAY 02/pangram.py
956
4.21875
4
""" Code Challenge Name: Pangram Filename: pangram.py Problem Statement: Write a Python function to check whether a string is PANGRAM or not Take input from User and give the output as PANGRAM or NOT PANGRAM. Hint: Pangrams are words or sentences containing every letter of the alphabet at ...
true
5528f3822a981c88f14222da69060e68581dd6dd
matheusCalaca/estudos-python-alura
/str_metodos/forca.py
1,494
4.25
4
# para definir uma funcao no python voce usa a palavra "def" segue o examplo encapsulando o jogo em uma função para ser # chamado em outro arquivo def jogar(): print("********************************") print("***Bem vindo ao jogo de Forca***") print("********************************") #variaveis palavra_se...
false
0e58b02c59fe57bf55e8c1c61a0442f35146876f
dev-di/python
/helloworld.py
323
4.1875
4
#name = input("What is your name my friend? ") name = "Diana" message = "Hello my friend, " + name + "!" print(message) #comment print(message.upper()) print(message.capitalize()) print(message.count("i")) print(f"message = '{message}', name = '{name}'") print("Hello {}!!".format(name)) print("Hello {0}!".format(nam...
true
6cf6799c4f652c47a3cb818ab1910b4c8d3d6d1c
JustinTrombley96/Python-Coding-Challenges
/drunk_python.py
730
4.1875
4
''' Drunken Python Python got drunk and the built-in functions str() and int() are acting odd: str(4) ➞ 4 str("4") ➞ 4 int("4") ➞ "4" int(4) ➞ "4" You need to create two functions to substitute str() and int(). A function called int_to_str() that converts integers into strings and a function called str_to_int() tha...
true
89b69d5b3a2e700b7f49bd7537ed6a56f1eaaef5
anvandev/TMS_HW
/HW/task_1_5/task_5_7.py
948
4.34375
4
""" Закрепить знания по работе с циклами и условиями. Дана целочисленная квадратная матрица. Найти в каждой строке наи- больший элемент и поменять его местами с элементом главной диагонали. """ from random import randint # function to print matrix in a convenient form def print_matrix(matrix): for element in ma...
false
106c85e88fcc4fbb246c8270d652cedc9de10446
SreeNru/ReDiProject
/main.py
580
4.125
4
from datetime import * import pytz print(">>Welcome to Python program to get Current Time") print(">>Please select your desired country") list=["Europe/Berlin","Asia/Kolkata","America/Los_Angeles", "America/New_York","Europe/London","Hongkong","Europe/Minsk","Australia/Sydney"] serial = 1 for item in list: print(se...
false
94db4a5c592136be5afeccac3323c5c598e41900
STProgrammer/PythonExercises
/Rock Paper Scissor.py
1,571
4.125
4
import random print("Welcome to \"Rock Paper Scissor\" game") print("""Type in "rock", "paper", or "scissor" and see who wins. first one that win 10 times win the game.""") HandsList = ["rock", "paper", "scissor"] while True: x = int() #Your score y = int() #Computer's score while x < 10 and y < 10: ...
true
8f7e92a384cf95b4b45ee3eb41d0edf8afdb38ff
Esther-Guo/python_crash_course_code
/chapter4-working with lists/4.10-slices.py
265
4.40625
4
odd = list(range(1,21,2)) for number in odd: print(number) print('The first three items in the list are: ') print(odd[:3]) print('Three items from the middle of the list are: ') print(odd[4:7]) print('The last three items in the list are: ') print(odd[-3:])
true
0777824a168e8bc5eabcb35a58e2c6aa62e122d2
Esther-Guo/python_crash_course_code
/chapter8-functions/8.8-user_albums.py
651
4.21875
4
def make_album(name, title, tracks=0): """builds a dictionary describing a music album""" album_dict = { 'artist name': f'{name.title()}', 'album title': f'{title.title()}' } if tracks: album_dict['tracks'] = tracks return album_dict name_prompt = 'Please input the name...
true
5e29635e085e9f0199f8e7e6b7e97e47fae30fcd
hefeholuwah/wejapa_internship
/Hefeholuwahwave4 lab/Scripting labs/match_flower_name.py
1,388
4.34375
4
#For the following practice question you will need to write code in Python in the workspace below. This will allow you to practice the concepts discussed in the Scripting lesson, such as reading and writing files. You will see some older concepts too, but again, we have them there to review and reinforce your understan...
true
100d133d879ff910586c3f5c49ec068ee3c01fb8
huioo/byte_of_python
/main/str_format.py
1,189
4.34375
4
# format 方法 # 有时候我们想要从其他信息中构造字符串。这就是 format() 方法可以发挥作用的地方。 age = 20 name = 'Swaroop' # {0}对应name,format方法的第一个参数 # {1}对应age,format方法的第二个参数 # 使用字符串连接实现相同的效果,name + ' is ' + str(age) + ' years old' template = '{0} was {1} years old when he wrote this book.' print(template.format(name, age)) template = 'Why is {0} playin...
false
73c3bcce9c5509b858bb2d149ded24f592b78207
xuyichen2010/Leetcode_in_Python
/general_templates/tree_bfs.py
1,170
4.1875
4
# https://www.geeksforgeeks.org/level-order-tree-traversal/ # Method 1 (Use function to print a given level) # O(n^2) time the worst case # Because it takes O(n) for printGivenLevel when there's a skewed tree # O(w) space where w is maximum width # Max binary tree width is 2^h. Worst case when perfect binary tree # ...
true
c03486f525084d5fd5f06c48f371db8cbdfa9666
phganh/CSC110---SCC
/Labs/Lab 3/coffeeShop.py
984
4.15625
4
# Project: Lab 03 (TrinhAnhLab03Sec03.py) # Name: Anh Trinh # Date: 01/20/2016 # Description: Calculate the cost of a coffee # shop's products def coffeeShop(): #Greeting print("Welcome to the Konditorei Coffee Shop!\n") #User's Input fltPound = float(input("Enter ...
true
02cf5510fb1edd89a53edb3c85b72f41307934b4
phganh/CSC110---SCC
/Statements for String.py
750
4.21875
4
## ------ STATEMENTS FOR STRING ------ ## def main(): print("Numeric Value of A Character") print("'a':",ord("a"),"\n'b':",ord("b")) print("\nString Value of A Number") print("'97':",chr(97),"\n'98':",chr(98)) print("\nNumeric Length of A String") string = "How a...
false
60357647015686ebbb09aee4122feb1fec8a8511
huahuijay/learn-python-with-L
/dict_set.py
1,446
4.15625
4
# -*- coding: utf-8 -*- # dict: 字典 ,使用key——value存储 d = {'Michael': 95, 'Bob': 75, 'Tracy': 85} print d['Michael'] d['Adam'] = 67 print d['Adam'] #一个key只能对应一个value,多次对一个key放入多个value,前面的值会被冲掉 #如果key不存在,dict会报错 #为避免key不存在的错误,两种办法: #1 'Thomas' in d #2 d.get('Thomas') d.get('Thomas', -1) #其中-1为key不存在时自己指定的返回的value,不指定的话为N...
false
4a0989e726ccdea9ec4b69028dd3f5b1c5e54312
ccchao/2018Spring
/Software Engineering/hw1/good.py
858
4.34375
4
""" 1. pick a list of 100 random integers in the range -500 to 500 2. find the largest and smallest values in the list 3. find the second-largest and second-smallest values in the list 4. calculate the median value of the elements in the list """ import random #Generate a list containing 100 randomly generated intege...
true
1a5decdca960e40d6c0bd1939d4461176a7fee70
parastooveisi/CtCI-6th-Edition-Python
/Linked Lists/palindrome.py
1,202
4.1875
4
# Implement a function to check if a linked list is a palindrome class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def printList(self): curr = self.head while curr: print(cur...
true
dcc6441b4f35dbf2962552d305fd7212c561ae3b
Brody-Liston/Pracs-by-Brody-Liston
/Prac 5/Colours.py
783
4.28125
4
hex_colour = {"f0f8ff": "AliceBlue", "f5f5dc": "Beige", "000000": "Black", "ffebcd": "BlanchedAlmond", "8a2be2": "BlueViolet", "5f9ea0": "CadetBlue", "d2691e": "Chocolate", "ff7f50": "Coral", "6495ed": "CornflowerBlue", "b8860b": "DarkGoldenrod"} def main(): hexadecimal = input(...
false
04229618cfcd1a1d69e3da28b9ca8f3ea03cc199
ash/python-tut
/41.py
241
4.1875
4
name = "John" print("Hello, " + name + '!') print("Hello, %s!" % name) print("Hello, {0}!".format(name)) print("{0}, {1}!".format('Hi', name)) print("{1}, {0}!".format(name, 'Hi')) print('My name is {0}. {0} {1}.'.format('James', 'Bond'))
false
5819dbb5b6c308ac62f478185a3d52718832a533
jbehrend89/she_codes_python
/functions/functions_exercises.py
429
4.125
4
# Q1)Write a function that takes a temperature in fahrenheitand returns the temperature in celsius. def convert_f_to_c(temp_in_f): temp_in_c = (temp_in_f - 32) * 5 / 9 return round(temp_in_c, 2) print(convert_f_to_c(350)) # Q2)Write a function that accepts one parameter (an integer) and returns True when tha...
true
8e05d610dc575187daeddc918c9395d9709a43c4
niceman5/pythonProject
/02.교육/Python-응용SW개발/Project/day20190420/whileEx01.py
561
4.125
4
num = 1 # 초기값 while num < 3: #조건식 : #반복할 조건 true일동안만 실 #명령문 print('num = {}'.format(num)) num += 1 # 증감식 print('실행종료') # 무한loop돌면서 조건으로 체크하는 방식이 있음 num = 1 while True: print('num = {}'.format(num)) num += 1 # 증감식 if num == 3: break print('실행종료') num = 1 while n...
false
9dcd83d636b054f122adb049fb0ecb97b342d3f4
nishanthegde/bitesofpy
/105/slicing.py
1,848
4.3125
4
from string import ascii_lowercase text = """ One really nice feature of Python is polymorphism: using the same operation on different types of objects. Let's talk about an elegant feature: slicing. You can use this on a string as well as a list for example 'pybites'[0:2] gives 'py'. The first value is inclus...
true
1ad2e7463aff6086e9506fe45d87a94b0d6b9226
nishanthegde/bitesofpy
/9/palindrome.py
1,805
4.21875
4
"""A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward""" import os import urllib.request as ur import re local = '/tmp' # local = os.getcwd() DICTIONARY = os.path.join(local, 'dictionary_m_words.txt') ur.urlretrieve('http://bit.ly/2Cbj6zn', DICTI...
true
489a9fbaa6d206101364ed5db32b3bf291c3d875
nishanthegde/bitesofpy
/304/max_letter.py
2,435
4.25
4
from typing import Tuple import re from collections import Counter sample_text = '''It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.''' with_numbers_text = '''20,000 Leagues Under the Sea is a 1954 American Tec...
true
c2e0d08cf977c216e326da83a6e1580b01c3af7b
nishanthegde/bitesofpy
/66/running_mean.py
666
4.125
4
import itertools def running_mean(sequence: list) -> list: """Calculate the running mean of the sequence passed in, returns a sequence of same length with the averages. You can assume all items in sequence are numeric.""" it = iter(sequence) n = len(sequence) run_mean = [] ...
true
f70649cbba312ef901ac9aa035cc529e46127200
Caleb-o/VU405
/sort.py
694
4.1875
4
""" Author: Caleb Otto-Hayes Date: 11/2/2021 """ def swap(x: int, y: int) -> tuple: return (y, x) def bubbleSort(unsorted: list) -> None: length: int = len(unsorted) full_pass: bool = False # Cannot parse if only 1 number exists if length < 2: return while not full_p...
true
1572a767db054bb13877a5d56f5efb212d0b844d
ahumoe/dragonfly-commands
/_text_utils.py
1,978
4.15625
4
#!/usr/bin/env python # (c) Copyright 2015 by James Stout # (c) Copyright 2016 by Andreas Hagen Ulltveit-Moe # Licensed under the LGPL, see <http://www.gnu.org/licenses/> """Library for extracting words and phrases from text.""" import re def split_dictation(dictation, strip=True): """Preprocess dictation to do ...
true
c3062c4b5da4a684bb5ce8a19b074e6585618620
josepicon/practice.code.py
/Exercise Files/Ch2/functions_start.py
747
4.34375
4
# # Example file for working with functions # # define a basic function def func1(): print("i am a function") # function that takes arguments def func2(arg1, arg2): print(arg1, "", arg2) # function that returns a value def cube(x): return x*x*x # function with default value for an argument def power(n...
true
080fa1a292fe225984f8889d5e5bd13ed05b0f07
MayThuHtun/python-exercises
/ex3.py
444
4.28125
4
print("I will now count my chickens") print("Hens", 25+30/6) print("Roosters", 100-25*3 % 4) print("Now I will count the egg:") print(3+2+1-5+4 % 2-1/4+6) print("Is it true that 3+2<5-7?") print(3+2 < 5-7) print("What is 3+2?", 3+2) print("What is 5-7?", 5-7) print("Oh, that is why it is false") print("How about some m...
true
71191aff305c9dae5028b28c2f43b0d963112b9b
dev-aleks/info_2021
/lab4/house.py
1,380
4.125
4
def main(): x, y = 300, 400 width, height = 200, 300 draw_house(x, y, width, height) def draw_house(x, y, width, height): ''' Функция рисует домик :param x: координата x у низа фундамента :param y: координата y у низа фундамента :param width: полная ширина домика (фундамент или вылеты ...
false
aeb5e4b72d128ac04131053125ed663ad059d5f5
Patricia888/data-structures-and-algorithms
/sorting_algos/merge_sort/merge_sort.py
927
4.5
4
def merge_sort_the_list(lst): ''' Performs a merge sort on a list. Checks the length and doesn't bother sorting if the length is 0 or 1. If more, it finds the middle, breaks the list in to sublists, sorts, puts in to a single list, and then returns the sorted list ''' # don't bother sorting if list is less than...
true
a56350042eb37db6b829f6a1e39aafaf25f8bca8
Roderich25/mac
/python_cookbook/chapter_02/cookbook_11.py
391
4.25
4
# 2.11 Stripping unwanted characters from strings # whitespace stripping import re s = ' hello world \n' print(s) print(s.strip()) print(s.lstrip()) print(s.rstrip()) # character stripping t = '-----hello=====' print(t.lstrip('-')) print(t.strip('-=')) # another example s = ' hello world \n' print(s.s...
false
4e2dcb79a87788232e4ea09ff6e3688a6a6f4b8c
Roderich25/mac
/python-scripts/square_root.py
233
4.21875
4
#!/usr/bin/env python3 def square_root(a): x = a//2 while True: print(int(x)*"*", x) y = (x + a/x)/2 print if abs(y-x) < 0.00001: return y x = y print(square_root(125))
false
e10e5f413c7f9e4b84f8fe20a314a4be4d36a9a9
TheWronskians/capture_the_flag
/turtlebot_ws/src/turtle_pkg/scripts/primeCalc.py
912
4.125
4
from math import * import time def checkingPrime(number): #Recieves number, true if prime. Algorithem reference mentioned in readme file. checkValue = int(sqrt(number))+1 printBool = True #print checkValue for i in range(2, checkValue): if (number%i) == 0: printBool = False break return printBool def c...
true
273b92997f588d6aeee2ae42928258d04f0a4187
drliebe/python_crash_course
/ch7/restaurant_seating.py
214
4.28125
4
dinner_party_size = input("How many people are in your dinner group? ") if int(dinner_party_size) > 8: print("I'm sorry, but you will have to wait to be seated.") else: print('Great, we can seat you now.')
true
20b3792997a403dda5086e24d5914c0157d91ea3
drliebe/python_crash_course
/ch9/restaurant.py
628
4.125
4
class Restaurant(): """A class modeling a simple restaurant.""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print('Restaurant name: ' + self.restaurant_name + ...
false
1a747fc8d6fefd929318c717954420f3e36ce54a
drliebe/python_crash_course
/ch9/ice_cream_stand.py
888
4.28125
4
class Restaurant(): """A class modeling a simple restaurant.""" def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print('Restaurant name: ' + self.restaurant_name + ...
true
42b2a2848527d4f024d2bdc5ff385b2ce9753dc4
aurafrost/Python
/DivisorCheck.py
518
4.21875
4
""" This program takes an int from the user then returns all divisors of that int from lowest to highest. """ num = int(input("Enter an integer: ")) divisorList = [] for x in range(1,num+1): if num%x==0: divisorList.append(x) #adds x to divisorList if it has no remainder when divided into num print("The div...
true
edaaa9d51915039e033c950b030fbc08a9ef4084
fharookshaik/Mobius_GUI
/mobius.py
2,932
4.28125
4
''' Möbius function: For any positive integer n,n, define μ(n)μ(n) as the sum of the primitive n^\text{th}nth roots of unity. It has values in \{-1, 0, 1\}{−1,0,1} depending on the factorization of nn into prime factors: a) \mu(n) = 1μ(n)=1 if nn is a square-free positive integer with an even number of prime facto...
true
86ae948be11bd8decc10050c7cea5fb41397e9d6
ms0695861/age
/age.py
657
4.1875
4
#age judement driving = input('Have you ever driven a car? (Y/N): ') if driving != 'Y' and driving != 'N': print('Please enter Y or N! Thanks!') raise SystemExit age = input('How old are you?: ') age = int(age) if driving == 'Y': if age >= 18: print('PASS!!') else: print('It is illegal') elif driving == 'N': ...
false
cb98c118df80bbe3ef89900bc63d6e38d01514c8
jpozin/Math-Projects
/TriangleStuff.py
652
4.375
4
import sys from math import sqrt class TriangleException(Exception): pass def isValidTriangle(a, b, c): return (a + b > c) and (a + c > b) and (b + c > a) def Perimeter(a, b, c): return a + b + c def Area(a, b, c): s = Perimeter(a, b, c) / 2 return sqrt(s*(s-a)*(s-b)*(s-c)) if __name__ == '__m...
true
907bc6613731a110a451fc19caae9ac35a8b7a86
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 2/Task7.py
413
4.34375
4
def Palindrome(String): word = "" for i in String: if i != " ": word += i oppositeWord = "" for i in range(len(String)-1,-1,-1): if String[i] != " ": oppositeWord += String[i] # # print(word) # print(oppositeWord) # if word == oppositeWord: ...
false
d6218b40c283b8ec5eda0c7f77e63e650a4eac75
FKistic/Python-Personal
/calci project/calci v5.py
2,422
4.21875
4
#simple calcultor using python import time time.sleep(1) print('''|||||||| //\\\ || |||||||| || || || //\\\ |||||||||| |||||||| ||||||\\''') time.sleep(1) print('''|| // \\\ || || || || || // \\\ || || || || ||''') time.sleep(1) print('''|| //==...
false
52756187aec18fc94ecc77d26594ab3d50a502a5
kellylougheed/raspberry-pi
/bubble_sort.py
956
4.375
4
#!/usr/bin/env python # This program sorts a list of comma-separated integers using bubble sort # Swaps two numbers in a list given their indices def swap(l, index1, index2): temp = l[index2] l[index2] = l[index1] l[index1] = temp numbers = input("Enter a list of comma-separated integers: ") lst = numbers.split...
true
473d78088b698ab07eca912a5ef5bf23a76d32dc
dibaggioj/bioinformatics-rosalind
/textbook/src/ba1d.py
2,138
4.3125
4
#!/usr/bin/env # encoding: utf-8 """ Created by John DiBaggio on 2018-07-28 Find All Occurrences of a Pattern in a String In this problem, we ask a simple question: how many times can one string occur as a substring of another? Recall from “Find the Most Frequent Words in a String” that different occurrences of a sub...
true
47f6f9ad980659dc5b1408cb50f588adda37c9cf
FierySama/vspython
/Module7ComplexDecisions/m7cont.py
1,121
4.21875
4
team = input('Enter your favorite hockey team: ').upper() sport = input('Enter your favorite sport: ').upper() sportIsHockey = False if sport == 'HOCKEY': sportIsHockey = True teamIsCorrect = False if team == 'SENATORS' or team == 'LEAFS': teamIsCorrect = True if sportIsHockey and teamIsCorrect: print('g...
false
b2b59660795297211f00f7b98497fb289583e46a
FierySama/vspython
/Module3StringVariables/Module3StringVariables/Module3StringVariables.py
1,330
4.5625
5
#String variables, and asking users to input a value print("What is your name? ") # This allows for the next line to be user input name = input("") country = input("What country do you live in? ") country = country.upper() print(country) # input is command to ask user to enter info!! # name is actually the name of...
true
89786e3d23a48edae281b38edcc1df05db998b13
AtilioA/Python-20191
/lista7jordana/Ex062.py
744
4.15625
4
# 12. Faça uma função que receba uma lista de números armazenados de forma crescente , e # dois valores ( limite inferior e limite superior), e exiba a sublista cujos elementos são maiores # ou iguais ao limite inferior e menores ou iguais ao limite superior def intervalo(listaOrdenada, limInferior, limSuperior): ...
false
75db23491fd660c007860b03e4ed99cca64a9025
zengh100/PythonForKids
/lesson02/07_keyboard_number.py
316
4.15625
4
# keyboard # we can use keyboard as an input to get informations or data (such as number or string) from users x1 = input("please give your first number? ") #print('x1=', x1) x2 = input("please give your second number? ") #print('x2=', x2) sum = x1 + x2 #sum = int(x1) + int(x2) print('the sum is {}'.format(sum))
true
ab38aaac210610d8b6b26ef0cab0d918d58f81b7
muhamadziaurrehman/Python
/Finding and printing odd numbers from list.py
283
4.34375
4
List = (1,2,3,4,5,6,7,8,9) ###This function is printing odd position numbers according to programmers who starts counting from 0 minor changes occur to start it from 1 i-e change x to x+1 only in if statement for x in range(0,9): if (x)%2 == 0: print() else: print(List[x])
true
c75d693b5f9e6fbf51573a8e2ede8070b52ec4cb
kasataku777/PY4E
/chap8-list/ex8-5.py
1,126
4.125
4
# Exercise 5: Write a program to read through the mail box data and # when you find line that starts with “From”, you will split the line into # words using the split function. We are interested in who sent the # message, which is the second word on the From line. # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:1...
true
bc204746027f72a2c68e230e9be6a4a3fc8bce26
sneceesay77/python_projects
/python_basics/classes.py
933
4.125
4
class Tutorial: """Modelling a Tutorial class""" #a docstring, mainly printed in documentation #constructor def __init__(self, module_name, max_students): self.module_name = module_name self.max_students = max_students def display_max_stud(self): print(f"Maximum number...
true
6194db2615e2819ffb8437cbbc8a2f511a093854
ivaylospasov/programming-101
/week0/prime_number_of_divisors.py
329
4.125
4
#!/usr/bin/env python3 from is_prime import is_prime def prime_number_of_divisors(n): divisors = [x for x in range(1, n+1) if n % x == 0] if is_prime(len(divisors)) is True: return True else: return False def main(): print(prime_number_of_divisors(45)) if __name__ == '__main__': ...
false
a3387722a6d8ac4ecf061ed08de7887fa38c7e59
MayankVerma105/Python_Programs
/max3.py
530
4.125
4
def max3(n1,n2,n3): maxNumber = 0 if n1 > n2: if n2 > n3: maxNumber = n1 else: maxNumber = n3 elif n2 > n3: maxNumber = n2 else: maxNumber = n3 return maxNumber def main(): n1=int(input('Enter first number :...
false