blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
9a454c277d9a93fe1f1d7d6456f3e626bc0d5615 | AylaGunawan/CP1404 | /prac_05/hex_colours.py | 603 | 4.1875 | 4 | """
CP1404 - Practical 05
Hex Colours
"""
COLOUR_TO_CODE = {"black": "#000000", "beige": "#f5f5dc", "chocolate": "#d2691e", "coral": "#ff7f50",
"darkkhaki": "#bdb76b", "darkorange": "#ff8c00", "darkorchid": "#9932cc", "darksalmon": "#e9967a",
"dimgray": "#696969", "gray": "#bebebe"}... | false |
8a45f66a39fee8556fa1aa8fc27170e33034cbdb | alexisbird/BC2repo | /number_guess.py | 2,952 | 4.625 | 5 | """Have the program generate a random int between 1 and 100. Keep it a secret. Ask the user to guess. Tell them if the secret number is higher or lower than their guess. Let them guess until they get it right.
Advanced:
Limit the number of guesses to 5."""
# ***NOTE TO SELF*** if you have the time and desire:
# - Ad... | true |
f5fbd7c1bad67704b35d81b9cb0d18c5a01dd1c5 | PogramLearningWithPouyan/advanced-python | /video29.py | 445 | 4.125 | 4 | # iterable => list tuple set string
# iterator
# iterate
numlist=[1,2,3,4,5]
# for num in numlist:
# print(num)
# iternum=iter(numlist)
# print(next(iternum))
# print(next(iternum))
# print(next(iternum))
# print(next(iternum))
# print(next(iternum))
list
name='pouyan'
itername=iter(name)
print(next(... | false |
b5f8ce7fc2f8ee32869a882dd189ce24ad11e8ee | laufei/PythonExample | /2. 反转链表.py | 1,176 | 4.21875 | 4 | # coding: utf-8
# @Time : 2019/7/31 10:26 AM
# @Author : 'liufei'
# @Email : fei.liu@qyer.com
# @Software: PyCharm
'''
假设存在链表 1 → 2 → 3 → Ø,我们想要把它改成 Ø ← 1 ← 2 ← 3。
在遍历列表时,将当前节点的 next 指针改为指向前一个元素。由于节点没有引用其上一个节点,因此必须事先存储其前一个元素。
在更改引用之前,还需要另一个指针来存储下一个节点。不要忘记在最后返回新的头引用!
'''
class Node(object):
def __init__(sel... | false |
0215cb209db874303eafe410171c442c7d85b0db | popnfreshspk/python_exercises | /connect_four/pt1_piece_and_board.py | 821 | 4.40625 | 4 | # CONNECT 4 Part: 1
#
# This exercise should expand on the TIC-TAC-TOE learning and let you explor
# implementing programs with classes.
#
# The output of your game board should look like the following:
#
# 0 1 2 3 4 5 6
# |_|_|_|_|_|_|_|
# |_|_|_|_|_|_|_|
# |_|_|_|_|_|_|_|
# |_|_|_|_|_|_|_|
# |_|_|_|_|_|_|_|
# |●|_|_... | true |
f2642ca47db5cbe70990d96919108745009ddc90 | kwy518/Udemy | /BMI.py | 221 | 4.28125 | 4 | weight = input('Please enter your weight(kg): ')
height = input('Please enter your height(cm): ')
height = float(height)
weight = float(weight)
height /= 100
BMI = weight / (height * height)
print('Your BMI is: ', BMI) | true |
6bc1c39d0bfd966c86046b9b2b34af90fc49a7b8 | ocanava/number_guessing_game | /app.py | 1,401 | 4.15625 | 4 | """
Python Web Development Techdegree
Project 1 - Number Guessing Game
--------------------------------
import random
number = random.randint(1, 10)
def start_game():
print("Welcome to the Number Guessing Game!!")
input("Press ENTER to continue...")
Tries = 1
while True:
try: ... | true |
23b620af391c84e21d5ed4b5a2617343346ff020 | kumarmj/test | /main.py | 1,002 | 4.1875 | 4 | # Chapter 1: The role of algorithms in Computing
# In this chapter, we will answer these questions
# What are algorithms?
# An algorithm is thus a sequence of computational steps that transform the input into the output
# e.g. let's define sorting problem
# Input: A sequence of n numbers a1, a2,...an.
# Output: Produ... | true |
7346d76a53843db430d118cd4981d0611e0bb3a4 | denisecase/chapstack | /scripts/04-functions.py | 2,616 | 4.125 | 4 | """04-functions.py
This script provides practice working with functions.
It's based on the script 3 - we use functions to make our code more
reusable and easier to maintain.
We add some fun css effects (zoom when we hover).
See index.html - in this example, our html has additional elements
See styles - we add a zo... | true |
1d297e99053f2596a3e59364129cedd8a5c35f4d | cnDelbert/Karan-Projects-Python | /Text/Count_Words_in_a_String.py | 826 | 4.5 | 4 | # coding: utf-8
__author__ = 'Delbert'
"""
Count Words in a String - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary.
"""
def count_by_input(inp):
return len(inp.strip().split())
def count_by_file(inp):
f = open(inp, "r").... | true |
b0d3208e3e8599e913dbda7124657ec67e8129e5 | philburling/UndergraduateElectiveModules | /Introduction to Programming -with Python/numbersorter.py | 975 | 4.4375 | 4 | # Filename: numbersorter.py
# Title: Number Sorter
# Function: Sorts 10 numbers entered by the user into descending numerical order
# starting the highest first and ending with the lowest. It then prints the new
# order in a list for the user to see.
# Author: Philip Burling
# Date: 28/04/07
# First the program creat... | true |
f19e136c3552317f9445bbeaaff2d407c7ff560f | philburling/UndergraduateElectiveModules | /Introduction to Programming -with Python/OrangutanDave.py | 921 | 4.40625 | 4 | # Filename: OrangutanDave.py
# Title: Dave the Orangutan
# Function: Creates an object (an orangutan called Dave) and gives it the
# co-ordinates (2,2). The program then displays how far (in a straight line)
# 'Dave' is from the point (5,3) where his favourite food is.
# Author: Philip Burling
# Date: 28/04/07
# This ... | true |
e3dfcbb368b8016dee32ec4d8d72c34a1735fe4b | Shootniky/gb_homework_py | /les2_hw_2/task_3_2.py | 739 | 4.15625 | 4 | """ 3. Пользователь вводит месяц в виде целого числа от 1 до 12.
Сообщить к какому времени года относится месяц (зима, весна, лето, осень).
Напишите решения через list и через dict. """
# with a dict
year = {'зима': [1, 2, 12], 'весна': [3, 4, 5], 'лето': [6, 7, 8], 'осень': [9, 10, 11]}
month = 0
try:
month = int... | false |
4da7f5cd5650eb8a60b8d624d25fa0900b2be33c | Shootniky/gb_homework_py | /lesson1_hw1/task_2.py | 810 | 4.4375 | 4 | """2. Пользователь вводит время в секундах. Переведите время в часы,
минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк. """
user_date = int(input('Пользователь вводит время в секундах: '))
if user_date > 345600:
print('Пользователь ввёл слишком большое число, за гранью четвёртых с... | false |
2ad89bf0f243c107cb885fbd06163c50343a9590 | Shootniky/gb_homework_py | /les2_hw_2/task_3.py | 1,256 | 4.34375 | 4 | """ 3. Пользователь вводит месяц в виде целого числа от 1 до 12.
Сообщить к какому времени года относится месяц (зима, весна, лето, осень).
Напишите решения через list и через dict. """
# with a list
month = 0
months = ['Декабрь', 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Окт... | false |
ef4893b9a6ebacda80a48219f20fcb2df250941e | malekmahjoub635/holbertonschool-higher_level_programming-2 | /0x07-python-test_driven_development/4-print_square.py | 685 | 4.46875 | 4 | #!/usr/bin/python3
"""
Module to print a square
"""
def print_square(size):
"""
a function that prints a square with the character #.
Args:
size(int): size of the square
Raises:
TypeError: if size is not integer
ValueError: if size less than 0
Returns:
a printed squ... | true |
30102d891dde0e518c406b0d0341bfc061ef3298 | malekmahjoub635/holbertonschool-higher_level_programming-2 | /0x0B-python-input_output/1-write_file.py | 363 | 4.34375 | 4 | #!/usr/bin/python3
""" write file Module """
def write_file(filename="", text=""):
"""
write file function
Args:
filename(string): the given file name
text(string): the text
Returns:
number of characters written.
"""
with open(filename, 'w', encoding="UTF8") as f:
... | true |
c39cb788505ab8251c84bbc46910442838726703 | 1296279026/Pyxuexi | /DiYi.py | 667 | 4.40625 | 4 | #第一个代码
#print('hello world!')
#print(6+6)
#导入别人写的乌龟
import turtle
#创建一个乌龟
my_turtle=turtle.Turtle()
#让乌龟有个乌龟的形状
my_turtle.shape("turtle")
#乌龟向前走100步
my_turtle.forward( 300 )
#让乌龟右转90度
my_turtle.right(90)
#乌龟再向前走100步
my_turtle.forward( 300 )
#让乌龟右转90度
my_turtle.right(90)
#乌龟再向前走100步
my_turtle.forward( 300 )
#让乌龟右转90度... | false |
87c0434acc2026da30d236311857734a702fbca2 | amanlalwani007/important-python-scripts | /insertion sort.py | 482 | 4.125 | 4 | def insertionsort(arr):
if len(arr)==1:
print("already sorted",arr)
return
else:
for i in range(1,len(arr)):
key=arr[i]
j=i-1
while j>=0 and arr[j]>key:
arr[j+1]=arr[j]
j=j-1
arr[j+1]=key
print("sorted array is",arr)
return
#c... | false |
c068b8ca7d7bb252bbdd37720db7b9ebeff4f60c | ananya-byte/Code-for-HacktoberFest-2021 | /Intermediate/Python/second_highest.py | 588 | 4.21875 | 4 | def bubbleSort(arr):
n = len(arr)
# Traverse through all array elements
for i in range(n):
# Last i elements are already in place
for j in range(0, n-i-1):
# traverse the array from 0 to n-i-1
# Swap if the element found is greater
# than ... | true |
b838bb47b7f9a0f56fe6dadc188a0ad8a9446f73 | CivicTesla/Teacher-Stone-s-Data-Structure-Lesson | /Notes/01-Basic/src/Fraction.py | 1,484 | 4.34375 | 4 | # 1. how to define a class
# 2. show function definition in class and out of class
# 3. show main function
# 4. the meaning of self
# When defining an instance method,
# the first parameter of the method should always be self
# (name convension from the python community).
# The self in python represents ... | true |
0f84bb21c8148a79a337527f89d0afb60953a72b | ellojess/coding-interview-practice | /LeetCode/two-sums.py | 1,066 | 4.125 | 4 | '''
Prompt:
Given an array of integers, return indices of the two
numbers such that they add up to a specific target.
You may assume that each input would have
exactly one solution, and you may not use the same
element twice.
Summary:
Find the indices of two numbers that add up to a specific target.
Examples: ... | true |
d2ba77f5316776a5acee116a7931a7d5aae92bbf | codesbyHaizhen/show-circle-and-rectangle-with-self-defined-modul | /ModulGeometry/circle.py | 860 | 4.21875 | 4 | # Create a class Circle
class Circle(object):
# Constructor
def __init__(self, radius=3, color='red'):
self.radius = radius
self.color = color
def add_radius(self, r):
self.radius = self.radius + r
return(self.radius)
def drawCircle(self):
# this m... | true |
4b779bed75cf8b9f1374f3d6df747980c222556c | ksripathi/python-programmes | /basics/month.py | 626 | 4.5625 | 5 | '''
This programme is about computing month number based on user input
'''
month=input("Enter the month name e.g January")
if month == "Janauary":
print("1")
elif month == "Febraury":
print("2")
elif month == "March":
print("3")
elif month == "April":
print("4")
elif month == "May":
print("5")
elif month... | false |
98cc1941b3e421126a3a7b1a77ac366133761591 | andreiturcanu/Data-Structures-Algorithms-Udemy-Course | /Selection Sort Algorithm Implementation - Project.py | 631 | 4.25 | 4 | #Write Selection Sort Algorithm; Ascending Order
def selectionsort (array):
for i in range(len(array) - 1):
#identify index to be equal to i
index = i
#1 through length of array -1
for j in range (i+1, len(array),1):
if array [j] < array [index]:
#we find smallest item in that given array
... | true |
72269a40897df9c8e829815aa805dd57c923d04b | andreiturcanu/Data-Structures-Algorithms-Udemy-Course | /Quick Sort Algorithm Implementation - Project.py | 1,108 | 4.15625 | 4 | #Write Quick Sort Algorithm; Ascending Order
def quicksort (array, low, high):
if low >= high:
return
#partition array
#select middle item in array
piv_index = (low+high)//2
#sort
temp1 = array[piv_index]
temp2 = array[high]
array[piv_index]=temp2
array[high]=temp1
i = low
#make sure... | true |
3a9c797ad3aeb48b52c81298eae76973f2211fd9 | drvinceknight/rsd | /assets/code/src/is_prime.py | 363 | 4.25 | 4 | """
Function to check if a number is prime.
"""
def check(N):
"""
Test if N is prime.
Inputs:
- N: an integer
Output:
- A boolean
"""
potential_factor = 1
while potential_factor < N / 2:
potential_factor = potential_factor + 1
if (N % potential_factor == 0)... | true |
1c494fdac791749392e673dff546d3b1a6008c48 | juliorhode/Python | /excepciones/1-excepciones.py | 1,192 | 4.21875 | 4 | # Las excepciones son errores en tiempo de ejecucion del programa. La sinstaxis del codiggo es correcta pero
# durante la ejecucion ha ocurrido "algo inesperado".
def suma(num1, num2):
return num1+num2
def resta(num1, num2):
return num1-num2
def multiplica(num1, num2):
return num1*num2
def divide(num1, ... | false |
662fb93b5d859097b4bf55c34343989c9ea469fa | TudorMaiereanu/Algorithms-DataStructures | /mergesort.py | 744 | 4.3125 | 4 | # Mergesort algorithm in Python
import sys
# function to be called on a list
def mergesort(unsortedList):
mergesortIndex(unsortedList, 0, len(A)-1)
def mergesortIndex(unsortedList, first, last):
if first < last:
middle = (first + last)//2
mergesortIndex(unsortedList, first, middle)
mergesortIndex... | true |
39a2bd9408657fbf40b7a20fa5d0c1b089cdeea9 | jesseulundo/basic_python_coding | /nested_data_structure.py | 1,711 | 4.5 | 4 | """
Create a list nested_list consisting of five empty lists
"""
nested_list = [[], [], [], [], []]
print(nested_list)
print("Nested_list of length 5 whose items are themselves lists consisting of 3 zeros")
print("===============================================================================")
n_nested_list... | true |
0c2cfc4554e2444d2bee517d03be6d0d4e9be96e | axtell5000/working-with-python | /basics-1.py | 873 | 4.125 | 4 | # Fundamental Data types
int
float
bool
str
list
tuple
set
dict
# Classes - custom data type
# Specialized data types - external packages
None
# int and float
print(type(3 + 3))
print(type(2 * 8))
print(type(2 / 8))
print(2 ** 2) # 4
print(4 // 2) # rounds down to integer
print(6 % 4) # modular remainder
# Mat... | true |
ac1f79328c2c79bc5cab0ebc059821acb7817321 | guillempalou/scikit-cv | /skcv/multiview/util/synthetic_point_cloud.py | 1,926 | 4.15625 | 4 | import numpy as np
def random_sphere(N, radius, center=None):
"""
Generates N points randomly distributed on a sphere
Parameters
----------
N: int
Number of points to generate
radius: float
Radius of the sphere
center: numyp array, optional
center of the sphere. (0,0,0) defau... | true |
00882283a9a01dfdbbcc7961ce471ae1046fbc35 | Hol7/100_Days_Challenge | /Day1.py | 664 | 4.25 | 4 | print("Day 1 - Python Print Function ")
print("The function is declared like this:")
print("print('what to print')")
# Debug and fix Exercise
print("Day 1 - String Manipulation")
print("String Concatenation is done with the" "+" "sign.")
print("e.g print('Hello'+'world')")
print("New lines can be created with a back... | true |
8bf9e3ac8bb085ac80dc605736d46530c63287c6 | amarendar-musham/Devops | /class_OOPS3.py | 1,020 | 4.28125 | 4 | ## <<v1>> not completed
class person:
def __init__ (self,name,age):
self.name=name
self.age=age
print("name is {} ; and age is {} \n".format(self.name,self.age))
o1=person("ad",3)
## inheritance
class teacher(person):
def printing(self,name,age):
person.__init(self,name,age)
## here no def is de... | false |
9df8f7a84cb750453653d64b6c6b8c48b6cb793a | naveenshandilya30/Common-Modules-in-Python | /Assignment_8.py | 883 | 4.21875 | 4 | #Question 1
"""A time tuple is the usage of a tuple (list of ordered items/functions) for the ordering and notation of time."""
#Question 2
import datetime,time
print (time.strftime("%I:%M:%S"))
#Question 3
import datetime,time
print ("Month:",time.strftime("%B"))
#Question 4
import datetime,time
print ("Day:"... | true |
173f56f7ae89501528eba25bacd5601ca3a2723e | Sameer2898/Data-Structure-And-Algorithims | /Placement Prepration/Mathmetics/prime_num.py | 555 | 4.125 | 4 | def isPrime(N):
if N <= 1:
return False
if N <= 3:
return True
if (N % 2 == 0 or N % 3 == 0):
return False
i = 5
while(i * i <= N):
if (N % i == 0 or N % (i + 2) == 0):
return False
i += 6
return True
def main():
T = int(input('Enter ... | false |
334e3b803269c9bd6680449731217a8808e7503c | Sameer2898/Data-Structure-And-Algorithims | /Placement Prepration/Stack/reverse_a_string.py | 434 | 4.125 | 4 |
def reverse(string):
stack = []
for ch in string:
stack.append(ch)
reverse = ''
while len(stack):
reverse += stack.pop()
return reverse
if __name__=='__main__':
t = int(input('Enter the number of test cases:- '))
for i in range(t):
str1 = input('Enter the strin... | true |
b9f4adeebf8aaad1e795d00c091e69a4d018dbdc | zhangzhentctc/crawl_hkexnews | /samples/single_select.py | 2,046 | 4.4375 | 4 | from tkinter import *
# This is a demo program that shows how to
# create radio buttons and how to get other widgets to
# share the information in a radio button.
#
# There are other ways of doing this too, but
# the "variable" option of radiobuttons seems to be the easiest.
#
# note how each button has a value it set... | true |
26a10b42641935713f2acf04983d20656f4db2dd | AchaRhaah/prime-numbers | /main.py | 225 | 4.15625 | 4 | n=int(input("enter a number:"))
is_prime=True
for i in range(1,n):
if n%i==0:
is_prime==False
if is_prime==True:
print(f"{n} is a prime number")
else:
print(f"{n} is not a prime number")
| false |
5437ea12e15311eddce36aa4088a9836d49fdb1a | Ananth3A1/Hkfst2k21 | /calculatorOfGrades.py | 1,131 | 4.3125 | 4 | # program that requests entry with a student's name,
# after entry enter 10 student grades (all must be entered by the program user)
# and after having the grade list for the student show at the end of the program,
# the student's average, the maximum grade, the minimum grade, the first and the last grade assigned to t... | true |
c15cf2aade883ded4b3257a30d1fc2756a46cd20 | gui-akinyele/python_mundo_1_curso_em_video | /Desafios/Desafios_22_27.py | 2,306 | 4.46875 | 4 | """ Exercício 22:
Crie um programa que leia o nome completo de uma pessoa e mostre:
– O nome com todas as letras maiúsculas e minúsculas.
– Quantas letras ao todo (sem considerar espaços).
– Quantas letras tem o primeiro nome.
nome = str(input('Digite seu nome: ')).strip()
espaco = (nome.count(' '))
primeiro = nome... | false |
506e3d63c06c48166bb57894ee5f85892699cdef | acctwdxab/project-4b | /fib.py | 420 | 4.125 | 4 | # Dan Wu
# 10/19/2020
# To create a function that takes a positive integer parameter and returns the number at that position of the Fibonacci sequence.
def fib(num):
"""The fib function returns the positive number at the position of the fibonacci sequence."""
first_num, second_num = 0 , 1
for i in range (... | true |
7b29f544f5f3d581af92347194d4da2d9fcae53a | Anna-Pramod/LeetCode_Solutions | /isomorphic_strings.py | 1,909 | 4.125 | 4 | #Given two strings 'str1' and 'str2', check if these two strings are isomorphic to each other.
#Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2 while preserving the order.
#Note: All occurrences of every character in ‘str1’... | true |
e0e1f4f3272c7ecbf5e59d89f6a1ba4112d1de0c | baymer2600/python_challenges | /divisor.py | 358 | 4.1875 | 4 | #Practice Program
#Create a program that asks the user for a number and then prints out a list of all the divisors of that number.
user_input = input("Please provide a number: ")
def divisor(number):
a = []
x = number
while x > 0:
if number % x == 0:
a.append(x)
x -= 1
retu... | true |
6c859b128b1b5fcfb37dfcdc152841d7b791043e | usmanwardag/prep | /5_twos_complement.py | 1,666 | 4.3125 | 4 | # Why do we need 2's complement?
# https://www.youtube.com/watch?v=lKTsv6iVxV4
#
# Two's complement is used to store signed numbers.
#
# How should be store signed numbers in bits?
# One idea is to assign the highest bit 0 or 1
# depending on whether the number is +ve or -ve.
#
# This idea has two problems.
# 1- There... | true |
c72b198242f1fa333a728ee426e5ebe80d4a1cde | jackpetersen3/leap_year | /leapYear2.py | 579 | 4.125 | 4 | quit1 = 0
while quit1 == 0:
year = input("Enter a year: ")
try:
year = int(year)
except:
print("input must be an integer")
break
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print(year, "is a leap year\n")
else:
... | false |
d9599b68b38c8ad91487a7ce2246f5eaeb712143 | AlexKovyazin/python_basic | /Lesson_4/Task_7.py | 802 | 4.125 | 4 | from functools import reduce
def multiplication(stop_num):
"""Перемножет все элементы списка и выводит результат умножения"""
# то же самое, что в задаче № 5, но импортировать только функцию multiplication не получилось -
# - выдавал ещё и результат всей задачи № 5.
# Надо сделать условие с name и __... | false |
a677c3a3844460845066f20dc9bd3766955e4eb7 | OmarThinks/numpy-project | /learning/A)Intro/09_join.py | 617 | 4.125 | 4 | import numpy as np
array1 = [[1,2],[3,4]]
array2 = [[5,6],[7,8]]
print("Concatenate")
print("_________")
array3_0 = np.concatenate((array1,array2), axis=0)
print(array3_0)
"""
[[1 2]
[3 4]
[5 6]
[7 8]]
"""
array3_1 = np.concatenate((array1,array2), axis=1)
print(array3_1)
"""
[[1 2 5 6]
[3 4 7 8]]
"""
p... | false |
1679b4e34a398a81aa293ff2c8471d151d8f5fc4 | Shamyukthaaaa/Python_assignments | /fruits_set.py | 1,334 | 4.1875 | 4 | # To Be Implemented Set methods
fruits=set()
num=int(input("Enter the number of elements to be present in the set: "))
for i in range(num):
fruits_set=input("Enter fruit {} :".format(i+1))
fruits.add(fruits_set)
print(fruits)
#add method
print(fruits.add("papaya"))
#update method
veggies=["potato","... | true |
47ad5edd172c6f1951efbd159b398cf090eadfbc | minddrummer/leetcode | /single questions/SearchInsertPosition.py | 909 | 4.15625 | 4 | # Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
# You may assume no duplicates in the array.
# Here are few examples.
# [1,3,5,6], 5 2
# [1,3,5,6], 2 1
# [1,3,5,6], 7 4
# [1,3,5,6], 0 0
class Solution(obj... | true |
ab2eee9e92e20cae6d71e6ccd6c57bfe64be3de0 | Deependrakumarrout/Small-Assignment | /Simple project/cheak prime number.py | 2,714 | 4.3125 | 4 |
#Making a function to restart
def restart():
try:
num=int(input("Enter a number:"))
if num>1:
for i in range (2,num):
if (num%i)==0:
print(num,"is not a prime number..")
print(i,"x",num//i,"is",num)
... | true |
70d4ae0a45fc2dc7f3ce963f3d8c69d3e9834a2a | Akarthikeyan91/TestGit | /reverse.py | 1,224 | 4.125 | 4 | #!/c/Python36/python
###### String reverse with range ######
s = "Hello"
s1= ""
n = len(s) + 1
for i in range(-1,-n,-1):
s1 = s1 + s[i]
print(s1)
s = "Hello" ###### simplest way
print(''.join(s[i] for i in range(-1,-(len(s)+1),-1)))
print(''.join(reversed('a string'))) ###### sorted
###### St... | false |
da062560647d69b8fac9d0686270087b1851023f | TjeerdH/Number-guess-game | /guess.py | 2,830 | 4.125 | 4 | import random
x = random.randrange(100)
while True:
count = 0
guess = input("Guess a number between 0 and 100 ")
try:
if x != int(guess):
if x % 2 == 0:
print("It is an even number!")
count += 1
break
else:
p... | true |
d8d759f9ee97a09a1d1d03d79e9c996ae287ebd9 | davidbUW/Intro-to-Python-Class | /hw3.py | 915 | 4.21875 | 4 | evenlist = "-"
evenlist = list(evenlist)
oddlist = "-"
oddlist = list(oddlist)
def number_program():
while True:
start = int(input("Enter a starting number: "))
end = int(input("Enter an ending number: "))
if start < 1:
print("ERROR: Starting number must be greater than 1")
... | true |
5decd85f916fceade200d88af89eb62385a59cf1 | DonyTawil/LPTHW | /ex.py/ex5.py | 631 | 4.15625 | 4 | dt_name='dony'
dt_height=163 #centimiters
dt_heights=dt_height/2.54 #to convert centimiters into inches for extra credit from tutorial.
dt_age=18
dt_weight=55
dt_weights=dt_weight*2.2 #extra cr. kilo into pounds
dt_eyes='brown'
dt_teeth='white'
dt_hair='dark brown'
print ('lets talk about %s.'%dt_name)
print ("he's %d... | true |
8f988e4a800f92702f77f0df4f36ad84e84f108a | DonyTawil/LPTHW | /ex.py/ex12.py | 254 | 4.1875 | 4 | name=input('what is your name? ')
age=input("what is your age? ")
height=input('''how tall are you? ''')
weight=input('how much do you weigh? ')
print ("so %s ,you're %s years old ,%s centimiters tall, and you weigh %s kilos"%(name,age,height,weight))
| true |
475778c024e9a48bbf4d902ff3d8f76f78f5c975 | omakasekim/python_algorithm | /00_자료구조 구현/chaining용 연결리스트.py | 1,719 | 4.15625 | 4 | # 해시테이블에서 충돌이 일어날 경우를 위한 chaining 용 링크드리스트 구현
class Node:
def __init__(self, key, value):
self.key = key
self.value = value
self.next = None
self.prev = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def find_node_with_key(self... | true |
d14be530e0781a8f77d4a450f4ef239dc633054f | ritesh3556/PythonConcepts | /dictionary_comprehension.py | 370 | 4.21875 | 4 | # dictionary comprehension------->
#square = {1:1,2:4,3:9}
square = {num:num**2 for num in range(1,11)}
print(square)
square = {f"square of {num} is ":num**2 for num in range(1,11)}
print(square)
for k,v in square.items():
print(f"{k} :{v}")
string = "harshit"
new_dictionary = {char:string.count(ch... | false |
e32b155a9b4b06ed347ed5412658796f8435abd1 | Jayaprakash1998/Python-practice-problems-set-5 | /Prison Security Protocol.py | 2,171 | 4.21875 | 4 | ''' QUESTION:
Prison Security Protocol :
There is a highly secure prison that holds the most dangerous criminals in the world. On 2nd November 2019,
the prison officials received a warning that there was an attack planned on the prison to free the criminals.
So, the prison officials planned a quick evacuation... | true |
205a7325dec447cab3994b95ab5ae41234425a93 | JustonSmith/Coding_Dojo | /python_stack/learn_assignments/functions_basics_I/functions_basic_I.py | 1,652 | 4.125 | 4 | # #1
# def number_of_food_groups():
# return 5
# print(number_of_food_groups())
# # The terminal will return 5.
# #2
# # There is an undefined variable so the function will not run.
# #3
# def number_of_books_on_hold():
# return 5
# return 10
# print(number_of_books_on_hold())
# # The terminal will r... | true |
c704e775f3c97c4582fb40dce0e5fdb93fa85108 | darkCavalier11/sort-python | /insertion_sort.py | 429 | 4.15625 | 4 | def insertion_sort(array, reverse=False):
if reverse:
array = [-1*e for e in array]
for j in range(1, len(array)):
key = array[j]
i = j - 1
while i > -1 and array[i] > key:
array[i+1] = array[i]
i -= 1
array[i+1] = key
if reverse:
array... | false |
6f5d6c116039b2f8b4ea1184e430a40460de9217 | LuisHenrique01/Questoes_Fabio | /fabio_04_31_while_numeros_romanos.py | 2,321 | 4.28125 | 4 | def main():
numero = int(input("Numero de até 3 digitos: "))
print('O numero em romano é: %s'%mil_romano(numero))
def mil_romano(numero):
numero_romano = (numero // 1000) * 'M'
numero_romano_final = numero_romano + novecentos_romano(numero % 1000)
return numero_romano_final
def novecentos_romano... | false |
32ad867849b95f3aa479b09c73ae7abb4d033955 | 757u/CSE | /Hangman(Jazmin Ambriz).py | 1,589 | 4.34375 | 4 | import random
# This is a guide of how to make hangman
# 1. Make a word bank - 10 items (checked)
# 2. Select a random item to guess (checked)
# 3. take in a letter and add it to a list of letters_guessed (checked)
# -up to ten incorrect guesses (checked)
# guesses_left = 10 (checked)
# list of letters that you have g... | true |
7b4f8e15418b7571c7d126127cbb8779f2924238 | hmanoj59/python_scripts | /circle_linkedlist.py | 785 | 4.28125 | 4 | def circle_node(node):
marker1 = node
marker2 = node
while marker2 != None and marker2.nextnode != None:
marker1 = marker1.nextnode
marker2 = marker2.nextnode.nextnode
if marker1 == marker2:
return True
return False
#Initializing node
class Node(object):
de... | true |
3c8a9c05f9caf0bc70b7f52762fb64198f0994be | Sharks33/HackerRankSolutions | /Python/staircase.py | 822 | 4.65625 | 5 | '''
Consider a staircase of size n = 4:
#
##
###
####
Observe that its base and height are both equal to n, and the image is drawn
using # symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size n.
INPUT FORMAT
A single integer, n, denoting the size of ... | true |
46ec164997037a09d38150b738cf81aab1b75f31 | JacksonMike/python_exercise | /python练习/老王开枪/Demo11.py | 772 | 4.21875 | 4 | class Cat:
#初始化对象
def __init__(self,newName,newAge):
self.name = newName
self.age = newAge
def __str__(self):
return "%s的年龄是:%d"%(self.name,self.age)
def introduce(self):
print("%s的年龄是:%d"%(self.name,self.age))
T = Cat("Tom",12)
print(T)
class Animal:
def __init__(se... | false |
9b6eb3dfa5fef600879b57f509abef3f6f6b6ccc | davidgower1/Python | /Ex3.py | 968 | 4.5 | 4 | #This line prints a statement about counting my chickens
print("I will now count my chickens:")
# These lines count the chickens, Hens and Roosters
print("Hens", float(26) + float(30) / float(6))
print("Roosters", float(100)-float(25) * float(3) % float(4))
# Here I am makeing the statement about counting the eggs
prin... | true |
1019f29bd5a5f767ece688fbef960be1ab4625da | Prakhar-Saxena/ProjectEulerSolutions | /quickSort | 290 | 4.28125 | 4 | #!/usr/bin/env python3
#This is an amazing way to write the quick sort method.
def quickSort(arr):
if len(arr) <= 1:
return arr
else:
return quickSort( [x for x in arr[1:] if x < arr[0]]) + [arr[0]]+quickSort([x for x in arr[1:] if x>=arr[0]])
print quickSort([3,1,4,1,5,9,2,6,5])
| true |
cdf04a7b1ff723776c2433516bc0eb0490344835 | sidneykung/python_practice | /01_easy/checking_x.py | 555 | 4.25 | 4 | # 1. is_even
# Define a function is_even that will take a number x as input.
# If x is even, then return True.
# Otherwise, return False
def is_even(x):
if x%2 == 0:
return True
else:
return False
print is_even(5) # False
print is_even(6) # True
# 2. is_int
# Define a function is_int that takes a numbe... | true |
49067afca8940e388ff099ed58b68726868d22e8 | thekingmass/OldPythonPrograms | /timedateModule.py | 287 | 4.21875 | 4 | from datetime import datetime
from datetime import date
'''
datetime function for time and time function for date
'''
time = datetime.now()
print(time)
print(date.today())
print(date.today().weekday()) # this will give the week date for today as it counts monday as 0 and saturday as 6
| true |
3e0173ac2ea4d30aafdbc6851636cb3a96f922e7 | supriyo-pal/Joy-Of-Computing-Using-Python-All-programms | /binary search by recursion.py | 1,226 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 20 21:03:53 2020
@author: Supriyo
binary search always takes sorted list as input
"""
#start=0 and end=last
def binary_search(l,x,start,end): #l is the list and x is the searching elelment
#base case: 1 element is in the list , start==end
if start == ... | true |
cc472c44fff5813680b7019dda413e81df991634 | abhishekbajpai/python | /even-odd.py | 301 | 4.40625 | 4 | # Ask the user for a number.
# Depending on whether the number is even or odd,
# print out an appropriate message to the user.
numb = int(input("Please enter a number to check if even or odd: "))
if numb%2 == 0:
print("Entered number is even. ")
else:
print("You have enetered odd number") | true |
d78a468f240b5a01b8da3bf5b05abefe449f99e0 | ryanlntn/mitx.6.00.1x | /l3.problem9.py | 714 | 4.15625 | 4 | # L3 Problem 9
low = 0
high = 100
guess = (low + high) / 2
print "Please think of a number between " + str(low) + " and " + str(high) + "!"
while True:
print("Is your secret number " + str(guess) + "?")
print "Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low.",
answ... | true |
c0f2b4cc267623aacdb13b188350ada0efc44311 | vipingujjar1/python-edsystango | /homework/29 July 2019/greaterDigit.py | 270 | 4.15625 | 4 | # find greater digit from three digit no.
num1=int(input("Enter a three digit no. :"))
for i in range(3):
if i==0:
max=num1%10
num1=num1//10
else:
temp=num1%10
if temp>max:
max=temp
num1=num1//10
print(max)
| true |
27e9c6ae86496fd733f0f1aa7181af06afdd1e82 | nspofford1/tech-savvy | /Assignment3.py | 1,246 | 4.125 | 4 | #Excercise5
def any_lowercase1(s):
for c in s:
if c.islower():
return True
else:
return False
#lowercase1 is seeing if the first letter is lowercase, if it is, it returns True and does not check any other letter
def any_lowercase2(s):
for c in s:
if 'c'.islower()... | true |
ff3b61e30c9f266ca478636bb0c7c15631bbe402 | kristuben/PythonFolder | /drawshapes.py | 622 | 4.3125 | 4 | from turtle import *
import math
#Name your turtle
ke=Turtle()
colormode(255)
#Set Up your screen and starting position.
setup(500,300)
ke.setposition(0,0)
### Write you code below:
color=input('Enter the color of the shapes:')
ke.pendown()
ke.pencolor(color)
length = input('Enter the length of the shapes:')
for nu... | true |
6d055d9ec5c902b107c942d9d8b6a2550e59b964 | annkon22/chapter4 | /ex7.py | 765 | 4.34375 | 4 | #Using the turtle graphics module, write a recursive
#program to display a Hilbert curve
###############################################
########## HILBERT CURVE ###########
import turtle
size = 10
def main():
t = turtle.Turtle()
my_wd = turtle.Screen()
hilbert(t, 5, 90)
my_wd.e... | false |
cd9faf9eac1d1fa9932a9e577708ece3f085a976 | annkon22/chapter4 | /ex12.py | 1,832 | 4.46875 | 4 | #Modify the Tower of Hanoi program using turtle graphics to animate the movement of the disks.
#Hint: You can make multiple turtles and have them shaped like rectangles.
import turtle as t
def move_tower(height, from_pole, to_pole, with_pole):
if height >=1:
move_tower(height - 1, from_pole, with_... | true |
0045217a7a04f74694ad26615f502be10bcff7db | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/list_manipulation_DFRICHARD.py | 1,121 | 4.34375 | 4 | // AUTHOR: Richard
// Python3 Concept: Manipulating data in lists
// GITHUB: https://github.com/DFRICHARD
//Add your python3 concept below
domestic_animals = [] #creating an empty list to contain domestic animals
domestic_animals.append("dog") #adding dog to the list domestic_animals
print(domestic_animals) # The res... | true |
21b8e68f4d4820cb47c3ed171c6d287819c33018 | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/SortAlphabeticalOrder_erarijit.py | 305 | 4.5625 | 5 | # Program to sort alphabetically the words form a string provided by the user
# take input from the user
my_str = input("Enter a string: ")
# breakdown the string into a list of words
words = my_str.split()
# sort the list
words.sort()
# display the sorted words
for word in words:
print(word)
| true |
fbc976c9592476b372056343a82fa714b065fcac | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/Palindrome_Shyam-2001.py | 375 | 4.1875 | 4 | // AUTHOR: Devendra Patel
//Python3 Concept: Palindrome
// GITHUB: https://github.com/github-dev21
print("Enter the Number ")
num = int(input())
temp = num
reverse = 0
while(num>0):
dig = num%10
reverse = reverse*10+dig
num = num//10
print(reverse)
if temp==reverse:
print("Number is i... | true |
2a2d5262d2828aa4649aaa8bd6b6ff66ea24891c | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/magic_number-sumitbro.py | 939 | 4.1875 | 4 | # Python3-Learn
// AUTHOR: Sumit Sah
// Python3 Concept: Check Magic number
// GITHUB: https://github.com/sumitbro
# Magic number concept
#A magic number is that number whose repeated sum of its digits till we get a single digit is equal to 1.
# Example:
# original number= 1729
# sum of digits= 1+7+2+9=19
# ... | true |
1348b71b806efdd6f0201339b28e51d52cc133ef | OcaeanYan/Python-Basics | /高级特性/5.迭代器.py | 1,058 | 4.125 | 4 |
if __name__ == '__main__':
# 可以使用isinstance()判断一个对象是否是Iterable对象:
# from collections.abc import Iterable
# print(isinstance([], Iterable))
# print(isinstance({}, Iterable))
# print(isinstance('abc', Iterable))
# print(isinstance((x for x in range(10)), Iterable))
# print(isinstance(100, Iter... | false |
230d895ba0af79ebb5d8215a2ff435d9c44a02bc | rajatrj16/PythonCode | /PythonCode/Function_MilesToKilometer.py | 211 | 4.1875 | 4 | miles = float(input('Enter Miles: '))
print('Miles: ')
print(miles)
print(' ')
def convert(miles):
print('Converting Miles to Kilometer: ')
return 1.60934 * miles
km = convert(miles)
print(km)
| false |
ea434795e0deee584fff9e426d35cfce5ef36024 | rajatrj16/PythonCode | /PythonCode/AddNumber.py | 248 | 4.1875 | 4 | value=1
summ=0
print("Enter Numbers to add to the sum")
print("Enter 0 to quit.")
while value !=0:
print("Current Sum: ",summ)
value=int(input("Enter Number? "))
summ+=value
print("---")
print("Total Sum is: ",summ)
| true |
59d1c057abf78be9d606f4aaf7d96d811210834c | AC740/Py | /python37/priorityQueue.py | 691 | 4.28125 | 4 | customers = []
customers.append((2, "Harry")) #no sort needed here because 1 item.
customers.append((3, "Charles"))
customers.sort(reverse=True)
#Need to sort to maintain order
customers.append((1, "Riya"))
customers.sort(reverse=True)
#Need to sort to maintain order
customers.append((4, "Stacy"))
customers... | true |
0c5de4f5507edac29ad3840714173cfdaf61ac47 | sahasatvik/assignments | /CS2201/problemset01/problem01.py | 389 | 4.15625 | 4 | #!/usr/bin/env python3
"""
Input your IISER email in format name-rollno@iiserkol.ac.in, extract the name,
roll no using split() and print them.
"""
email = input("Enter your email in the format name-rollno@iiserkol.ac.in : ")
try:
name_roll, domain = email.split("@")
name, rollno = name_roll.split("-")
pr... | true |
dbb34903bf5365ba09f52c12de86f32d94c37ff0 | Algorant/leetcode | /07_reverse_integer.py | 519 | 4.34375 | 4 | '''
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
'''
def reverse(x):
#check if negative
neg_check = 1
# ignoring negative sign, convert to str
if x < 0:
neg_check... | true |
b5ec7405a7c8b68560146a9fa9565063defaa165 | Kitrinos/Ch.05_Looping | /5.1_Coin_Toss.py | 778 | 4.3125 | 4 | '''
COIN TOSS PROGRAM
-----------------
1.) Create a program that will print a random 0 or 1.
2.) Instead of 0 or 1, print heads or tails. Do this using if statements. Don't select from a list.
3.) Add a loop so that the program does this 50 times.
4.) Create a running total for the number of heads and the number of ta... | true |
6e2b7809c92d27cadc9618ed4ccee34432ab6f02 | jmsaavedra/Interactive-Prototyping-S15 | /python/inclass.py | 268 | 4.3125 | 4 |
x = raw_input("Please enter an integer: ")
x = int(x)
if x < 0:
x = 0
print 'no negative numbers allowed!'
elif x == 2:
print 'x is 2!!'
elif x > 10:
print 'x is greater than 10!'
else:
print 'x is less than 10, greater 0 and NOT 2'
print 'done! exiting now.'
| true |
7463dd78101526c91de711352501cf2b0a465c15 | honestobx/exercicios_em_python | /3_notas_media.py | 349 | 4.1875 | 4 | # Faça um programa que leia as 3 notas de um aluno e calcule a média aritmética deste aluno.
nota1 = float(input("Entre com a primeira nota: "))
nota2 = float(input("Entre com a segunda nota: "))
nota3 = float(input("Entre com a terceira nota: "))
media = (nota1 + nota2 + nota3) / 3
print("A média do aluno f... | false |
e5862c30d80f3886aa2a6ee34c200e40d0276259 | ankitchoudhary49/Daily-Assignments | /Assignment-9.py | 1,739 | 4.21875 | 4 | #Assignment 9
'''
Question 1:Name and handle the exception occured in the following program:
a=3
if a<4:
a=a/(a-3)
print(a)
'''
#Exception: ZeroDivisionError
a=3
if a<4:
try:
a=a/(a-3)
except:
a=int(input("please enter a value other than 3. "))
a=a/(a-3)
print(a)
'''
Question 2... | true |
d9f193db5866194f1f3a2a3917a6a1317de589c6 | ankitchoudhary49/Daily-Assignments | /assignment-4.py | 1,307 | 4.3125 | 4 | #Asignment 4
#Question 1: Reverse the List.
print("*"*50)
list1=[1,2,3,4,5]
print(list1[::-1]) #list1.reverse() was not working so i had to use slice operator.
print("*"*50)
#Question 2: Extract all the uppercase letters from a string.
str1='My name is ANKIT CHOUDHARY.'
for i in str1:
if i.isupper()==True:
... | true |
db4dee6c383d948fc86d7c9aee1908214f79d58f | loc-dev/CursoEmVideo-Python-Part2 | /Fase12/Desafios/Desafio_037.py | 712 | 4.15625 | 4 | # Fase 12 - Condições Aninhadas
# Desafio 37
# Escreva um programa que leia um número inteiro qualquer
# e peça para o usuário escolher qual será a base de conversão:
# 1 para binário
# 2 para octal
# 3 para hexadecimal
num = int(input('Digite um número inteiro: '))
print('')
print('Escolha uma conversão: \n... | false |
dbf4133ce1e2db8d06175daf9f5daf9f837da365 | fernandobd42/Introduction_Python | /07_function.py | 2,055 | 4.71875 | 5 | '''
Funções, basicamente são subprogramas, dentro de um programa maior, utilizados para realizar uma tarefa específica.
'''
def say_hello(): #def define uma função, say_hello foi o nome que eu dei
return "Hello World" #return define o retorno desta função
#OBS:a identação(espaçamento) define o bloco que faz parte f... | false |
022081786817ba3b960d45b0f1125692cff1a3bb | mcbishop/calculator_2 | /arithmetic.py | 1,516 | 4.15625 | 4 | import math
# def add(num1,num2,*therestnums):
# new_num = 0
# for i in therestnums:
# i = int(i)
# new_num = (int(new_num) + i)
# return (int(num1)+int(num2)+int(new_num))
#next task: change functions to use reduce().
# we will want to convert both arguments into a list along with theres... | true |
a16201f040fee1cee135952b9c1de1fc28c013b4 | mag389/holbertonschool-higher_level_programming | /0x06-python-classes/2-square.py | 528 | 4.25 | 4 | #!/usr/bin/python3
"""square with attribute file"""
class Square:
"""
Square - the square class
Currently blank class
__init__ - makes instance
"""
def __init__(self, _Square_size=0):
"""
creates square instance
_Square_size: self explanatory
"""
if t... | true |
8f04b4b1214f2eb4ab3fdb6fe62d5d18ec264aff | joeywangzr/File_Sorter | /file_sorter.py | 1,473 | 4.28125 | 4 | # Import necessary directories
import os, shutil
# Change working directory to user choice
dir = input('Please input the name of the directory you would like to sort: ')
os.chdir(dir)
print('Sorting files...')
# Check number of files in the directory
num_files = len([f for f in os.listdir('.') if os.path.isfile(f)])... | true |
02892e3a0ccc9faa07184ba3599a036804c65402 | theskinnycoder/python_crash_course | /7_DataStructures/5_MemberShipOperators.py | 1,077 | 4.53125 | 5 | # NOTE: MEMEBRSHIP OPERATORS : in, not in
# - In Strings :
my_string = 'She sells sea shells in the sea shore'
if 'sea' in my_string:
print('Present')
else:
print('Not present')
# - In Lists :
my_list = [1, 3 + 4j, 3.4, 'Rahul']
if 1 in my_list:
print('Present')
else:
print('Not present')
# - In Tup... | true |
092784978eccd9e9483ec1d318631c590253c53f | geog3050/matchison | /Quizzes/matchison_G5055_Quiz1.py | 583 | 4.125 | 4 | climate = input("Please input the climate (in lowercase) and then press enter: ")
temp_string = input("Please input all temperature measurements for this climate as a list enclosed in brackets (i.e. [24.7, 44, 76]): ")
temp_float = eval(temp_string)
print("climate: ", climate)
print("temperatures: ", temp_float)
if cli... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.