blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
eb7bc39f59c1d5ed19f206a85ccec13c4a6a7e00 | winniewjeng/StockDatabase | /Example.py | 2,330 | 4.40625 | 4 | #! /usr/bin/env python3
"""
File: Jeng_Winnie_Lab1.py
Author: Winnie Wei Jeng
Assignment: Lab 2
Professor: Phil Tracton
Date: 10/07/2018
The base and derived classes in this file lay out
the structure of a simple stock-purchasing database
"""
from ExampleException import *
# Base Class
class ExampleBase:
# c... | true |
c145820dfe8508a0091293b96dbf1b45d5507bd1 | Stephania86/Algorithmims | /reverse_statement.py | 449 | 4.5625 | 5 | # Reverse a Statement
# Build an algorithm that will print the given statement in reverse.
# Example: Initial string = Everything is hard before it is easy
# Reversed string = easy is it before hard is Everything
def reverse_sentence(s):
word_list = s.split()
word_list.reverse()
reversed_sentence = " ".jo... | true |
c09cbd12035fbd857e646f2379691090df8e267c | Stephania86/Algorithmims | /Even_first.py | 674 | 4.34375 | 4 | # Even First
# Your input is an array of integers, and you have to reorder its entries so that the even
# entries appear first. You are required to solve it without allocating additional storage (operate with the input array).
# Example: [7, 3, 5, 6, 4, 10, 3, 2]
# Return [6, 4, 10, 2, 7, 3, 5, 3]
def even_first(arr):... | true |
8fb6a2464a7c668ea237ed170a3e84a237c4a049 | Lincxx/py-PythonCrashCourse | /ch3 lists/motorcycles.py | 1,470 | 4.59375 | 5 | motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
# change an element in a list
motorcycles[0] = 'ducati'
print(motorcycles)
# append to a list
motorcycles.append('Indian')
print(motorcycles)
# Start with an empty list
friends = []
friends.append("Jeff")
friends.append("Nick")
friends.append("Corey"... | true |
fddb55fdc2d951f6c8dbcf265ee894ed6b853c43 | Lincxx/py-PythonCrashCourse | /ch3 lists/exercises/3-5.py | 1,030 | 4.25 | 4 | # 3-5. Changing Guest List: You just heard that one of your guests can’t make the
# dinner, so you need to send out a new set of invitations. You’ll have to think of
# someone else to invite.
# • Start with your program from Exercise 3-4. Add a print statement at the
# end of your program stating the name of the guest... | true |
ec339af34ee862e4be09aa357477f6be7512c868 | Lincxx/py-PythonCrashCourse | /ch3 lists/exercises/3-4.py | 577 | 4.34375 | 4 | # 3-4. Guest List: If you could invite anyone, living or deceased, to dinner, who
# would you invite? Make a list that includes at least three people you’d like to
# invite to dinner. Then use your list to print a message to each person, inviting
# them to dinner.
interesting_people = ['Einstein', 'Jack Black', 'The Q... | true |
42ab61361b181d15deeb79ddcee10368643786c2 | tramxme/CodeEval | /Easy/RollerCoaster.py | 1,043 | 4.125 | 4 | '''
CHALLENGE DESCRIPTION:
You are given a piece of text. Your job is to write a program that sets the case of text characters according to the following rules:
The first letter of the line should be in uppercase.
The next letter should be in lowercase.
The next letter should be in uppercase, and so on.
Any characters... | true |
569fb617c5b2721bd3df06cf09fd12cc80cd071b | tramxme/CodeEval | /Easy/ChardonayOrCabernet.py | 2,096 | 4.1875 | 4 | '''
CHALLENGE DESCRIPTION:
Your good friend Tom is admirer of tasting different types of fine wines. What he loves even more is to guess their names. One day, he was sipping very extraordinary wine. Tom was sure he had tasted it before, but what was its name? The taste of this wine was so familiar, so delicious, so ple... | true |
f78f231145b031de661340f6bb6dbedcd567b837 | randalsallaq/data-structures-and-algorithms-python | /data_structures_and_algorithms_python/challenges/array_reverse/array_reverse.py | 350 | 4.4375 | 4 | def reverse_array(arr):
"""Reverses a list
Args:
arr (list): python list
Returns:
[list]: list in reversed form
"""
# put your function implementation here
update_list = []
list_length = len(arr)
while list_length:
update_list.append(arr[list_length-1])
l... | true |
8ff7e7b25fa251914cefc9ac48073768cc06c745 | nuass/lzh | /The_diffcult_point/iter_iterable.py | 1,104 | 4.21875 | 4 | #coding:utf-8
#迭代器一定是迭代对象,反过来则不是,
#迭代对象是定义__iter__()方法,返回迭代器
#迭代器是定义了__iter__()和__next__()
#生成器是特殊的迭代器,yeild的作用和__iter__()和__next__()的作用相同
from collections import Iterable,Iterator
class Myrange(object):
def __init__(self,start,end,step=1):
self.start=start
self.end=end
self.step=step
... | false |
70291137c6c759f268f7ab8b45591a3d1ec95cd9 | dnwigley/Python-Crash-Course | /make_album.py | 492 | 4.21875 | 4 | #make album
def make_album(artist_name , album_title):
""""Returns a dictionary based on artist name and album title"""
album = {
'Artist' : artist_name.title(),
'Title' : album_title.title(),
}
return album
print("Enter q to quit")
while True:
title = input("Enter album title: ")
i... | true |
53fb20fc1ba77ca145dea0b93a89cc020f887619 | naveensambandan11/PythonTutorials | /tutorial 39_Factorial.py | 224 | 4.34375 | 4 | # Funtion to calculate factorial
def Fact(n):
fact = 1
for i in range(1, n+1):
fact = fact * i
return fact
n = int(input('enter the number to get factorial:'))
result = Fact(n)
print(result) | true |
da85714a0fea257a811e53d95d5b0bf3d99717a5 | TwitchT/Learn-Pythonn-The-Hard-Way | /ex4.py | 1,687 | 4.4375 | 4 | # This is telling me how many cars there is
cars = 100
# This is going to tell me how much space there is in a car
space_in_a_car = 40
# This is telling me how many drivers there is for the 100 cars
drivers = 30
# This is telling how many passengers there is
passengers = 90
# This tells me how many empty cars there is ... | true |
1dfed477aa45a48f640d4d869f5ae051c99b363a | TwitchT/Learn-Pythonn-The-Hard-Way | /ex13.py | 984 | 4.125 | 4 | from sys import argv
# Read the WYSS section for how to run this
# These will store the variables
script, first, second, third = argv
# Script will put the first thing that comes to the line, 13.py is the first thing
# So script will put it 13.py and it will be the variable
print("The script is called:", script)
# If y... | true |
33115232faf0951e37f4b48521e3e22f6bbc2a00 | TwitchT/Learn-Pythonn-The-Hard-Way | /ex23.py | 916 | 4.125 | 4 | import sys
# Will make the code run on bash
script, input_encoding, error = sys.argv
# Defines the function to make it work later on
def main(language_file, encoding, errors):
line = language_file.readline()
if line:
print_line(line, encoding, errors)
return main(language_file, encoding, e... | true |
03cd39bc59234bd30b84a89ae3157a44363f8a93 | Ishan-Bhusari-306/applications-of-discrete-mathematics | /dicestrategy.py | 988 | 4.28125 | 4 | def find_the_best_dice(dices):
# you need to use range (height-1)
height=len(dices)
dice=[0]*height
#print(dice)
for i in range(height-1):
#print("this is dice number ",i+1)
# use height
for j in range(i+1,height):
#print("comparing dice number ",i+1," with dice number ",j+1)
check1=0
check2=0
fo... | true |
892ba5dc80b77da4916db1e1afb0f0b4a06c75ba | ibndiaye/odd-or-even | /main.py | 321 | 4.25 | 4 | print("welcome to this simple calculator")
number = int(input("Which number do you want to check? "))
divider = int(input("what do you want to divide it by? "))
operation=number%divider
result=round(number/divider, 2)
if operation == 0:
print(f"{result} is an even number")
else:
print(f"{result} is an odd number")... | true |
d475df99c67157cfad58ce2514cae3e378ed785c | adwardlee/leetcode_solutions | /0114_Flatten_Binary_Tree_to_Linked_List.py | 1,520 | 4.34375 | 4 | '''
Given the root of a binary tree, flatten the tree into a "linked list":
The "linked list" should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null.
The "linked list" should be in the same order as a pre-order traversal of the bin... | true |
6bf88ae9e8933f099ed1d579af505fc8ef0d04b4 | Abicreepzz/Python-programs | /Decimal_to_binary.py | 462 | 4.25 | 4 | def binary(n):
result=''
while n>0:
result=str(n%2)+str(result)
n//=2
return int(result)
binary(5) ##output= 101
# Another simple one line code for converting the decimal number to binary is followed:
def f(n): print('{:04b}'.format(n))
binary(5) ##output =101
# If we want to print in the 8 bit digi... | true |
9e188e9dcd5fd64231f883943ab83e307158a5f7 | Jewel-Hong/SC-projects | /SC101Lecture_code/SC101_week6/priority_queue_list.py | 1,402 | 4.46875 | 4 | """
File: priority_queue_list.py
Name:
----------------------------------
This program shows how to build a priority queue by
using Python list. We will be discussing 3 different
conditions while appending:
1) Prepend
2) Append
3) Append in between
"""
# This constant controls when to stop the user input
EXIT = ''
d... | true |
7ce2f22d370784db0284cac76eba4becb42f7556 | Jewel-Hong/SC-projects | /SC101Lecture_code/SC101_week3/word_occurrence.py | 1,397 | 4.21875 | 4 | """
File: student_info_dict.py
------------------------------
This program puts data in a text file
into a nested data structure where key
is the name of each student, and the value
is the dict that stores the student info
"""
# The file name of our target text file
FILE = 'romeojuliet.txt'
# Contains the chars we ... | true |
b7c2bfb8e2014f910c9303da904d3303eae9e5bf | KREAL22/tms | /lesson8/lesson8.py | 2,464 | 4.34375 | 4 | '''
Создайте класс Figure. У каждой фигуры есть имя, также можно найти площадь и периметр фигуры.
Создайте классы Triangle, Circle, Rectangle производные от Figure.
У класса Triangle есть 3 стороны: a, b, c; у Circle - радиус r; у Rectangle - стороны a и b.
Переопределите методы нахождения площади и периметра для ка... | false |
122d28e0debb5673766de18fcdd5f27c44cdb407 | Nicolas-Wursthorn/Exercicios-Python-Brasil | /EstruturaDeRepeticao/exercicio13.py | 461 | 4.15625 | 4 | # Faça um programa que peça dois números, base e expoente, calcule e mostre o primeiro número elevado ao segundo número. Não utilize a função de potência da linguagem.
base = int(input("Digite o primeiro número: "))
expoente = int(input("Digite o segundo número: "))
count = 1
potencia = 1
while count <= expoente:
... | false |
9f97af2a66220b24f7fc849b477d455027f80960 | Nicolas-Wursthorn/Exercicios-Python-Brasil | /EstruturaDeDecisao/exercicio23.py | 276 | 4.15625 | 4 | # Faça um Programa que peça um número e informe se o número é inteiro ou decimal. Dica: utilize uma função de arredondamento.
num = float(input("Digite um número: "))
if num // 1 == num:
print("Esse número é inteiro")
else:
print("Esse número é decimal") | false |
a01d070dcdbc806fe0b93a311ea5660bc9b6d16a | Nicolas-Wursthorn/Exercicios-Python-Brasil | /EstruturaDeRepeticao/exercicio31.py | 411 | 4.28125 | 4 | # Faça um programa que calcule o fatorial de um número inteiro fornecido pelo usuário. Ex.: 5!=5.4.3.2.1=120. A saída deve ser conforme o exemplo abaixo:
# Fatorial de: 5
# 5! = 5 . 4 . 3 . 2 . 1 = 120
import math
numero = int(input("Fatorial de: "))
count = numero
fatorial = math.factorial(numero)
for i in range(n... | false |
78f798166b198026dbd97dbb63d23802865baaee | Nicolas-Wursthorn/Exercicios-Python-Brasil | /EstruturaSequencial/exercicio17.py | 1,275 | 4.15625 | 4 | # Faça um Programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 6 metros quadrados e que a tinta é vendida em latas de 18 litros , que custam R$80,00 ou galões de 3,6 litros, que custam R$25,00.
# Informe... | false |
80f2cfaaa82a18157ebc3b8d6015ac36b3412bc4 | uppala-praveen-au7/blacknimbus | /AttainU/Robin/Code_Challenges/Day2/Day2/D7CC3.py | 1,984 | 4.21875 | 4 | # 3) write a program that takes input from the user as marks in 5 subjects and assigns a grade according to the following rules:
# Perc = (s1+s2+s3+s4+s5)/5.
# A, if Perc is 90 or more
# B, if Perc is between 70 and 90(not equal to 90)
# C, if Perc is between 50 and 70(not equal to 90)
# D, if Perc is between 30 and 50... | true |
2c49ef300a9d5a6b783f103e064132f222fe4977 | ruchirbhai/Trees | /PathSum_112.py | 2,125 | 4.15625 | 4 | # https://leetcode.com/problems/path-sum/
# Given a binary tree and a sum, determine if the tree has a root-to-leaf path such
# that adding up all the values along the path equals the given sum.
# Note: A leaf is a node with no children.
# Example:
# Given the below binary tree and sum = 22,
# 5
# / \
# ... | true |
58118aa6dac147138a91cdfb393ddf328be961b0 | 44858/variables | /multiplication and division.py | 484 | 4.34375 | 4 | #Lewis Travers
#12/09/2014
#Multiplying and dividing integers
first_integer = int(input("Please enter your first integer: ")
second_integer = int(input("Please enter an integer that you would like the first to be multiplied by: "))
third_integer = int(input("Please enter an integer that you would like the total... | true |
9995de8314efb0c98d03f0c893bb7b7ddbbfd239 | jjsherma/Digital-Forensics | /hw1.py | 2,967 | 4.3125 | 4 | #!/usr/bin/env python
import sys
def usage():
"""Prints the correct usage of the module.
Prints an example of the correct usage for this module and then exits,
in the event of improper user input.
>>>Usage: hw1.py <file1>
"""
print("Usage: "+sys.argv[0]+" <file1>")
sys.exit(2)
def getFi... | true |
2f9c1a23384af6b52ab218621aa937a294a6b793 | bainjen/python_madlibs | /lists.py | 895 | 4.125 | 4 | empty_list = []
numbers = [2, 3, 5, 2, 6]
large_animals = ["african elephant", "asian elephant", "white rhino", "hippo", "guar", "giraffe", "walrus", "black rhino", "crocodile", "water buffalo"]
a = large_animals[0]
b = large_animals[5]
# get the last animal in list
c = large_animals[-1]
# return index number
d = lar... | true |
423fce215596d87146dd016ad3cd9b7a51cf9895 | dasha108219/PROGR | /hw6/try-random.py | 2,872 | 4.21875 | 4 | print('ВАРИАНТ 2')
print('Текст должен представлять собой стихотворение на русском языке из четырёх строк без рифмы, но написанное с соблюдением одной метрической схемы, кроме трёхстопного анапеста- трехстопный дактиль')
print()
import random
with open('noun_sg.txt') as file:
file = file.read().split(' ')
... | false |
36e830aa4a52c6f8faa1347722d1dab6333088c8 | tom1mol/core-python | /test-driven-dev-with-python/refactoring.py | 1,197 | 4.3125 | 4 | #follow on from test-driven-development
def is_even(number):
return number % 2 == 0 #returns true/false whether number even/not
def even_number_of_evens(numbers):
evens = sum([1 for n in numbers if is_even(n)])
return False if evens == 0 else is_even(evens)
""" this reduc... | true |
bc547b6f91f5f3133e608c4aa479eb811ddf7c58 | sgspectra/phi-scanner | /oldScripts/wholeFile.py | 835 | 4.40625 | 4 | # @reFileName is the name of the file containing regular expressions to be searched for.
# expressions are separated by newline
# @fileToScanName is the name of the file that you would like to run the regex against.
# It is read all at once and the results returned in @match
import re
#reFileName = input("Please ente... | true |
b28a938c098b5526fb6541b41f593d30a665b185 | elguneminov/Python-Programming-Complete-Beginner-Course-Bootcamp-2021 | /Codes/StringVariables.py | 1,209 | 4.46875 | 4 | # A simple string example
short_string_variable = "Have a great week, Ninjas !"
print(short_string_variable)
# Print the first letter of a string variable, index 0
first_letter_variable = "New York City"[0]
print(first_letter_variable)
# Mixed upper and lower case letter variable
mixed_letter_variable = "ThI... | true |
201a2b05930cd4064623156c2b9248665d378647 | Dumacrevano/Dumac-chen_ITP2017_Exercise2 | /3.1 names.py | 234 | 4.375 | 4 | #Store the names of a few of your friends in a list called names .
# Print each person’s name by accessing each element in the list, one at a time .
names=["Suri", "andy", "fadil", "hendy"]
print(names[0],names[1],names[2],names[3]) | true |
42627250cb4d940216afbfd63631af391c8df4f9 | Dumacrevano/Dumac-chen_ITP2017_Exercise2 | /3.10 every function.py | 328 | 4.15625 | 4 | list=["Indonesia","singapore","Thailand","Kamboja"]
print(list[1])
print(list[-2])
list[1]="Vietnam"
list.append("Laos")
list.insert(0,"Malaysia")
del list[3]
winner=list.pop()
print("the winner is "+winner)
list.remove("Malaysia")
print(list)
print(sorted(list,reverse=True))
list.sort()
print(list)
list.reverse()
prin... | false |
70bff1130064e823077c47b62fe29a207661fa73 | PauloGunther/Python_Studies | /Teorias/2.1_Exemplos.py | 1,362 | 4.125 | 4 | # POR TUDO MAIUSCULO E MINUSCULO, CONTA NUMERO DE LETRAS
nome = input('Digite seu nome completo: ')
print(nome.upper())
print(nome.lower())
rep = nome.replace(' ', '')
print('O número de letra é: {}' .format(len(rep)))
n1 = nome.split()
print('Seu primeiro nome tem {} letras' .format(len(n1[0])))
# MOSTRAR DEZENAS CEN... | false |
752626c1314c482e195bec357be5f28142a69c51 | bquillas/Learning-Python | /codigo_python/listas.py | 742 | 4.125 | 4 | # LISTAS
# Las listas son mutables
# Puedo quitar y añadi9r alementos a la lista
objetos = ["Hola", 2, 4.5, True]
objetos[0]
#'Hola'
objetos[3]
# True
objetos.append(False)
# ["Hola", 2, 4.5, True, False]
objetos.pop(1) #Pasa como parámetro el índice de la lista
# 2
# Elimina el valor de la pos 2
# ["Hola", 4.5, T... | false |
5a98de9302cd36107a5bd2c3e7bba4218f817ba6 | lodi-jesse/aula_python | /desafio042.py | 744 | 4.125 | 4 | # Refaça o desafio 035 dos triângulos, acrescentando o recurso de mostrar que tipo de triângulo será formado:
# Equilátero: todos os lados iguais
# Isósceles: dois lados iguais
# Escaleno: Todos os lados diferentes
r1 = int(input('Digite a primeira reta: '))
r2 = int(input('Digite a segunda reta: '))
r3 = int(in... | false |
f5b05ac0de2aa72baae02f6cf9c077b6e774bf93 | lodi-jesse/aula_python | /desafio028.py | 744 | 4.125 | 4 | #Escreva um programa que faça o computador sortear um número de 0 ate 5 e pesa para o usuário tentar descobrir qual foi o número escolhido pelo computador.
# O programa deverá escrever na tela se o usuário venceu ou perdeu.
from random import randint
from time import sleep
sorteado = randint (0, 5) #faz o computado... | false |
9454b32184aa1c29ad0db72ec564036666dff0f9 | EnriqueStrange/portscannpy | /nmap port-scanner.py | 1,508 | 4.1875 | 4 | #python nmap port-scanner.py
#Author: P(codename- STRANGE)
#date: 10/09/2020
import argparse
import nmap
def argument_parser():
"""Allow target to specify target host and port"""
parser = argparse.ArgumentParser(description = "TCP port scanner. accept a hostname/IP address and list of ports to"
... | true |
0dd3441b24d9c65bc2c0bdfe20612dfcfcf55482 | nadiyasalma/Nadiya-Salma_I0320071_M.Wildan-Rusydani_Tugas3 | /I0320071__Exercise 3.1-3.10.py | 2,150 | 4.375 | 4 | #exercise 3.1
#cara mengakses nilai di dalam list python
list1 = ['fisika', 'kimia', 1993, 2017]
list2 = [1, 2, 3, 4, 5, 6, 7]
print("list1[0]: ", list1[0])
print("list2[1;5]: ", list2[1:5])
#exercise 3.2
list = ['fisika', 'kimia', 1993, 2017]
print("Nilai ada pada index 2: ", list[2])
list[2] = 2001
print("Nilai ba... | false |
f484aab33a5142f6fbe20f6072e035339f561d0b | programmer290399/Udacity-CS101-My-Solutions-to-Exercises- | /CS101_Shift_a_Letter.py | 387 | 4.125 | 4 | # Write a procedure, shift, which takes as its input a lowercase letter,
# a-z and returns the next letter in the alphabet after it, with 'a'
# following 'z'.
def shift(letter):
ASCII = ord(letter)
if ASCII == 122 :
return chr(97)
else :
return chr(ASCII + 1)
print shift... | true |
62c129920b2c9d82d35eaba02a73924596696280 | Maxrovr/concepts | /python/sorting/merge_sort.py | 1,982 | 4.21875 | 4 | class MergeSort:
def _merge(self, a, start, mid, end):
"""Merges 2 arrays (one starting at start, another at mid+1) into a new array and then copies it into the original array"""
# Start of first array
s1 = start
# Start of second array
s2 = mid + 1
# The partially so... | true |
a5333dc221c0adcb79f583faceb53c7078333601 | tocheng/Book-Exercises-Intro-to-Computing-using-Python | /Book-Chapter5_2-Range.py | 1,922 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 29 09:48 2020
Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed
Book Chapter 5 Structured types, mutability and higher-order functions
Ranges
@author: Atanas Kozarev - github.com/ultraasi-atanas
RANGE the Theory
The range function t... | true |
0240f939041db7bfe697fecd110ca33dd83f84b8 | tocheng/Book-Exercises-Intro-to-Computing-using-Python | /Book-Chapter2_2-FE-odd-number.py | 1,173 | 4.46875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 11 09:54:53 2020
Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed
Book Chapter 2 Finger Exercises - Find the largest odd number
@author: Atanas Kozarev - github.com/ultraasi-atanas
"""
# edge cases 100, 2, 3 an... | true |
32edc5c1c32209e99e6b51d2bf0cb14ba3f1a07c | tocheng/Book-Exercises-Intro-to-Computing-using-Python | /Book-Chapter2_3-Exercises-LargestOddNumberOf10.py | 1,186 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 13 14:15:03 2020
Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed
Book Chapter 2 Finger Exercises
Largest Odd number of 10, using user input
Prints the largest odd number that was entered
If no odd number was entered, it should print ... | true |
8e04e0bc3911f87b01ccab4a8d70101f53bff593 | stulew93/die-simulator | /dicesimulator.py | 1,773 | 4.4375 | 4 | import random
def die_face_generator(digit: int) -> str:
"""
Function to create a basic render of a die face, of value equal to digit. If digit is not an integer between 1
and 6, function will return a warning.
:param digit: Any integer.
:return: str
"""
full_line = "-----------"
middl... | false |
1b049dc1145f1269bcbf38c96965fa0b13d585ca | guyjacks/codementor-learn-python | /string_manipulation.py | 872 | 4.1875 | 4 | print "split your and last name"
name = "guy jacks"
# split returns a list of strings
print name.split()
print "/n"
print "split a comma separated list of colors"
colors = "yellow, black, blue"
print colors.split(',')
print "\n"
print "get the 3rd character of the word banana"
print "banana"[2]
print "\n"
blue_moon... | true |
b67babb057054f9c58063cee41fdbc8244d23071 | Chris-gde/exercicios | /algoritmo-Fabiano/22-3-exe1.py | 249 | 4.21875 | 4 | '''
1) Escreva um algoritmo para ler um valor e escrever o seu antecessor.
usuario informa um valor
valor=valor - 1
'''
num=int(input("Digite um numero qualquer: "))
valor=num - 1
print("O antecessor do numero digitado é: ", valor)
| false |
af1368faa37377ce0f6df653891f9104d5cd23b6 | Chris-gde/exercicios | /algoritmo-Fabiano/03-05-exe4.py | 699 | 4.15625 | 4 | '''
(4) - Faça um programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a
ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 3 metros quadrados e que a tinta é vendida
em latas de 18 litros, que custam R$ 80,00. Informe ao usuário a quantidades de latas d... | false |
3d0785a60c2af05e31ac80f61d05accc32a7b5e0 | Chris-gde/exercicios | /algoritmo-Fabiano/31-05-desafio2.py | 585 | 4.15625 | 4 | '''
Faça um programa onde o usuário informe a km inicial no momento que o tanque é cheio, no próximo abastecimento
o usuário deve informar os km percorridos e a quantidade de combustível necessária para completar o tanque (l).
O sistema deve informar a o consumo médio (km/l).
'''
n=int(input("Informe a kilometrage... | false |
427e6f0978cd52b339ef4f89256ace7ff9298c4d | learnthecraft617/dev-sprint1 | /RAMP_UP_SPRINT1/exercise54.py | 291 | 4.21875 | 4 |
def is_triangle (a, b, c):
if a > b + c
print "YES!"
else
print "NO!"
is_triangle (4, 2, 5)
#5.4
question = raw_input('Please enter 3 lengths to build this triangle in this order (a, b, c)/n')
length = raw_input (a, b, c)
is triangle (raw_input)
| true |
afed5225df3b7a8cc6b42ba7691710a8a019459d | colten-cross/CodeWarsChallenges---Python | /BouncingBalls.py | 784 | 4.375 | 4 | # A child is playing with a ball on the nth floor of a tall building. The height of this floor, h, is known.
# He drops the ball out of the window. The ball bounces (for example), to two-thirds of its height (a bounce of 0.66).
# His mother looks out of a window 1.5 meters from the ground.
# How many times will the ... | true |
58f99618238ebedc92e013c8b47b259e1fb2b197 | ryadav4/Python-codes- | /EX_05/Finding_largestno.py | 263 | 4.28125 | 4 | #find the largest number :
largest = -1
print('Before',largest)
for i in [1,45,67,12,100] :
if i>largest :
largest = i
print(largest , i)
else :
print(i , 'is less than',largest)
print('largest number is :', largest)
| true |
6faa436ab98bac3d2f6c556f8cb239c48ba72b0f | BusgeethPravesh/Python-Files | /Question6.py | 1,549 | 4.15625 | 4 | """Write a Python program that will accept two lists of integer.
Your program should create a third list such that it contain only odd numbers
from the first list and even numbers from the second list."""
print("This Program will allow you to enter two list of 5 integers "
"\nand will then print the odd num... | true |
f7789e9d8ba69c7974aa42131a6bf08c8cb8a293 | vithalsamp/AlgosWithPython | /merge_insertion_sort.py | 1,470 | 4.21875 | 4 | # This program shows how to speed up merge sort using insertion sort
def merge_insertion_sort(arr):
if len(arr) > 1:
mid = len(arr)//2
L = arr[mid:]
R = arr[:mid]
# Set threshold length of sub-arrays to use insertion sort
# divide array if it is greater then 10
if ... | false |
04890c636e097a33fdad2ff75e9c00be0da9ee06 | Oluyosola/micropilot-entry-challenge | /oluyosola/count_zeros.py | 544 | 4.15625 | 4 | # Write a function CountZeros(A) that takes in an array of integers A, and returns the number of 0's in that array.
# For example, given [1, 0, 5, 6, 0, 2], the function/method should return 2.
def countZeros(array):
# count declared to be zero
count=0
# loop through array length and count the number of ze... | true |
d9504458070080dca24cf9736564196369483c82 | salmonofdoubt/TECH | /PROG/PY/py_wiki/wiki_code/w8e.py | 1,551 | 4.125 | 4 | #!/usr/bin/env python
#8_Lists - test of knowledge
def get_questions(): #Note that these are 3 lists
return [["What color is the daytime sky on a clear day? ", "blue"],
["What is the answer to life, the universe and everything? ", "42"],
["What is a three letter wor... | true |
df7cfa7f74c9ac6d00ee5f0cb1c059aeac69febb | salmonofdoubt/TECH | /PROG/PY/dicts/ex40.py | 800 | 4.1875 | 4 | #!/usr/bin/env python
# encoding: utf-8
"""
Discription: dicts
Created by André Baumann 2012 Copyright (c) Google Inc. 2012. All rights reserved.
"""
import sys
from sys import exit
import os
def find_city(which_state, cities):
if which_state in cities:
return cities[which_state]
else:
return "Not found."
def ... | true |
3de44b016d5b45e0670397bfe59d69aedb9bef33 | salmonofdoubt/TECH | /PROG/PY/classes/dog.py | 1,881 | 4.53125 | 5 | #!/usr/bin/env python
# encoding: utf-8
'''
How to use classes and subclasses
- classes are templates
Created by André Baumann on 2011-12-11.
Copyright (c)2011 Google. All rights reserved.
'''
import sys
import os
class Dog(object): # means Dog inherits from 'object'
def __init__(self, name, breed): #... | true |
2f3e14bec17b97afd523081d2e116dea6ddcd6d8 | salmonofdoubt/TECH | /PROG/PY/py_wiki/wiki_code/w12a.py | 434 | 4.125 | 4 | #!/usr/bin/env python
# 12_Modules
import calendar
year = int(input('Type in the bloody year: '))
calendar.setfirstweekday(calendar.SUNDAY)
calendar.prcal(year) # Prints the calendar for an entire year as returned by calendar().
from time import time, ctime
prev_time = ""
while True:
the_time = ctim... | true |
cb7e18fd05f7cb9b2bedb14e80ceef0c9d5591ea | molusca/Python | /learning_python/speed_radar.py | 955 | 4.15625 | 4 | '''
A radar checks whether vehicles pass on the road within the 80km/h speed limit.
If it is above the limit, the driver must pay a fine of 7 times the difference between the speed that he was
trafficking and the speed limit.
'''
def calculate_speed_difference(vehicle_speed, speed_limit):
return (vehicle_speed - s... | true |
18fa6287bdfec727517bb2073845c911f1494b2f | swatha96/python | /preDefinedDatatypes/tuple.py | 928 | 4.25 | 4 | ## tuple is immutable(cant change)
## its have index starts from 0
## enclosed with parenthesis () - defaultly it will take as tuple
## it can have duplicate value
tup=(56,'swe',89,5,0,-6,'A','b',89)
t=56,5,'swe'
print(type(t)) ## it will return as tuple
print(tup)
print(type(tup)) ## it will return datatyp... | true |
4205c5ca3e4edd81809135f9aa3f79323a0db129 | swatha96/python | /numberDatatype.py | 327 | 4.3125 | 4 | #int
#float
#complex - real and imaginary number: eg:5 : it will return 5+0j
#type() - to get the datatype - predefined function
#input()- predefined function - to get the inputs from the user
a=int(input("enter the number:"))
b=float(input("enter the number:"))
c=complex(input("enter the number:"))
print(a... | true |
317b17c8ac8c70a11950599c1c150feadf2cf034 | swatha96/python | /large_number_list.py | 478 | 4.1875 | 4 | """
number=[23,98,56,26,96,63]
number.sort()
maxi=len(number)
minus=maxi-1
for i in range(maxi):
if(i==minus):
print("the largest number is :",number[i])
"""
number=[]
n=int(input("how many numbers you wants to add:"))
for i in range(n):
num=int(input("enter the number:"))
num... | true |
f341beabb8073553316b8c64b1b0c040a5c82b75 | wf-Krystal/TestDemo | /PTestDemo/funcTest/funcTest4.py | 1,128 | 4.40625 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
#案例5:计算传入的列表的最大值、最小值和平均值,并以元组的方式返回;
import math
def numdel(li):
list = []
list.append(float(max(li)))
list.append(float(min(li)))
sum = 0
for i in li:
sum += float(i)
aver = sum/len(li)
list.append(aver)
return tuple(list)
print... | false |
5fc71703fba3d7be429fa128215cb01ffa0f32c2 | AliPollock/Morar-group-repository | /calculator.py | 302 | 4.1875 | 4 | x=int(input("enter value for x: "))
y=int(input("enter value for y: "))
symbol = input("enter operator ('*', '+', '-', '/'): ")
if symbol == '*':
print(x*y)
elif symbol == '/':
print(x/y)
elif symbol == '+':
print(x+y)
elif symbol == '':
print(x-y)
else:
print("invalid operator")
| false |
fc551bda83861e5a5f921668fc08d3e98b76307e | c344081/learning_algorithm | /01/48_Rotate_Image.py | 1,544 | 4.3125 | 4 | '''
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.
DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Given input matrix =
[
[1,2,3],
[4,5... | true |
f1251d29d364dd65a74150dcdd1c7b4e5a906bbc | 009shanshukla/tkinter_tut_prog | /tkinter3.py | 433 | 4.125 | 4 | from tkinter import*
root = Tk()
######making lable #######
one = Label(root, text="one", bg="red", fg="white") #bg stands for background color
one.pack() #static label
two = Label(root, text="two", bg="green", fg="black")
two.pack(fill=X) #label that streches in x-dir
three = Label(root, t... | true |
545bebe07bcdb15db70b76a9b011e85f1c5bc8b6 | Guillermomartinez03/Tic_20_21 | /python/ejercico_10.py | 344 | 4.34375 | 4 | '''10.Realizar un programa que al recibir un numero entero muestre por pantalla
los 3 numeros anteriores y los 3 numeros siguientes al numero recibido'''
def ejercicio_10 ():
numero=input ("Escribe un numero entero:")
print (numero-1), (numero-2), (numero-3)
print (numero+1), (numero+2), (numero+3)
ejercic... | false |
190ed822b9a78a3415282df127c15aec1a50333f | einian78/The-Complete-Python-3-Course-Beginner-to-Advanced-Udemy-Course | /Section 3 (Programming Basics)/4. Self-Defined Functions.py | 1,129 | 4.375 | 4 |
# Without Arguments:
def my_function(): # recommended style: snake case
print("This is my function!")
my_function() # This is my function
# With Arguments:
def my_function2(str1, str2):
print(str1, str2)
my_function2("Argument 1", "Argument 2") # Argument 1 Argument 2
my_function2("Hello", "World!") ... | false |
6f8af959758fad53d3a36b7da1fb1ea9aeca3777 | einian78/The-Complete-Python-3-Course-Beginner-to-Advanced-Udemy-Course | /Section 3 (Programming Basics)/3. Built-in Functions.py | 706 | 4.21875 | 4 | # print(): prints whatever inside
print("hi!") # hi!
# str(): Converts any type into a string
str(5) # 5
str(True) # True
# int(): Converts any type into a integer
int("5")
# float(): Converts any type into a float
float("5.6")
print(float(1)) # 1.0
# bool(): Converts any type into a boolean
bool("True")
# len... | true |
91945d3b7d3fd6939c0d44e0a08fb8a5e6627af5 | msheikomar/pythonsandbox | /Python/B05_T1_Dictionaries.py | 420 | 4.21875 | 4 | # Dict:
# Name is String, Age is Integer and courses is List
student = {'name':'John', 'age':25, 'courses':['Math', 'CompSys']}
# To get value by using key
print(student['name'])
# To get value by using key
print(student['courses'])
# If you look at the keys are currently being string. But actually it can be any i... | true |
8b393455be6e85cc3825b98fe857d7147c7c1806 | msheikomar/pythonsandbox | /Python/B04_T1_Lists_Tuples_Sets.py | 974 | 4.5 | 4 | # Lists and Tuples allows us to work with sequential data
# Sets are unordered collections of values with no duplicate
# List Example
courses = ['History', 'Math', 'Physics', 'ComSys'] # Create List with elements
print(courses) # To print lists
print(len(courses)) # To print length of list
print(courses[0]) # To a... | true |
d5c7efe1c7f1345be4b3fa2bdc3c1cb218c532e7 | riya1794/python-practice | /py/list functions.py | 815 | 4.25 | 4 | list1 = [1,2,3]
list2 = [4,5,6]
print list1+list2 #[1,2,3,4,5,6]
print list1*3 #[1,2,3,1,2,3,1,2,3]
print 3 in list1 #True
print 3 in list2 #False
print "length of the list : "
print len(list1)
list3 = [1,2,3]
print "comparsion of the 2 list : "
print cmp(list1,list2) # -1 as list1 is small... | true |
c6e4fa1d487e0c922865c44fa8042aad78cf6a96 | crazymalady/Python-Exercises | /ielect_Meeting10/w10_e1fBC_ListOperations_Delete Elements.py | 508 | 4.40625 | 4 | def display():
try:
# We can change the values of elements in a List. Lets take an example to understand this.
# list of nos.
list = [1,2,3,4,5,6]
# Deleting 2nd element
#del list[1]
# Deleting elements from 3rd to 4th
#del list[2:4]
#print(list)
... | true |
d63aa167926b91a246b0219af06e6ffec803a944 | SahityaRoy/get-your-PR-accepted | /Sorting/Python/Insertion_Sort.py | 532 | 4.21875 | 4 | # Python program to implement Insertion Sort
def insertion_sort(arr):
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >= 0 and key < arr[j]:
arr[j + 1] = arr[j]
j = j - 1
arr[j + 1] = key
# Driver function
if... | true |
db188733063d2315b9ba8b8906b24576fc5883cc | SourabhSaraswat-191939/ADA-BT-CSE-501A | /Assignment-2/Insertion_Sort.py | 1,740 | 4.5 | 4 | #Insertion sort is used when number of elements is small. It can also be useful when input array
# is almost sorted, only few elements are misplaced in complete big array.
import time, random, sys
sys.setrecursionlimit(3010)
def insertionSortRecur(arr,n):
if n<=1:
return
insertionSortRecur(arr,n-... | true |
279eaa1adb84a6362e50c16cbcf77fdb96b8c710 | parinita08/Hacktoberfest2020_ | /Python/wordGuess.py | 1,664 | 4.3125 | 4 | import random
# This lib is used to choose a random word from the list of word
# The user can feed his name
name = input("What's your Name? ")
print("Good Luck ! ", name)
words = ['education', 'rainbow', 'computer', 'science', 'programming',
'python', 'mathematics', 'player', 'condition',
'reverse', ... | true |
e9958c2817a63419482cd59df408a156cd3264ae | SwiftBean/Test1 | /Name or Circle Area.py | 656 | 4.40625 | 4 | #Zach Page
#9/13
#get a users name
##def get_name():
### step one: ask user for name
## name = input("what's your name")
###step two: display the name back for user
## print("the name you entered was", name)
###step three: verify the name
## input("is this correct? yes or no")
##
##print("this is our fu... | true |
297443115f368f6f74954748aea31cf38fdb3aad | abhikrish06/PythonPractice | /CCI/CCI_1_09_isSubstring.py | 732 | 4.15625 | 4 | # Given two strings, sl and s2, write code to check if s2 is a rotation of sl using only one
# call to isSubstring (e.g., "waterbottle" is a rotation of"erbottlewat").
def isRotation(str1, str2):
if len(str1) != len(str2):
return False
return isSubstring(str1 + str1, str2)
def isSubstring(st... | true |
ac98777c509e0e92d030fd29f9fc9e33e175d948 | morvanTseng/paper | /TestDataGeneration/data_generation.py | 2,653 | 4.125 | 4 | import numpy as np
class DataGenerator:
"""this class is for two dimensional data generation
I create this class to generate 2-D data for testing
algorithm
Attributes:
data: A 2-d numpy array inflated with 2-D data
points has both minority and majority class
labels: A 1-D nu... | true |
193ba136e0c667b84dcff683355aee443607c556 | olessiap/glowing-journey-udacity | /6_drawingturtles.py | 1,179 | 4.15625 | 4 | # import turtle
#
# def draw_square():
# window = turtle.Screen()
# window.bgcolor("white")
#
# brad = turtle.Turtle()
# brad.shape("turtle")
# brad.color("green")
# brad.speed(2)
# count = 0
# while count <= 3:
# brad.forward(100)
# brad.right(90)
# count = count... | true |
820b6dc8f092a7128bfd1b55d0db7f3b239d3f9a | olessiap/glowing-journey-udacity | /2_daysold.py | 2,007 | 4.375 | 4 | # Given your birthday and the current date, calculate your age
# in days. Compensate for leap days. Assume that the birthday
# and current date are correct dates (and no time travel).
# Simply put, if you were born 1 Jan 2012 and todays date is
# 2 Jan 2012 you are 1 day old.
##breaking down the problem ##
#PSEUDOCOD... | true |
de922ab0471fc5b6976933148f4fcf09ff205cf2 | tianyi33/Python | /river_cases.py | 419 | 4.15625 | 4 | river={'chang jiang':'china',
'huang he':'china',
'qian tang jiang':'china',
'nile':'egypt'}
for name,location in river.items():
if location!="china":
print(name.title()+" is not in my country.")
else:
print(name.title()+' is from my country!')
for name,location in river.items():
print('\nthis river called '... | false |
a9ab2e591e65123d33deb79ffc5467f5199a2f39 | TeeGeeDee/adventOfCode2020 | /Day4/day4.py | 2,221 | 4.125 | 4 |
from typing import List
def parse_records(records_raw:List[str]):
"""Turn list of raw string records (each record across multiple list entries)
to list of dict structured output (one list entry per record)
Parameters
----------
records_raw : List[str]
List of records. Records are se... | true |
ad3564d330aba2b298de30d2f8b41ab2ca6891da | TeeGeeDee/adventOfCode2020 | /Day3/day3.py | 1,066 | 4.125 | 4 |
from typing import List
from math import prod
def traverse(down: int,right: int,terrain: List[str]):
""" Counts number of trees passed when traversing terrane with given step sizes
Parameters
----------
down: int
number of steps to take down each iteration
right: int
number o... | true |
9e72a3b63a392aff565a4cd4bbad93a433a4a29f | matthijskrul/ThinkPython | /src/Fourth Chapter/Exercise7.py | 375 | 4.1875 | 4 | # Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and including n.
# So sum_to(10) would be 1+2+3...+10 which would return the value 55.
def sum_to(n):
s = 0
for i in range(1, n+1):
s += i
return s
def sum_to_constant_complexity(n):
return ((n*n)+n)/2
to... | true |
90e3aa20ceca89debc99ef5b009ad413dd57c625 | matthijskrul/ThinkPython | /src/Seventh Chapter/Exercise15.py | 2,718 | 4.5 | 4 | # You and your friend are in a team to write a two-player game, human against computer, such as Tic-Tac-Toe
# / Noughts and Crosses.
# Your friend will write the logic to play one round of the game,
# while you will write the logic to allow many rounds of play, keep score, decide who plays, first, etc.
# The two of you... | true |
95bf5a53f5b665dec11f4171b5b4877d2f241f08 | mohapsat/python-abspy | /tuples.py | 592 | 4.15625 | 4 | #!/usr/bin/python
# tuple are immutable lists, whose values cannot be changed
tup1 = (1,2,3)
try:
tup1.pop()
except AttributeError:
print "'tuple' object has no attribute 'pop':" + "Please pop from a list"
print tup1
tup2 = tup1 * 3
print "lenght: %d Values: %s" %(len(tup2),tup2)
tup3 = list(tup2)
print tup3
t... | false |
4da17d0305a8c7473bd24624d04fb148a271bc7e | AbelCodes247/Google-Projects | /Calculator.py | 1,240 | 4.375 | 4 | #num1 = input("Enter a number: ")
#num2 = input("Enter another number: ")
#result = int(num1) + int(num2)
#print(result)
#Here, the calculator works the same way but the
#Arithmetic operations need to be changed manually
print("Select an operation to perform:")
print("1. ADD")
print("2. SUBTRACT")
print("3. MULTIPL... | true |
49d4ae16fba58eaa1ebfeb45553eb575b6962b0a | EJohnston1986/100DaysOfPython | /DAY9 - Secret auction/practice/main.py | 1,283 | 4.65625 | 5 | # creating a dictionary
student = {}
# populating the dictionary with key value pairs
student = {"Name": "John",
"Age": 25,
"Courses": ["Maths", "Physics"]
}
# printing data from dictionary
print(student) # prints all key, value pairs
print(student["name"]) # prints only... | true |
ed583b5475071835db5ac8067ccae943e10c432a | LavanyaJayaprakash7232/Python-code---oops | /line_oop.py | 844 | 4.40625 | 4 | '''
To calculate the slope of a line and distance between two coordinates on the line
'''
#defining class line
class Line():
def __init__(self, co1, co2):
self.co1 = co1
self.co2 = co2
#slope
def slope(self):
x1, y1 = self.co1
x2, y2 = self.co2
retu... | true |
40fa436b40b1158b0057e8f5b13208acc748dd5d | a2606844292/vs-code | /慕课网/面向对象/c4.py | 2,149 | 4.15625 | 4 |
class Student(): # 类方法
name = '' # 类变量
age = 0
sum = 0
def __init__(self, name, age): # self代表的是实例
self.name = name # 对实例变量进行赋值
self.age = age
self.__score = 0 # 加__变成私有变量
# print('student')
# print(self.name)
self.__class__.sum += 1
... | false |
4d386f77d415e5e9335763ebb49bc683af7c0fbf | pbeata/DSc-Training | /Python/oop_classes.py | 2,087 | 4.40625 | 4 | import turtle
class Polygon:
def __init__(self, num_sides, name, size=100, color="black", lw=2):
self.num_sides = num_sides
self.name = name
self.size = size # default size is 100
self.color = color
self.lw = lw
self.interior_angles_sum = (self.num_sides - 2) * 180
self.single_angle = self.interior_ang... | true |
2d840cb24543cc55b9cf78d8b5569286db52c510 | pbeata/DSc-Training | /02-Udemy-DS-Bootcamp/exercise_84.py | 1,097 | 4.15625 | 4 |
# Paul A. Beata
# January 29, 2021
import math
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import skew
def compute_skewness(x):
n = len(x)
x_mean = x.mean()
a = x - x_mean
b = a ** 3
numer = (1 / n) * b.sum()
c = a ** 2
d = (1 / n) * c.sum()... | false |
0e087f65ba7b781cda0568712dee4975a49a1bd1 | OkelleyDevelopment/Caesar-Cipher | /caesar_cipher.py | 1,258 | 4.21875 | 4 | from string import ascii_letters
def encrypt(message, key):
lexicon = ascii_letters
result = ""
for char in message:
if char not in lexicon:
result += char
else:
new_key = (lexicon.index(char) + key) % len(lexicon)
result += lexicon[new_key]
return... | true |
f194918b18cd8728d7f5ec5854152b8d5bc4cc2e | rarezhang/ucberkeley_cs61a | /lecture/l15_inheritance.py | 987 | 4.46875 | 4 | """
lecture 15
inheritance
"""
# inheritance
# relating classes together
# similar classes differ in their degree of specialization
## class <name>(<base class>)
# example: checking account is a specialized type of account
class Account:
interest = 0.04
def __init__(self, account_holder):
self.balance = 0
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.