blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
40a867cb13e82c92137838f1a9a0d7cfd515fdc2 | DeveloperJoseph/PYTHON---DE---0---10000 | /Modulo 1/ejercicio4.py | 939 | 4.40625 | 4 |
#ARRAY LISTS SIN CICLO FOR + SALIDA
the_list = ["love","sad","funny","crazy"]#My list of feelings
print(">> The list is (without for): "+str(the_list))#salida de mi lista de array
print("## The item in position '0' of the list is (without for): "+the_list[0])
print("## The item in position '1' of the list is (without... | false |
d86d291ac0a1a21683cd70d4a23bed601a90262a | DeveloperJoseph/PYTHON---DE---0---10000 | /Modulo 1/appBirthday.py | 705 | 4.25 | 4 | dictionary = {}
while True:
print("--- APP BIRTHDAY ---")
print(">>(1) Show birthdays")
print(">>(2) Add to Birthday list")
print(">>(3) Exit")
choice = int(input("Enter the choice: "))
if choice == 1:
if(len(dictionary.keys()))==0:
print("Nothing to show..")
else:
... | true |
29c5eaa6897dbbbb6d3cbfe9d868c5110992366b | DeveloperJoseph/PYTHON---DE---0---10000 | /Modulo 1/ejercicio24.py | 2,464 | 4.34375 | 4 | ## PYTHON JSON ##
# - JSON is a syntax for storing and exchanging data.
# - JSON is text, written with Javascript object notation.
# JSON IN PYTHON:
#Python has built-in package called json, which can be use
#to work with JSON data.
#Example:
# Import the json module:
import json
#Parse JSON - Convert from JSON t... | true |
39773f7d4aa077701cbb9b8bd826f63c5b6169a4 | DeveloperJoseph/PYTHON---DE---0---10000 | /Modulo 3 - File Handling/writeFiles.py | 1,040 | 4.65625 | 5 | # PYTHON FILE WRITE #
#Create a new File:
# To create a new file in Python, use the open() method, with one of the
# following parameter:
# "x" - Create - will create a file, returns an error if the file exist
# "a" - Append - will create a file if the specified file does not exist
#Example:
# Cre... | true |
0663f1986d43764b32f2af2db2bfc3269a0862f1 | gtfotis/python_functions | /functionsExercise.py | 1,542 | 4.125 | 4 | #1. Madlib Function
def make_formal_greeting(name, game):
return ("%s's favorite video game is %s" % (name, game))
def ask_for_user_info():
name = input("What is your name? ")
game = input("What is favorite video game? ")
if len(name) < 1 or len(game) < 1:
print("Terminating since you don't want... | false |
429f9f55f17d32174ab5c856728622926b38c861 | juanmunoz00/python_classes | /ej_validate_user_input.py | 829 | 4.40625 | 4 | ##This code validates if the user's input is a number, it's type or it's a string
##So far no library's needed
##Method that performs the validation
def ValidateInput(user_input):
try:
# Verify input is an integer by direct casting
is_int = int(user_input)
print("Input is an integer: ", is_... | true |
1af6e34b568f7615ffbec35404ca39f4ba851c8b | gjf2a/date_triples | /date_triples.py | 540 | 4.125 | 4 | import calendar
def pythagorean_triple(a, b, c):
return a ** 2 + b ** 2 == c ** 2
def pythagorean_dates(start_year, end_year):
dates = []
c = calendar.Calendar()
for year in range(start_year, end_year + 1):
for month in range(1, 13):
for day in (d for d in c.itermonthdays(year, m... | false |
626dc70789de6e61963051996357f3ba6aae42e6 | noisebridge/PythonClass | /instructors/course-2015/errors_and_introspection/project/primetester4.py | 1,242 | 4.46875 | 4 | """
For any given number, we only need to test the primes below it.
e.g. 9 -- we need only test 1,2,3,5,7
e.g. 8 -- we need only test 1,2,3,5,7
for example, the number 12 has factors 1,2,3,6,12.
We could find the six factor but we will find the two factor first.
The definition of a composite number is that it is co... | true |
9c81264446ef2fd968208b79fd0d696409bb5f83 | noisebridge/PythonClass | /instructors/lessons/higher_order_functions/examples/closure1.py | 1,509 | 4.15625 | 4 | """
This example intentionally doesn't work.
Go through this code and predict what will happen, then run
the code.
The below function fixes i in the parent scope, which means
that the function 'f' 'gets updates' as i progresses through
the loop.
Clearly we need to somehow fix i to be contained in the local
scope for... | true |
f412f50e278ad7ba058891a8e463625155bffdfb | noisebridge/PythonClass | /instructors/projects-2015/workshop_100515/quick_sort.py | 1,124 | 4.1875 | 4 | """ Quick Sort
Implement a simple quick sort in Python.
"""
# we'll use a random pivot.
import random
def my_sorter(mylist):
""" The atomic component of recursive quick sort
"""
# we are missing a base case
if len(mylist) == 1:
return mylist
# do we need this?
if len(mylist) == 0:
... | true |
9db3cd6f2fbadcfa1e558ac85e38bb1129f163b2 | noisebridge/PythonClass | /instructors/lessons/functions_and_gens/examples/example0.py | 618 | 4.1875 | 4 | #Return the absolute value of the number x. Floats as well as ints are accepted values.
abs(-100)
abs(-77.312304986)
abs(10)
#Return True if any element of the iterable is true. If the iterable is empty, return False.
any([0,1,2,3])
any([0, False, "", {}, []])
#enumerate() returns an iterator which yields a tuple tha... | true |
9846b1a24c40d2da5e5737d15c2a92725560e7c0 | otobin/CSSI-stuff | /Python/Playground.py | 2,806 | 4.46875 | 4 | # #!/usr/bin/python
#
#
# # # # print("Hello, World!")
# # # #
# # # #
# # # #
# # # # i = 0
# # # #
# # # # while (i < 3):
# # # # num = int(input("Enter a number"))
# # # #
# # # # if num > 0:
# # # # print("This number is positive")
# # # # elif num < 0:
# # # # print("This number is nega... | false |
908accf654cd559a95b1ce89dd9b4b1e332cabe1 | makcipes/budg-intensive | /day_1/scope/task_1/question.py | 580 | 4.25 | 4 | """
Что будет выведено после выполнения кода? Почему?
"""
x = 42
def some_func():
global x
x = x + 1
print(x)
some_func()
print(x)
"""выведет 2 раза чилсло 43 тк в функции мы определили глобальную переменную и прибавили к ней единицу
тоесть, при выполнении some_func мы прибавили единицу к числу , a... | false |
3d7581fb9378298bd491df6a5f54063a659ae965 | PhuocThienTran/Learning-Python-During-Lockdown | /30DaysOfPython/chapter6/strings.py | 720 | 4.125 | 4 | word = "Ishini"
def backward(word):
index = len(word) - 1
while index >= 0:
print(word[index])
index -= 1
backward(word)
fruit = "apple"
def count(fruit, count):
count = 0
for letter in fruit:
if letter == "p":
count = count + 1
print("Amount of p:", count)
coun... | true |
b1d766d3d8a6a7635f7c928e085844594e0eb329 | PhuocThienTran/Learning-Python-During-Lockdown | /30DaysOfPython/chapter5/iteration.py | 1,479 | 4.3125 | 4 | import math
n = 5
while n > 0:
print(n)
n =- 1
print("Launched!")
while True:
line = input('> ')
if line == 'done':
break #this means if input is "done" -> break the while loop
print(line)
print('Done!')
while True:
usr_line = input('> ')
if usr_line[0] == '#':
continue #... | true |
425a7de115ec728612aa7bdbbe81d2b3c0395fe3 | pujaaryal89/PythonAssignment | /function/function1.py | 555 | 4.125 | 4 | def max_num(num_list):
largest_num=num_list[0]
for num in num_list[1:]:
if num >largest_num:
largest_num=num
return largest_num
number = input('Enter a number separate by comma: ').split(',')
# print(number)
#split le pailai , bata split garera list ma leraauxa
num=[int(x) ... | false |
ad1894bc97e870b14a06d8dd46bcc6ff9875cdb5 | rakshithvasudev/Datacamp-Solutions | /Recommendation Engines in Pyspark/How ALS works/ex16.py | 606 | 4.28125 | 4 | """
Get RMSE
Now that you know how to build a model and generate predictions, and have an evaluator to tell us how well it predicts ratings, we can calculate the RMSE to see how well an ALS model performed. We'll use the evaluator that we built in the previous exercise to calculate and print the rmse.
Instructions
100... | true |
c34d4873e498d568971b362d20e40af0a16d0a16 | kopxiong/Leetcode | /sort/python3/01_bubble_sort.py | 1,315 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# 冒泡排序 (Bubble Sort) 是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,
# 如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。
# 这个算法的名字由来是因为越小的元素会经由交换慢慢“浮”到数列的顶端。
# Time complexity: O(n^2)
class Solution(object):
def bubbleSort(self, lists):
n = len(lists)
# after each iteration, the ... | false |
5e5e7df63660f904a45f4350df321e9ce8d600c0 | tbeaux18/rosalind | /point_mutation.py | 1,127 | 4.34375 | 4 | #!/usr/bin/env python3
"""
@author: Timothy Baker
@version: 01/15/2019
Counting Point Mutations Rosalind
Input:
Standard Input
Output:
Console
"""
import sys
def hamming_distance(sequence_one, sequence_two):
""" Calculates hamming distance between 2 strings
Args:
sequence_one (str) ... | true |
22cfe29daf5a9adca5e908e8c4fda15132536133 | sapalamut/homework | /ClassWork_4.py | 1,764 | 4.25 | 4 | # FUNCTIONS
# Ex:1
def add_two_numbers(num1, num2):
return num1 + num2
result = add_two_numbers(1, 2)
print(result)
print(add_two_numbers(1, 2))
first = 1
second = 2
third = 3
print(add_two_numbers(first, second), add_two_numbers(second, third))
print('\n')
# Ex:2
def print_hello_world():
print("Hello Wolrd")
print... | true |
ca6f5f7bb7fc627f7278170fecbb630e5a00ec7c | RRRustik/Algorithms | /alg_lesson_1.8.py | 567 | 4.21875 | 4 | """8. Вводятся три разных числа. Найти, какое из них является средним (больше одного, но меньше другого)."""
n1 = int(input("Введите первое число: "))
n2 = int(input("Введите второе число: "))
n3 = int(input("Введите третье число: "))
if n1 > n2 and n1 < n3:
print(f'{n1} - среднее число')
elif n2 > n1 and n2 < n3... | false |
44d2fe6c8ff90183d9826fdb89850085071f2f32 | darrenrs/ica-projects | /ICA Creative Applications/Python/Python Turtle/main.py | 1,766 | 4.1875 | 4 | import turtle
import math
'''
void drawLine(int x, int y):
draws a single line
'''
def drawLine(x, y):
turtle.penup()
turtle.setposition(x, y)
turtle.pendown()
turtle.forward(math.sqrt(50**2+50**2))
'''
void drawSquare(int x, int y, int d):
draws a square
'''
def drawSquare(x, y, d):
turtle.setp... | false |
7dd17ad1a08aa1fe100a432bdb76f3fea11b371c | andreferreira4/Programa-o1 | /ficha 2 entregar/ex2.py | 799 | 4.21875 | 4 | #Exercício2
Numero1 = int(input("Escreva o primeiro número "))
Numero2 = int(input("Escreva o segundo número "))
Numero3 = int(input("Escreva o terceiro número "))
if Numero1 > Numero2 and Numero2 > Numero3 :
print("{} > {} > {}".format(Numero1,Numero2,Numero3))
elif Numero1 > Numero2 and Numero1 > Numero3 :
... | false |
5766534c0e915f055d9fdfe3d2451303ddfbc1d7 | zs18034pn/ORS-PA-18-Homework07 | /task2.py | 727 | 4.375 | 4 |
"""
=================== TASK 2 ====================
* Name: Recursive Sum
*
* Write a recursive function that will sum given
* list of integer numbers.
*
* Note: Please describe in details possible cases
* in which your solution might not work.
*
* Use main() function to test your solution.
========================... | true |
d93b00c503f7cf24933359240b330423efc511e2 | Chris-uche/Pythonbasics | /Work/loops.py | 670 | 4.15625 | 4 | for x in range(0,10,2): #start,stop,step
print(x)
#The While Loop section
uche = True
while uche:
name = input("insert something here: ")
if name == "stop":
uche = False
break
Fredschoolname = True
while Fredschoolname:
nameOfschool =input("insert Fred's schoool name: ")
if nam... | false |
bbf65e88dffba753cd3ae13fef8d76c2e6439692 | CodeBall/Learn-Python-The-Hard-Way | /yanzilu/ex32.py | 2,647 | 4.4375 | 4 | # -*- coding: utf-8 -*-
#Exercise 32:Loops and List
the_count = [1,2,3,4,5]
fruits = ['apples','oranges','pears','banana']
change = [1,'pennies',2,'dimes',3,'quarters']
print "change[0]: ", change[0]
print "change[2:5]: ", change[2:5]
#this first kind of for-loop goes through a list
for number in the_count:
print "... | true |
6248d8ced78cf9b217c28b88189424dae0b41e01 | starschen/learning | /data_structure/binaryTreeTravle.py | 2,590 | 4.21875 | 4 | #encoding:utf8
#二叉树的遍历(前、中、后)
#代码来源:http://blog.csdn.net/littlethunder/article/details/9707669,仅学习用
class Node:
def __init__(self,value=None,left=None,right=None):
self.value=value
self.left=left
self.right=right
#此部分为后加,代码来源http://www.cnblogs.com/sunada2005/p/3326160.html
class BinaryTree... | false |
7b7ea0f2690579220e1dd50f8151e0214c950ec8 | hxsnow10/BrainNN | /SORN/general_model.py | 2,398 | 4.15625 | 4 | '''一个general的RNN
应该定义的计算结构
'''
class RNN(SimpleRecurrent):
'''
some abstract model to define structural RNN.
abstracts of RNN is dynamic systems, all variables has it's dynamics, \
when in NN some as states some as weights.
when NN become more complex, for example biology models, LSTM, multi\
... | true |
5081fb1aabe670d901a8215ac85d44233bf715b2 | biroska/Python-Study | /repeticao/DigitoAdjacente.py | 982 | 4.1875 | 4 | # Este programa contempla a resolução do primeiro exercício opcional do curso:
# Introdução à Ciência da Computação com Python Parte 1
# Disponível no coursera.
#
# EXERCÍCIO OPCIONAL 2
# Escreva um programa que receba um número inteiro na entrada e verifique se o número
# recebido possui... | false |
089ff3c062a5b18c9f1c318561e8603d5ddc62ee | biroska/Python-Study | /condicionais/Ordenados.py | 633 | 4.34375 | 4 | # Este programa contempla a resolução do primeiro exercício opcional do curso:
# Introdução à Ciência da Computação com Python Parte 1
# Disponível no coursera.
#
# EXERCÍCIO 5
# Receba 3 números inteiros na entrada e imprima crescente se eles forem dados em
# ordem crescente. Caso contrário, im... | false |
176fb212620acdcf861e9999a496d699c730fc11 | biroska/Python-Study | /repeticao/SomaDigitos.py | 511 | 4.1875 | 4 | # Este programa contempla a resolução do primeiro exercício opcional do curso:
# Introdução à Ciência da Computação com Python Parte 1
# Disponível no coursera.
#
# EXERCÍCIO 2
# Escreva um programa que receba um número inteiro na entrada, calcule e imprima
# a soma dos dígitos deste númer... | false |
14211c899a064cff7330fba2bd74711c4dc0dda6 | monkeesuit/Intro-To-Python | /scripts/trialdivision.py | 479 | 4.15625 | 4 |
num = int(input('Enter a numer to be check for primality: '))
ceiling = int(pow(num, .5)) + 1 # Get ceiling of sqaure root of number (b/c of how range works
for i in range(2, ceiling):
if (num % i == 0): # if any number between 2 and ceiling-1 divides num
print('{} is composite'.format(num)) ... | true |
924e46c90bc31ed5fd44ccc3da128734d006fb1a | martincxx/PythonPlay | /PythonforAstronomers/exercise2.py | 356 | 4.125 | 4 | """2. Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise.
2.1. Use the module re (regular expressions)"""
def find_m(word):
import re
if re.match("[aeiou]$",word.lower()):
return True
else:
return False
print find_m("A")
... | true |
87031f94d2855382675da6a49829599fca6792a5 | poojan14/Python-Practice | /Automate the boring stuff with python/Pattern_Matching_With_Regular_Expressions/Regex Version of strip().py | 443 | 4.1875 | 4 | import re
def strip(string , sep = None):
if sep == None:
sep = '\s'
return re.sub(r'^[{0}]+|[{0}]+$'.format(sep),'',string) #first {0} is replaced by {sep}
if __name__ == '__main__':
string = input('Enter string : ')
sep = input('Enter character to be strip... | false |
0902f72d26a0a9cc71e41dfa76f0b5b7e62bf07e | poojan14/Python-Practice | /GeeksForGeeks/Good or Bad string.py | 1,378 | 4.125 | 4 | '''
In this problem, a String S is composed of lowercase alphabets and wildcard characters i.e. '?'. Here, '?' can be replaced by any of the
lowercase alphabets. Now you have to classify the given String on the basis of following rules:
If there are more than 3 consonants together or more than 5 vowels together, the S... | true |
def77432cc97bb70a22c8e37b0e237b05f3dbb9e | poojan14/Python-Practice | /Data Structures and File Processing/Heap/Heap_Class.py | 2,756 | 4.25 | 4 | import math
class Heap:
heap=[]
def __init__(self):
'''
Objective : To initialize an empty heap.
Input parameters :
self : Object of class Heap.
Output : None
'''
#Approach : Heap is an empty list.
self.heap=[]
def ... | true |
617d3cdc74bcc4d7f1cd3489881efb9da784dfcc | bilaer/Algorithm-And-Data-Structure-Practices-in-Python | /heap_sort.py | 1,922 | 4.25 | 4 | ####################################
# Heap Sort #
# ##################################
# #
# Max_heapify: O(lgn) #
# Build_max_heap: O(n) #
# Overall performance is O(nlgn) #
# #
########################... | true |
1be2eb9e19b8341b6622460623edd22664d8f5f2 | pawloxx/CodeWars | /CreditCardValidifier.py | 1,340 | 4.34375 | 4 | """
Make a program that sees if a credit card number is valid or not.
Also the program should tell you what type of credit card it is if it is valid.
The five things you should consider in your program is: AMEX, Discover, VISA, Master, and Invalid :
Discover starts with 6011 and has 16 digits,
AMEX starts with 34 or 37... | true |
ef4501237a29658db20410fa1825da1346b56483 | ArnoldCody/Python-100-exercise | /exercise6.py | 1,066 | 4.21875 | 4 | # coding=utf-8
"""
题目:斐波那契数列。
程序分析:斐波那契数列(Fibonacci sequence),又称黄金分割数列,指的是这样一个数列:0、1、1、2、3、5、8、13、21、34、……。
在数学上,费波那契数列是以递归的方法来定义:
F0 = 0 (n=0)
F1 = 1 (n=1)
Fn = F[n-1]+ F[n-2](n=>2)
"""
"""
# 这个函数可以输出制定从 0~i 的数列,比较省内存,计算 i 很大的时候很快得出结果
def Fib(i):
Fib = []
Fib.append(0)
Fib.append(1)
n = 2
... | false |
b5c453b32461e11eb27c42b38ca495a94a33124a | ArnoldCody/Python-100-exercise | /exercise4.py | 1,134 | 4.1875 | 4 | # coding:utf-8
# 题目:输入某年某月某日,判断这一天是这一年的第几天?
birthday = raw_input("please input birthday, like yyyymmdd: ")
# 检验是否为闰年
def leap_year(year):
if year%4 == 0:
return True
else:
return False
# 定义每月的天数
def month_has_days(month):
for i in [1, 3, 5, 7, 9, 10, 12]:
if month == i:
... | false |
22523d88e2faa931e6535429110634ab47a564e0 | Megatech13/Pythontutor | /Lesson 1. Data input and output/1. Problem Sum of three numbers.py | 451 | 4.125 | 4 | # Условие
# Напишите программу, которая считывает три числа и выводит их сумму. Каждое число записано в отдельной строке.
a = int(input())
b = int(input())
c = int(input())
print(a + b + c)
# Если аргументов намного больше, то можно так
# c = 0
# for i in range(10):
# a = int(input())
# c += a
# print(c) | false |
1721135b50b49c0cfb109712ce9355a7695bb438 | Jaykb123/jay | /jay1.py | 831 | 4.5 | 4 |
print("To check the greater number from the given number!".center(70,'-'))
# To take a numbers as an input from the user.
first_num = int(input("Enter the first number: "))
second_num = int(input("Enter the second number: "))
third_num = int(input("Enter the third number: "))
# To check among the num... | true |
8f711d9c3fd1c55bad77a4a1980c5d6a4bea22c6 | tusharpl/python_tutorial | /max_value_function.py | 502 | 4.125 | 4 | # Get the list of values ..here it is student scores
student_scores = input("Enter the list of student scores").split()
# change str to integer so that calculations can be done
for n in range(0, len(student_scores)):
student_scores[n] = int(student_scores[n])
print(student_scores)
# find max value through iterat... | true |
ff508760139b4197b86726ac82a698f82ae8caec | QasimK/Project-Euler-Python | /src/problems/p_1_49/p19.py | 2,544 | 4.28125 | 4 | '''
You are given the following information, but you may prefer
to do some research for yourself.
* 1 Jan 1900 was a Monday.
* Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on le... | true |
b108c2c7de3669c11c6e765d6e213619aa3d91fe | QasimK/Project-Euler-Python | /src/problems/p_1_49/p23.py | 2,656 | 4.125 | 4 | '''
A perfect number is a number for which the sum of its
proper divisors is exactly equal to the number.
For example, the sum of the proper divisors of 28
would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is
a perfect number.
A number n is called deficient if the sum of its proper
divisors is less than n and it i... | true |
ed0baab15b160004bc09324389f4b13c2a927266 | sap218/python | /csm0120/02/lect_02b_hw.py | 663 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 12 11:03:24 2017
@author: sap21
"""
'''
An interactive game to exercise what you know about variables, if statements, loops and input/output.
Game: Guess the secret number!
● Initialise a variable to hold a secret number of your choice.
● Prompt th... | true |
f7115ec803f7fa5935712ad690bc385142dcbbeb | Phantsure/algo-rythm-urf-algorithm | /Searching/python/fibonacciSearch.py | 1,185 | 4.15625 | 4 | #List should be in Sorted ascending order
from bisect import bisect_left
def fibonacciSearch(arr, x, n):
# Initialize fibonacci numbers
m2 = 0 # (m-2)'th Fibonacci No.
m1 = 1 # (m-1)'th Fibonacci No.
m = m2 + m1 # m'th Fibonacci
# m is going to store the smallest
... | false |
3978a26c7eae2acc34309229aba939942f55edf8 | mellosilvajp/projetos_unipampa | /teste github/exercicios_vetores_14.py | 1,728 | 4.15625 | 4 | # https://www.passeidireto.com/arquivo/56813560/listas-em-python-exercicios-iniciais
#
# Os alunos de uma turma foram muito mal em uma prova.
# O professor resolveu, então considerar a maior nota como o 10.0 e transformar as demais notas em relação
# a esta nota da seguinte maneira: nota do aluno * 10/ maior nota.
# F... | false |
5c773bead4c91bd8a50fb5441f9631cbe9edc027 | yurizirkov/PythonOM | /if.py | 657 | 4.125 | 4 | answer = input("Do you want to hear a joke?")
#affirmative_responses = ["Yes", "yes", "y"]
#negative_responses = ["No", "no", "n"]
#if answer.lower() in affirmative_responses:
#print("I am against picketing, but I do not know how to show it.")
#elif answer.lower() in negative_responses:
#print("Fine")
#i... | true |
b40fa3ed7cfd83a46f24eaa9fbcc05b5ad35dee3 | Xigua2011/mu_code | /names.py | 278 | 4.28125 | 4 | name = input("What is your name?")
print("Hello", name)
if name=="James":
print("Your name is James. That is a silly name")
elif name=="Richard":
print("That is a good name.")
elif name=="Anni":
print("Thats a stupid name")
else:
print("I do not know your name") | true |
628e319d65d3dd83d540ab326913f2bb62cca265 | shivveerq/python | /replacementop.py | 430 | 4.25 | 4 | name="shiva"
salary=15000
gf="sunny"
print("Hello {0} your salary is {1} and your girlfriend waiting {2}".format(name,salary,gf)) # wint index
print("Hello {} your salary is {} and your girlfriend waiting {}".format(name,salary,gf))
print("Hello {x} your salary is {y} and your girlfriend waiting {z}".format(x=na... | true |
b4c433ee6ddb5c5f1e04c27963d9b56ce104ce87 | pavarotti305/python-training | /while_loop.py | 599 | 4.125 | 4 | print('')
print("Use while with modulus this expression for x in xrange(2, 21): is the same as i = 2 while i < 21:")
i = 2
while i < 21:
print(i)
stop10 = i == 10
if i % 2 != 0:
break
if stop10:
break
i += 2
print('')
print("Same code with for")
for x in range(2, 21):
if x % 2 =... | true |
a37de490c4738e54d1f68f6194af7c2a47c96969 | pavarotti305/python-training | /if_else_then.py | 2,994 | 4.4375 | 4 | print('')
print('''Here is the structure:
if expression: like on this example if var1 is true that means = 1 print the value of true expression
statement(s)
else: else var1 is false that means = 0 print the value of false expression
statement(s)''')
truevalue = 1
if truevalue:
print("1 - Got a true expression valu... | true |
f62f9f153a2b413d32bf07f4cd9e660e4adfcfea | SaurabhRuikar/CdacRepo | /Python and Advanced Analytics/Lab Practice/ConsonantReplace.py | 1,176 | 4.15625 | 4 | '''
Q. 1. Given a dictionary of students and their favourite colours:
people={'Arham':'Blue','Lisa':'Yellow',''Vinod:'Purple','Jenny':'Pink'}
1. Find out how many students are in the list
2. Change Lisa’s favourite colour
3. Remove 'Jenny' and her favourite colour
4. Sort and print students and their favourite colours ... | true |
8ee6a5e0a13f0db31fdae73f1492ba225a6c480d | SaurabhRuikar/CdacRepo | /Python and Advanced Analytics/Advanced Analytics/libraries3.py | 1,819 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 7 17:19:54 2019
@author: student
"""
import sys
import numpy as np
def createArange():
r1=int(input("Enter the number of rows for matrix A "))
c1=int(input("Enter the number of column for matrix A "))
m1=r1*c1
a=np.arange(m1).re... | true |
14e688e1b7f4f8116a1ac43140a8bb508bcfa392 | SaurabhRuikar/CdacRepo | /Python and Advanced Analytics/Database/sqlite3/database.py | 2,039 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 6 12:27:14 2019
@author: student
"""
import sqlite3
import sys
db=sqlite3.connect('mydb1.db') #Connecting to database
if db!=None:
print("Connection done")
else:
print("Connection not done")
cursor=db.cursor() #cursor generate some... | true |
92799c5dad508dbe76b9a231dc82cfa22e01b7f5 | erferguson/CodeWars | /9.13.20/kata.py | 1,639 | 4.15625 | 4 | # 8kyu
# This kata is from check py.checkio.org
# You are given an array with positive numbers and a number N.
# You should find the N-th power of the element in the array with the index N.
# If N is outside of the array, then return -1.
# Don't forget that the first element has the index 0.
# Let's look at a f... | true |
9dfe1eb181d7260f35d81c380e385008ebcf519d | run-fourest-run/PythonBeyondTheBasics | /Inheritence/singleinheritence.py | 885 | 4.15625 | 4 | ####Example given by instructor#####
class Base:
def __init__(self):
print('Base Intilizer')
def f(self):
print('Base.f()')
class Sub(Base):
def __init__(self):
super().__init__()
print('Sub Intilizer')
def f(self):
print('Sub.f()')
#####################Sel... | false |
1c44e33f725fbc0d5268277482ce1c001c614025 | rkidwell2/teachingPython | /HowManyCows.py | 1,444 | 4.21875 | 4 | """
Rosalind Kidwell
6/26/19
This program creates an interactive riddle for the cow game,
and is being used to demonstrate python fundamentals for high school students
"""
import random
from time import sleep
def cows():
print('')
myList = [[0, "? "],
[2, "How many? "],
[3, "How ma... | true |
389b2826c6f9ab6a0ab39423ff8a7c66311f05e7 | em0flaming0/Mock-Database | /mock_db.py | 1,075 | 4.34375 | 4 | #!/usr/bin/python
#demonstrating basic use of classes and inheritance
class Automobile(object):
def __init__(self, wheels):
self.wheels = wheels #all autmobiles have wheels
class Car(Automobile):
def __init__(self, make, model, year, color):
Automobile.__init__(self, "4") #all Car objects should have 4 whee... | true |
6cdc61e07a9a2a52d7c07a5a48570e4f2d80c0ce | aliamjad1/Data-Structure-Fall-2020 | /BubbleSorting.py | 571 | 4.28125 | 4 | ##It compares every index like [2,1,4,3]-------Firstly 2 compare with 1 bcz of greater 1 is moved towards left and 2 is on right
# [1,2,4,3]
def bubblesort(list):
listed=len(list)
isSorted=False
while not isSorted:
isSorted=True
for eachvalue in range(0,listed-1):
if list[eac... | true |
4a117edd4e73e2a8830804061c0f3e61a7ea4865 | trademark152/Data_Mining_USC | /hw5/test.py | 1,156 | 4.15625 | 4 | import re
import random
def isprime(num):
# If given number is greater than 1
if num > 1:
# Iterate from 2 to n / 2
for i in range(2, num // 2):
# If num is divisible by any number between
# 2 and n / 2, it is not prime
if (num % i) == 0:
retu... | true |
8b398401d12c5c9470dabcf3acf682e91aa3520a | RokKrivicic/webdevelopment2 | /Homeworks/homework1.py | 840 | 4.21875 | 4 | from smartninja_sql.sqlite import SQLiteDatabase
db = SQLiteDatabase("Chinook_Sqlite.sqlite")
# all tables in the database
db.print_tables(verbose=True)
#This database has many tables. Write an SQL command that will print Name
# from the table Artist (for all the database entries)
db.pretty_print("SELECT Name FROM A... | true |
a1675e46df676847b8576ef35a2ef5bf95061fab | Omisw/Python_100_days | /Day 3/leap_year.py | 950 | 4.53125 | 5 | # Day 3 - Third exercise.
# Leap Year
# Instructions
# Write a program that works out whether if a given year is a leap year. A normal year has 365 days, leap years have 366, with an extra day in February.
# The reason why we have leap years is really fascinating, this video does it more justice:
# This ... | true |
93dc5203b837b3ce41dd6df3051f1e8446113245 | Omisw/Python_100_days | /Day 10/Calculator/main.py | 1,438 | 4.1875 | 4 | # Day 10 - Final challenge.
from art import logo
# from replit import clear
def add(number_1, number_2):
return number_1 + number_2
def subtract(number_1, number_2):
return number_1 - number_2
def multiply(number_1, number_2):
return number_1 * number_2
def divide(number_1, number_2):
return number_1 / numbe... | true |
24c5920330ecb18cad06ee63444aa9432ad58dfc | Omisw/Python_100_days | /Day 9/dictionary_in_list.py | 1,258 | 4.5 | 4 | # Day 9 - Second exercise.
# Dictionary in List
# Instructions
# You are going to write a program that adds to a travel_log. You can see a travel_log which is a List that contains 2 Dictionaries.
# Write a function that will work with the following line of code on line 21 to add the entry for Russia to the travel_l... | true |
498e80a75aa31b4bad5652b9cebc4f0c11dfeb7a | Omisw/Python_100_days | /Day 9/grading_program.py | 1,517 | 4.65625 | 5 | # Day 9 - First exercise.
# Instructions
# You have access to a database of student_scores in the format of a dictionary. The keys in student_scores are the names of the students and the values are their exam scores.
# Write a program that converts their scores to grades. By the end of your program, you should have ... | true |
62d5ab70daaf6ea89567f6e2e3903f481401dc29 | eddieatkinson/Python101 | /guess_num_high_low.py | 421 | 4.25 | 4 | # Guess the number! Gives clues as to whether the guess is too high or too low.
secret_number = 5
guess = 2
print "I'm thinking of a number between 1 and 10."
while secret_number != guess:
print "What's the number?"
guess = int(raw_input("> "))
if (guess > secret_number):
print "%d is too high. Try again!" % guess... | true |
1fb3875553dd99fb89943a9c954029f1d0213877 | saddamarbaa/object-oriented-programming-concepts | /Intro OOP1.py | 1,187 | 4.4375 | 4 | # Object Oriented Programming
# Class and Object in Python
# Robot class
class Robot:
# instance attribute
def __init__(self, name, color, weight):
self.name = name
self.color = color
self.weight = weight
# instance method
def introduce_self(self):
print(... | true |
92d3eeecb0efceb24b34a7f87488d3296c7d99de | lelongrvp/Special_Subject_01 | /homeword_2/problem3.py | 1,856 | 4.53125 | 5 | # Obtain phone number from user and split it into 3 parts
phone_number = input('Enter a phone number using the format XXX-XXX-XXXX: ')
split_number = phone_number.split('-')
#initializing some control variables
weird_character = False # True will stop while loop and display an error
count = 0 # Keeps tra... | true |
44746aec5d7405051b68ec4f1ead570f57e57ce0 | tnovak123/hello-spring | /crypto/caesar.py | 567 | 4.1875 | 4 | from helpers import rotate_character, alphabet_position
def encrypt(text, rot):
newtext = ""
for char in text:
if char.isalpha() == True:
newtext += rotate_character(char, rot)
else:
newtext += char
return(newtext)
def main():
inputtext = ""
displace = 0
inputtext... | true |
d6c30d2048e7e815b9550b05e2abe1966c7d4332 | probuse/prime_numbers | /prime_numbers_.py | 810 | 4.15625 | 4 | def prime_numbers(n):
"Generate prime numbers between 0 and n"
while isinstance(n, int) and n > 0:
prime = []
def is_prime(number):
"Tests if number is prime"
if number == 1 or number == 0:
return False
for num in range(2, number):
... | true |
2d195bd9e64a571692a80213e75beddf8235052c | ironboxer/leetcode | /python/214.py | 983 | 4.15625 | 4 | """
https://leetcode.com/problems/shortest-palindrome/
Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.
Example 1:
Input: "aacecaaa"
Output: "aaacecaaa"
Example 2:
Input: "abc... | true |
bc509ad8e8375270c803a118c24746d45af97088 | ironboxer/leetcode | /python/49.py | 1,050 | 4.1875 | 4 | """
https://leetcode.com/problems/group-anagrams/
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Example 1:
In... | true |
9b79ae5a9eaadcef2a1be81c479ca9675c0d3553 | ironboxer/leetcode | /python/231.py | 652 | 4.125 | 4 | """
https://leetcode.com/problems/power-of-two/
Given an integer, write a function to determine if it is a power of two.
Example 1:
Input: 1
Output: true
Explanation: 20 = 1
Example 2:
Input: 16
Output: true
Explanation: 24 = 16
Example 3:
Input: 218
Output: false
"""
class Solution:
def isPowerOfTwo(self,... | true |
9e4fc7517fbe8fd3e2f9c68694b0692e5ad0eef4 | Steven4869/Simple-Python-Projects | /excercise21.py | 434 | 4.25 | 4 | #Amstrong number
print("Welcome to Amstrong number checker, if the number's sum is same as the sum of the cubes of respective digits then it is called Amstrong number")
a=int(input("Please enter your number\n"))
sum=0
temp=a
while(temp >0):
b=temp%10
sum+=b **3
temp//=10
if(a==sum):
print(a,"is an Amstr... | true |
8331900c3a1c5d994c1b3616e62198af66396cb4 | RainbowBite/Project_Eilera | /1-10/py1.py | 2,286 | 4.21875 | 4 | """
Если выписать все натуральные числа меньше 10, кратные 3 или 5, то получим 3, 5, 6 и 9. Сумма этих чисел равна 23.
Найдите сумму всех чисел меньше 1000, кратных 3 или 5.
"""
# создаем переменную = список
zed = []
# заполняем список числами от одного до 1000
for i in range(1,1001):
zed.append(i) # append запи... | false |
b15b77753c5241a39900ca8f697e160215d794e3 | emersonleite/python | /Introdução a Programação com Python - exercícios baixados do site oficial/Exercícios/exercicio-04-04.py | 791 | 4.34375 | 4 | ##############################################################################
# Parte do livro Introdução à Programação com Python
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2014
# Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8
# Primeira reimpressão - Outubro/2011
# Segunda reimpressão - ... | false |
7988fec9082331a5ca49538884019261be7bc21c | emersonleite/python | /Introdução a Programação com Python - exercícios baixados do site oficial/Exercícios/exercicio-06-07.py | 1,014 | 4.15625 | 4 | ##############################################################################
# Parte do livro Introdução à Programação com Python
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2014
# Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8
# Primeira reimpressão - Outubro/2011
# Segunda reimpressão - ... | false |
a92a5371ecbf8a8b7e80695f1935ea44606983fb | davidholmes1999/first-project1 | /Holmes_numbergenerator.py | 892 | 4.15625 | 4 | #David Holmes
#3/9/17
#Number Simulator
#Print Statements
print("\nWeclome to the number simulator game! You will be seeing how many guesses it takes for you to guess my number!\n")
print("\nFirst let me think of a number between 1 and 100\n")
print("\nHmmmmmm...\n")
import random
#Defining Variables
... | true |
21d764b5c154ea14771a48b5e0c0d9b0bcac4509 | bhagyamudgal/learning-python | /data-types/data-types.py | 2,563 | 4.125 | 4 | # Variables
num1 = 10
num2 = 5
num3 = 2
num4 = 3
print("Sum of 10 and 5 is", num1 + num2)
print("Differnce of 10 and 5 is", num1 - num2)
print("Product of 10 and 5 is", num1 * num2)
print("Dividend of 10 and 5 is", num1 / num2)
print("Remainder of 10 and 5 is", num1 % num2)
print("2 to the power of 3 is", num3**num4)
p... | false |
fd74144669b2dfb6dd3ad08b4ad8f029d817b0d3 | Dexmo/pypy | /playground.py | 1,126 | 4.21875 | 4 | values = (1,2,3,4,5) #tuple - immutable, orderly data structure
squares = [value**2 for value in range(1,11)] #list comprehension
''' 3 short subprogram for quick work '''
print(max(values))
print(min(values))
print(sum(values))
print(squares)
'''---------------------------------------'''
for number in range(1, 21):
... | true |
956fd0812e6565fa8f6843af933c225e7ae22a7c | emailman/Raspberry_Pi_Heater | /sorted grades/function demo.py | 647 | 4.15625 | 4 | def rectangle_calc(x, y):
area = x * y
perimeter = 2 * (x + y)
return area, perimeter
def main():
try:
length = float(input("Enter the length of a rectangle: "))
width = float(input("Enter the width of a rectangle: "))
units = input("Enter the units: ")
area_, perimet... | true |
39028abf4600601082d0c7f24f718739f5e77c3a | queenskid/MyCode | /labs/introfor/forloop2.py | 542 | 4.15625 | 4 | #!/usr/bin/env python3
# 2 seprate list of vendors
vendors = ['cisco', 'juniper', 'big_ip', 'f5', 'arista', 'alta3', 'zach', 'stuart']
approved_vendors = ['cisco', 'juniper', 'big_ip']
# for loop going through list of vendors and printing to screen with a conditional statement.
for x in vendors:
print("\nThe ven... | true |
bf40a829a9887f981a48f429835956a807d3cf03 | cowsertm1/Python-Assignments | /functions-and-collections.py | 2,974 | 4.6875 | 5 | """
As we saw in class, in Python arguments passed to a function are
treatedly differently depending on whether they are a "normal"
variable or a collection. In this file we will go over some additional
examples so that you get used to this behavior:
1. Write a program that assigns some value to a global variable ca... | true |
0b9802a4b4ecc2823db5761773af068cad2d0e56 | davifelix5/design-patterns-python | /structurals/adapter/adapter.py | 2,102 | 4.3125 | 4 | """
Serve par ligar duas classes diferentes
"""
from abc import ABC, abstractmethod
class iGameControl(ABC):
@abstractmethod
def left(self) -> None: pass
@abstractmethod
def right(self) -> None: pass
@abstractmethod
def down(self) -> None: pass
@abstractmethod
def up(self) -> N... | true |
7bfd6160f69605ad5009e8baca3c065aa739b1d0 | joyrexus/nst | /misc/poset.py | 2,638 | 4.1875 | 4 | '''
In NST Sect 14 (p. 57) Halmos gives three examples of partially ordered sets
with amusing properties to illustrate the various possibilities in their
behavior.
Here we aim to define less_than functions for each example. Each function
should return a negative value if its first argument is "less than" its
second,... | true |
59b252c6a2308eb7c590901f9aa0090186b83161 | mitalishah25/hackerRank_problems | /introduction.py | 1,525 | 4.21875 | 4 | # Introduction
#Say "Hello, World!" With Python https://www.hackerrank.com/challenges/py-hello-world/problem
print("Hello, World!")
#Python If-Else https://www.hackerrank.com/challenges/py-if-else/problem
#!/bin/python3
N = int(input())
if N%2 == 0:
if 2 <= N <= 5:
print('Not Weird')
el... | false |
8be7ea60b1cd7f0ce2ab030b7d25c63b257a686a | MarcusGraetsch/awsrestart | /Exercise_1_ConvertHourintoSeconds.py | 295 | 4.34375 | 4 | hours = input("How many hours to you want to convert into seconds? ")
hours = int(hours)
seconds = hours*3600
print("{} hours are {} seconds!".format(hours, seconds))
print("Now with usage of a function")
def convert_hours (hrs):
sec = hrs * 3600
print(f"{hrs} are {sec}")
convert_hours(8) | true |
eccc6cac4824435c77a7d706f555976b788e7446 | thinkingape46/Full-Stack-Web-Technologies | /Python/regular_expressions.py | 798 | 4.28125 | 4 | # Regular expressions
# Import regular expressions
import re
# mytext = "I am from Earth"
# USING REGULAR EXPRESSIONS TO FIND THE MATCH
# if re.search("Earth", mytext):
# print("MATCH found")
# else:
# print("MATCH not found")
# x = re.search("Earth", mytext)
# FIND THE START AND END INDEX OF THE MATCH
... | true |
0f76462a6eca506d11f58d6f1314a1a175ddfd5f | AdamJSoftware/iti1120 | /assignments/A2/a2_part2_300166171.py | 1,935 | 4.21875 | 4 | # Family name: Adam Jasniewicz
# Student number: 300166171
# Course: ITI 1120
# Assignment Number 2
# year 2020
########################
# Question 2.1
########################
def min_enclosing_rectangle(radius, x, y):
'''
(Number, Number, Number) -> (Number, Number)
Description: Calculates the x and ... | true |
7f2c16d15d19183ceabdbcd7ea311bc4f4c27838 | ph4ge/ost-python | /python1_Lesson06/src/word_frequency.py | 456 | 4.125 | 4 | """Count the number of different words in a text."""
text = """\
Baa, baa, black sheep,
Have you any wool?
Yes sir, yes sir,
Three bags full;
One for the master,
And one for the dame,
And one for the little boy
Who lives down the lane."""
for punc in ",?;.":
text = text.replace(punc, "")
freq = {}
... | true |
17e0981af5496c8fe8a3c05e7d2ef15b2681064e | Benkimeric/number-game | /number_guess.py | 863 | 4.1875 | 4 | import random
def main():
global randomNumber
randomNumber = random.randrange(1, 101)
# print(randomNumber)
number = int(input("I have generated a Random number between 1 and 100, please guess it: "))
guess(number)
# guess method with while loop to loop when user does not give correct guess
def ... | true |
63c90181fe378d9bb9093d8395ba0f1f147daf26 | shwesinhtay111/Python-Study-Step1 | /list.py | 1,501 | 4.53125 | 5 | # Create list
my_list = [1, 2, 3]
print(my_list)
# lists can actually hold different object types
my_list = ['A string', 23, 100.22, 'o']
print(my_list)
# len() function will tell you how many items are in the sequence of the list
print(len(my_list))
# Indexing and Slicing
my_list = ['one','two','three',4,5]
print(m... | true |
723cfd942791ed9266f240781f58118cb30ddea9 | shwesinhtay111/Python-Study-Step1 | /abstract_class.py | 1,280 | 4.6875 | 5 | # abstract class is one that never expects to be instantiated. For example, we will never have an Animal object, only Dog and Cat objects, although Dogs and Cats are derived from Animals
class Animal:
def __init__(self, name): # Constructor of the class
self.name = name
def speak(self): ... | true |
3d20fa99eae7df1270b21c6a08bd3cc5d6adb375 | ocmadin/molssi_devops | /util.py | 694 | 4.4375 | 4 | """
util.py
A file containing utility functions.
"""
def title_case(sentence):
"""
Convert a string into title case.
Title case means that the first letter of each word is capitalized with all other letter lower case
Parameters
----------
sentence : str
String to be converted int... | true |
4f46f746f21e445f71ea8fc61155dff62e3ce033 | ToBeTree/cookbookDemo | /1-数据结构和算法/1-19转换计算.py | 610 | 4.15625 | 4 | # 需要灵活使用生成器,避免内存消耗
s = {'name', 12, 11.11}
print(','.join(str(a) for a in s))
nums = [1, 2, 3, 6, 7]
# 生成器
s = sum(s * s for s in nums)
print(s)
# 下面的方式会生成一个临时的列表
s = sum([s * s for s in nums])
print(s)
# 命名元组不能修改但是_replace可以创建一个新的对象替代
from collections import namedtuple
Student = namedtuple('Student', ['name', 'age', ... | false |
12f4625a421f85e40f4ab2700795fceb8e53acad | TLTerry23/CS30practice | /CS_Solutions/Thonnysolutions/3.3.2Area_of_figures.py | 791 | 4.4375 | 4 | # Area Calculator
# Put Your Name Here
# Put the Date Here
choice=input("What do you want to find the area of? Choose 1 for rectangle, 2 for circle, or 3 for triangle.")
if choice=='1':
rectangle_width=float(input("What is the width of your rectangle?"))
rectangle_height=float(input("What is the length of your... | true |
a2781049e4ac8d2f94355326498919ad5501cd25 | brettmadrid/Algorithms | /recipe_batches/recipe_batches.py | 1,409 | 4.25 | 4 | #!/usr/bin/python
import math
def recipe_batches(recipe, ingredients):
batches = math.inf
'''
First check to see if there are enough ingredients to satisfy the recipe requirements
'''
if len(recipe) > len(ingredients):
return 0
'''
Now check to see if there are enough of each i... | true |
f8fa6b77b71bd50acf2cbddeff370e0b2709d3bf | barvaliyavishal/DataStructure | /Cracking the Coding Interview Exercises/Linked Lists/SinglyLinkedList/RemoveDups.py | 741 | 4.3125 | 4 | from LinkedList import LinkedList
class RemoveDuplicates:
# Remove duplicates Using O(n)
def removeDuplicates(self, h):
if h is None:
return
current = h
seen = set([current.data])
while current.next:
if current.next.data in seen:
curren... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.