blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
77dd52e0b2643c3982971cd606ae1ba993d8d435 | eldss-classwork/CSC110 | /Creating Modules/oldMcDonald.py | 2,814 | 4.125 | 4 | # Evan Douglass
# HW 8: Children's Songs, the Sequel
# Grade at challenge
'''The oldMcDonald module houses several functions that can be used to write
the children's song "Old McDonald"'''
SOUNDS = []
ANIMALS = []
# Title method
# No parameters
def title():
'Outputs the song title and a blank line'
print('Old ... | true |
73a144d3bf620a3ea9287afd4cb713eb8fd6fab6 | zhangpengGenedock/leetcode_python | /110. Balanced Binary Tree.py | 1,901 | 4.125 | 4 | """
https://leetcode.com/problems/balanced-binary-tree/
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as:
a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
Example 1:
Given the following tree [3,9,20... | true |
7b0811fcdf971e01cbcf0f532fb8a79d1f0c69cb | zhangpengGenedock/leetcode_python | /101. Symmetric Tree.py | 1,750 | 4.25 | 4 | # -*- coding:utf-8 -*-
__author__ = 'zhangpeng'
"""
https://leetcode.com/problems/symmetric-tree/description/
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the fo... | true |
8de2024a2a527db07a59f6ccc1efc09d9980ef70 | zhangpengGenedock/leetcode_python | /695. Max Area of Island.py | 2,409 | 4.1875 | 4 | """Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected
4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
Find the maximum area of an island in the given 2D array. (If there is no island, the maximum area is... | true |
1ff6cf2ba685fc061555a0641b048717b28efe52 | JackLu1/mks66-matrix | /matrix.py | 1,876 | 4.40625 | 4 | """
A matrix will be an N sized list of 4 element lists.
Each individual list will represent an [x, y, z, 1] point.
For multiplication purposes, consider the lists like so:
x0 x1 xn
y0 y1 yn
z0 z1 ... zn
1 1 1
"""
import math
#print the matrix such that it looks like
#the template in the top co... | true |
ee3d3d94e1cf31ae5d554d84c748299cb97f4c43 | esau91/Python | /Problems/leetcode/google_interview.py | 671 | 4.21875 | 4 |
def find_shortest(given_dict):
shortest = {}
iteration = 0
flag = True
while flag:
for key, value in given_dict.items():
key_len = len(key)
if iteration < key_len:
key_subs = key[:iteration]
print(key_subs)
if key_subs no... | true |
231fa24241fc27bc737aa93fc2ca3a6372404d12 | arora-yash/Python-Programming | /jumbled_words.py | 1,853 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 21 07:19:51 2018
@author: yashkumararora
"""
import random
def choose():
words = ['rainbow','computer','science','programming','mathematics','player','condition','reverse','water','board']
pick = random.choice(words)
return pick
def j... | true |
85e0f87adcf9ada348c1d7874fa382c7ac669595 | bflaven/BlogArticlesExamples | /stop_starting_start_stopping/pandas_learning_basics/pandas_learning_basics_1.py | 1,923 | 4.40625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
[path]
cd /Users/brunoflaven/Documents/01_work/blog_articles/stop_starting_start_stopping/pandas_learning_basics/
[file]
python pandas_learning_basics_1.py
# source
- How to use Regex in Pandas
https://kanoki.org/2019/11/12/how-to-use-regex-in-pandas/
"""
import n... | true |
4d3eb71a87f04d3c0c3129f64bf8d7e51bc70a28 | Prathibha1990/python_class | /9.py | 789 | 4.4375 | 4 | # List in python
#list can hold multiple data types
#[]
x=[10,30,'lohit','prathibha','varsha']
print(x)
print(x[2])
#index or key
######
print(x[2:5])
# ['lohit', 'prathibha', 'varsha']
print(x[:3])
#till no not be print
##############
#list is mutable/change values
name=['prathibha','lohith','varsha',[2000,34... | false |
57bc677d6e532717669fc4058f06005211dd19b3 | Prathibha1990/python_class | /19.py | 418 | 4.21875 | 4 | # Dictionaries in python
#{} we will use curly brackets
person={'name':'prathibha','age':25,'email':'prathi@'}
print(person)
print(person['name'])
print(person['age'])
person['age']=29
print(person)
# index name should not be same
x=dict(name='lohit',age=25,email='lohith@')
print(x)
person={'name':'prathibha','age':2... | false |
88070050081eeba6ac991e7e0f502a5e8e4978b1 | Prathibha1990/python_class | /11.py | 1,130 | 4.3125 | 4 | # tuple()
# non mutable type()
# tuples are faster compaired to list
x=(100,'lohit')
print(x)
print(type(x))
xyz=30,30.445j,'name','school'
print(xyz)
print(type(xyz))
empty_tuple=()
print(empty_tuple)
tuple1=(100,200,300)
tuple2=(100,200,300)
print(tuple1+tuple2) #it can't chanege original value
print(sum(tupl... | false |
eaa71e3f62af7581cd31fb221f3ca86f9542c253 | ketanAggarwal58/Python | /replaceS.py | 1,153 | 4.40625 | 4 | """
The replace_ending function replaces the old string in a sentence with the new string,
but only if the sentence ends with the old string. If there is more than one occurrence
of the old string in the sentence, only the one at the end is replaced, not all of them.
For example, replace_ending("abca... | true |
e9e5e3c934a033c2ce0a8a1828fa5d33782452fe | ketanAggarwal58/Python | /loops.py | 373 | 4.25 | 4 | print("we have two types of loops in python");
print("1. for loop");
print("2. while loop");
print("this is an example of for loop");
for x in range(10):
print(x);
for y in range(2,10):
print(y);
print("this is an example of while loop");
i = 0;
while i < 7:
print(i);
i += 1;
if i == 5:
... | true |
79880cd75b02737461959fa4e9c4bb4acb946506 | TejshreeLavatre/Basic-Codes | /Check Age.py | 345 | 4.1875 | 4 | #Check whether or not a person is eligible to join the 18-30 club
name = input('Hello, please enter your name: ')
print("Hello {}".format(name))
age = int(input('Please enter your age: '))
if 18 <= age < 31:
print('Welcome to the 18-30 club, {}'.format(name))
else:
print('Sorry, you aren\'t eligible for this h... | true |
bf5284cdd1371fc420383ddc0f5da4791edcdeda | Developernation/codefights | /cfights/python3_solutions/mexFunction.py | 971 | 4.25 | 4 | #You've just started to study impartial games, and came across an interesting theory.
#The theory is quite complicated, but it can be narrowed down to the following statements:
#solutions to all such games can be found with the mex function. Mex is an abbreviation of
#minimum excludant: for the given set s it finds ... | true |
af1e1ba7b841076f8399af7d75881c21b190f55d | Nikilesh-123/Nikilesh-Kammila | /palindromenumber.py | 329 | 4.46875 | 4 | # the palindrome in numeric
# for numeric enter the numeric character
# for example number
number = int(input("enter the string"))
string = str(number)
rev_string= string[: : -1]
print("reversed string:", rev_string)
if string == rev_string:
print("the num is palindrome: ")
else:
print("the num is not a palin... | true |
a794ae5e7412d33dda5acba1daca455fa511a603 | nicolas-git-hub/python-sololearn | /7_Object_Oriented_Programming/magic_methods.py | 1,127 | 4.6875 | 5 | # Magic methods are special methods which have double underscores at the beginning and end of their names.
# They are also known as dunders.
#
# So far, the only one we have encountered is __init__, but there are several others.
#
# They are used to create functionality that can't be represented as a normal method.
#
#... | true |
c5c350e2167cb1271de5f2b3005bdde2d8a15417 | nicolas-git-hub/python-sololearn | /6_Functional_Programming/map.py | 620 | 4.375 | 4 | # The built-in function map an filter are very useful higher-order functions that operate
# on lists (or similar objects called iterables).
# The function map takes a function and an iterable as arguments, and returns a new iterable
# with the function applied to each argument.
#
# Example:
def add_five(x):
return... | true |
948433a5b39c9350d3ce26f72baa2c44872bd9ba | nicolas-git-hub/python-sololearn | /5_More_Types/none.py | 883 | 4.375 | 4 | # The "None" object is used to represent the absence of a value.
# It is similar to null in other programming languages.
# Like other "empty" values, such as (), [] and the empty string,
# it is "False" when converted to a "Boolean variable".
# When entered at the Python console, it is displayed as the empty string.
p... | true |
dad02800e2723cc1ef2ffdcef944ac63361c0514 | nicolas-git-hub/python-sololearn | /6_Functional_Programming/recursion.py | 1,782 | 4.5625 | 5 | # Recursion is a very important concept in functional programming.
# The funcdamental part of recursion is self-reference - function calling themselves.
# It is used to solve problems that can be broken up into easier sub-problems of the same type.
#
# A classic example of a function that is implemented recursively is ... | true |
659a5e141cc44c7e9f530bf103df12e6ddf1f0f5 | nicolas-git-hub/python-sololearn | /6_Functional_Programming/functional_programming.py | 1,836 | 4.4375 | 4 | # Functional programming is a style of programming that (as the name suggests) is
# based around functions.
# A key part of functional programming is higher-order functions. We have seen this idea
# briefly in the previous lesson on functions as objects.
# Higher-order functions take other functions as arguments, or re... | true |
ac68e238a4ad576c4fd33580a9e28f8828ba30e8 | btranscend/numericalIntegration | /polynomial.py | 2,936 | 4.28125 | 4 | #!/usr/bin/python3
import unittest
class Polynomial(object):
# Constructor where the object
# is the degree of a given polynomial
def __init__(self, degree):
self.degree = degree
self.coef = []
# Constructor where the object is
# are the coefficients of a given polynomial
def setCoef(self, coef):... | true |
5b8f515e09a50e5d5ffb32838447cd191abdee48 | justinnhli/wernicke | /sample.py | 1,010 | 4.21875 | 4 | if False:
print ("false")
elif True:
print ("true")
else:
print ("should not print")
#
# if 1 > 0 :
# print ('case 1 correct')
# else:
# print ('case 1 incorrect')
#
# if 1 < 0 :
# print ('case 2 incorrect')
# else:
# print ('case 2 correct')
#
# if 0 < 1 < 2:
# print('case 3 correct')
... | false |
41a4078846aa79ef78e52222579342583d0db329 | HarshithaReddyJ/1026-Harshitha-Reddy- | /module5(assignment2).py | 2,038 | 4.78125 | 5 | # 1. Write a python program to create a tuple...
x = () # create an empty tuple
print(x)
tupleb = tuple() # create an empty tuple with tuple() function built-in python.
print(tupleb)
# 2.Write a python program to create a tuple with different data types...
# Type-1 :
tupleb = ("tuple",True,10.0,5)
pri... | false |
e67547d2156ec0a913d048b4643ad6b1d8b380aa | pankaj-pundir/The-projects | /dexterous/3danim_example.py | 2,576 | 4.40625 | 4 | """
============
3D animation
============
A simple example of an animated plot... In 3D!
"""
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import matplotlib.animation as animation
def Gen_RandLine(length, dims=2):
"""
Create a line using a random walk algorithm
... | true |
54cd3f14708ee889f563c0f84c0817f69857a451 | eeyoo/python | /src/function.py | 742 | 4.28125 | 4 | #! /usr/bin/python
# function without return statement
def fib(n):
"""Print a Fibonacci series up to n."""
a,b = 0, 1
while a < n:
print a,
a, b = b, a+b
# call fib function
print 'fib(2000)'
raw_input('press any to continue...')
fib(2000)
# assign fib to another name
f = fib
print '\nfib(... | true |
391b35097d6ff5d3f4194f27dcf0bfdc7d9587c5 | Philip-Loeffler/python | /SectionTen/OOPandClassesPT2.py | 1,556 | 4.46875 | 4 | # this section is entitled "instances, constructors, sets and more"
# class: template for creating obects. all objects created using the same class will have the same characterists
# object: an instance of a class
# instantiate: create an instance of a class
# method: a function defined in a class
# attribute: a variab... | true |
1831cdeeb37ef3058db155431c00059a138ad5f3 | Philip-Loeffler/python | /SectionFour/nestedForLoops.py | 323 | 4.21875 | 4 | for i in range(1, 13):
for j in range(1, 13):
print("{0} times {1} is {2}".format(j, i, i * j))
print("--------------")
# first loop runs 1 time, then inner loop will run all the way through
# then come back to the outer loop, which then again but incremented one time
# and inner loops runs through ful... | true |
8d6be190063a8dbbcc4cb9637db8801429a2e676 | Philip-Loeffler/python | /SectionFive/sortingList.py | 576 | 4.6875 | 5 |
even = [2, 4, 6, 8]
odd = [1, 3, 5, 7, 9]
# extend will combine and add all of the iterables from the list and adds them to it
even.extend(odd)
print(even)
# sort will sort the sequence of numbers
# sort method doesnt create a copy of the list, it rearranges the items of the list
# lists are mutable and their conten... | true |
3dc389c7dadea1293fd13bdc0127a166e9815867 | Philip-Loeffler/python | /SectionFour/in&NotInConditions.py | 468 | 4.15625 | 4 | parrot = "Norweigian blue"
letter = input("enter a character: ")
# checking to see if a letter is in parrot
if letter in parrot:
print("{} is in {}".format(letter, parrot))
else:
print("i dont need that letter")
# here is using not
activity = input("What would you like to do today ")
# checking to see if ... | true |
8313c2cf9fe5a1c478d690ddad54cdb7d459c56c | Philip-Loeffler/python | /SectionFive/nestedLists.py | 815 | 4.3125 | 4 | empty_list = []
even = [2, 4, 6, 8]
odd = [1, 3, 5, 7, 9]
numbers = [even, odd]
# this will print out [[2,4,6,8], [1,3,5,7,9]]
# you have a list within a list
print(numbers)
# will create the 2 seperate lists and print them out
for number_list in numbers:
print(number_list)
# will print out the values inside thos... | true |
cc96e31133f2e20a9563adc61c970b233fb1e010 | perrym6949/CTI110 | /P3HW1_Debugging_Perry.py | 580 | 4.1875 | 4 | # System Grading Output
# 3/23/2021
# CTI-110 P3HW1-Debugging
# Madelyn Perry
#
def main():
# Program takes number grade and outputs letter grade.
# Use 10-point grading scale:
A = 90
B = 80
C = 70
D = 60
F = 50
score = input('Please input your grade: ')
Grd = int(score) # Grd <-... | true |
a9aab3bd27a47191ecfe88770ca5a41cf97d0324 | steve-yuan-8276/pythonScrapy | /practiceFolder/runoob/datetime_16.py | 341 | 4.28125 | 4 | # 题目:输出指定格式的日期。
#
# 分析:此题实际是要求学习time 模块的用法
import time, datetime
# today
print(time.strftime("%Y, %m, %d"))
print(datetime.date.today())
# yesterday
today = datetime.date.today()
oneday = datetime.timedelta(days=1)
yesterday = today - oneday
print(f"Yesterday is {yesterday}.")
| false |
78cd91b1ab16e08d3057757ed6e47960d6eafeee | steve-yuan-8276/pythonScrapy | /practiceFolder/ComputerProgrammingforKids/area_or_perimeter.py | 538 | 4.3125 | 4 | length = int(input("Please input the length(cm): "))
width = int(input("Please input the width(cm): "))
def area_of_the_rectangle(length, width):
area_of_the_rectangle = length * width
return area_of_the_rectangle
def perimeter_of_the_rectangle(length, width):
perimeter_of_the_rectangle = (length + width)... | true |
b5f319cd9f4748295a89f14c6090a51fd10a93a2 | TheShrug/Advent-of-Code | /day2/day-2-1.py | 791 | 4.21875 | 4 | def contains_count_of_any_letter(string, count):
""" Returns bool of whether or not the provided
string contains count number of any unique letter.
This could be optimized further to prevent unnecessary
processing.
:param string:
:param count:
:return bool:
"""
for char in string:
... | true |
4fb3c69cf7196c8cd8251eb5b46e6a98fdfc27da | emmanuelrobles/School | /Python/Harvard/Assigment 5/pairs.py | 1,749 | 4.125 | 4 | """
1) Using the English DictionaryPreview the documentView in a new window that Downey provides, find all words in the dictionary whose reverse is also in the dictionary. There are about 500 such unordered pairs: build a list with each pair appearing once in alphabetic order. Your list should start with the pair ('... | true |
5b28fec3335efd32d3768942c39e2d72b4725838 | NikitaChhattani/sdet | /python/Activity11.py | 235 | 4.28125 | 4 |
fruits={
"Mango" :10,
"Banana" :30,
"Apple" :40,
"Kiwi" :40,
}
choice=input("Enter fruit name you are looking for :")
for fruit in fruits:
if(fruit==choice):
print(choice,"is available")
| false |
11ebd324957354748a4cc483fb8bb74075c68556 | COrtaDev/Data-Structures-and-Algorithms | /HackerRank/InterviewPrep/ProblemSolving/theMaximumSubArray/maxSubArr.py | 2,451 | 4.1875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the maxSubarray function below.
def maxSubarray(arr):
# the subarray will be a slice of the array where all elements are contiguous
# the subsequence however are elements that are non contiguous
# we observe that if all ele... | true |
9bcfb99ff91f61a3e715e030072624156317acc9 | candiepih/alx-higher_level_programming | /0x0C-python-almost_a_circle/models/square.py | 1,499 | 4.15625 | 4 | #!/usr/bin/python3
"""Contains `Square` class defination"""
from .rectangle import Rectangle
class Square(Rectangle):
"""Class inherits from `Rectangle` class"""
def __init__(self, size, x=0, y=0, id=None):
"""Initializes instance attributes
Args:
size (int): size of rectangle
... | true |
8a452b2ec4376064b51e01e191cc92a38c64d263 | candiepih/alx-higher_level_programming | /0x06-python-classes/2-square.py | 622 | 4.46875 | 4 | #!/usr/bin/python3
"""Represent a square class"""
class Square:
"""Derives a square """
def __init__(self, size=0):
"""Initializes the data
Args:
size (int): size of the square
Note:
Do not include the `self` parameter in the ``Args`` section.
Raises:
... | true |
37ec3b0724e970e6b7e9cb5f2af524fc2985f1db | keertanaganiga/Lockdown_coding | /reverse.py | 298 | 4.21875 | 4 | '''
Reverse words in a given String in Python We are given a string and we need to reverse words of given string ?
Examples:
Input :
str = "AIET CHALLENGES IIT"
Output :
str = "IIT CHALLENGES AIET"
'''
str1="AIET CHALLENGES IIT"
print(str1[::-1])
'''
another solution:
str1=input()
print... | true |
cea99b8e2289e57e6de606356ef75d8cdc862f24 | gishbg/my_pynet | /CL1ex7.py | 850 | 4.375 | 4 | #!/usr/bin/env
"""
7. Write a Python program that reads both the YAML file and the JSON file created in exercise6 and pretty prints the data structure that is returned.
"""
from __future__ import print_function, unicode_literals
import yaml
import json
from pprint import pprint
def output_format(my_list, file_type)... | true |
259c1a81fdc5a7e7b731daf4a6aab6dba03dc649 | SonikaVashistha/python-practice | /basics/com/shanu/Circle.py | 370 | 4.21875 | 4 | from math import pi
r=2
# area of circle up to 2 decimal places
print("Area of circle with radius", str(r), "is", round(pi*r**2,2))
# area of circle up to 4 decimal places
print("Area of circle with radius", str(r), "is", '%.4f'%(pi*r**2))
# circumference of circle upto 2 decimal places
print("Circumference of the c... | true |
87cff0de5eafdf4641444a16a7273a6697a087b8 | SteffiBaumgart/Computer_Science_1 | /pairs.py | 553 | 4.21875 | 4 | #uses a recursive function to count the number of pairs of repeated characters in a string. Pairs of characters cannot overlap.
# Steffi Baumgart
# 1 May 2015
def main():
message = input("Enter a message: \n")
print("Number of pairs: " + pair(message, 0))
def pair (message, count):
if len(... | true |
589ff52e3b645b897dfbbffe31fcf46adbfb8cbc | SteffiBaumgart/Computer_Science_1 | /palindromeprime.py | 710 | 4.125 | 4 | # Finding all palindromic primes between two integers
# Steffi Baumgart
# 23 March 2015
N = eval(input("Enter the start point N:" +"\n"))
M = eval(input("Enter the end point M:" + "\n"))
print("The palindromic primes are:")
#loop from M to N
if (N < 2):
N = 1
for i in range (N+1, M):
#Check if Pa... | false |
43d42ae79ca535deb5c4ccede2474f6ee83bcf48 | everbird/leetcode-py | /2013/convert-sorted-list-to-binary-search-tree.py | 1,554 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
class ListNode(object):
next = None
value = 0
def __init__(self, value, next=None):
self.value = value
self.next = next
class TreeNode(object):
left = None
right = None
value = 0
depth = 0
def __init__(self, value, left=... | true |
aecae5acc5d8ddd02c2667c69ee53a1fa50606e8 | SinghJitender/Python | /Hackerrank/lists.py | 1,676 | 4.46875 | 4 | '''
Consider a list (list = []). You can perform the following commands:
insert i e: Insert integer at position .
print: Print the list.
remove e: Delete the first occurrence of integer .
append e: Insert integer at the end of the list.
sort: Sort the list.
pop: Pop the last element from the list.
reverse: Reverse t... | true |
ed5d56877cb4be73f548bf20c5d0ee72715f2190 | SinghJitender/Python | /ControlFlowStatements/ForLoop.py | 449 | 4.3125 | 4 | # For iterating over the elements
list =[1,2,3,4,5,6,7,8,9,10]
for num in list:
print(num)
str = "This is a string"
for letter in str:
print(letter,end='_')
# tuple unpacking
list =[(1,2),(3,4),(5,6),(7,8)]
for tuple in list:
print(tuple)
for a,b in list:
print(a)
print(b)
d={'k1':1,'k2':2,'k3':... | true |
94ecf79c8b7d707aceab8db8a4c0a4c45ac5b8f8 | SinghJitender/Python | /ObjectsAndDataStructures/ListAndDictionary.py | 1,431 | 4.21875 | 4 | # list are similar to arrays in python. they can hold any type of data and supports indexing and slicing function juts as string
list = [1,2,3,4,5]
print(list)
list = ["one","two",'three']
print(list)
list = ["One",120,133.45]
print(list)
list = [1,2,3,4,5]
print(list[0]) # items at index - 0
print(list[1:]) # All ite... | true |
2d2739e330eab90653f90240664d2c3940ed10fc | SinghJitender/Python | /MethodsAndFunctions/LambdaExpression.py | 720 | 4.46875 | 4 | # map() and filter()
# lambda expression are anonymous functions
# map() is used to map each item in the list to the given function and returns a list
def sqrt(num):
return num**2
mylist = [1,2,3,4,5]
print(list(map(sqrt,mylist)))
#filter() can be used to filter the list based upon a condition
def check_len(str):... | true |
c11398aadb3f3da34439229f95449f0f01087330 | ncrowder/python-programming-edX | /assignment3.py | 1,858 | 4.1875 | 4 | # This function accepts a 2-dimensional list of characters (like a crossword puzzle) and a string (word) as input arguments.
# It searches the rows and columns of the 2d list to find a match for the word.
# If a match is found, this functions capitalizes the matched characters in 2-dimensional list and returns the li... | true |
80397fd2494793f67e7966ead0de4fd3e3f0ce0b | lvfds/Curso_Python3 | /mundo_2/desafio_067.py | 836 | 4.15625 | 4 | """
Faça um programa que mostre a tabuada de vários números, um de cada vez, para cada valor digitado pelo usuário.
O programa será interrompido quando o número solicitado for negativo.
"""
from time import sleep
contador = 0
contador2 = 0
continuar_o_programa = True
while continuar_o_programa == True:
c... | false |
bba25468bfcaf2099c340f3885696923b26e306e | lvfds/Curso_Python3 | /mundo_1/desafios/desafio_023.py | 870 | 4.15625 | 4 | """
Faça um programa que leia um número de 0 a 9999 e mostre na tela cada um dos digitos separados.
Ex:
Digite um número: 1834
unidade: 4
dezena: 3
centena: 8
milhar: 1
"""
numero_digitado = input('Digite um número: ')
if len(numero_digitado) == 1:
print(f'Unidade: {numero_digitado[0... | false |
4014223c1f55c29d631b5918b851e2e2769d61e2 | lvfds/Curso_Python3 | /mundo_2/desafio_072.py | 687 | 4.375 | 4 | """
Crie um programa que tenha uma tupla totalmente preenchida com uma contagem por extenso, de zero até vinte.
Seu programa deverá ler um número pelo teclado (entre 0 e 20) e mostrá-lo por extenso.
"""
numeros_por_extenso = ('Zero','Um','Dois','Três','Quatro','Cinco','Seis','Sete','Oito','Nove','Dez','Onze','... | false |
949f58bd10b818923c78e03ae6e044170e5c0d46 | lvfds/Curso_Python3 | /mundo_1/desafios/desafio_028.py | 632 | 4.28125 | 4 | """
Escreva um programa que faça o computador 'Pensar' em um número inteiro entre 0 e 5
e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador.
"""
from random import randint
numero_gerado_aleatoriamente = randint(0,5)
numero_digitado_pelo_usuario = int(input('Adivinhe qual número... | false |
ba551eddf5a18a7044801bb7907df01c3fe40220 | lvfds/Curso_Python3 | /mundo_1/desafios/desafio_004.py | 736 | 4.1875 | 4 | # Faça um programa que leia algo pelo teclado e mostre na tela o seu tipo primitivo e todas as informações possíveis sobre ele.
algo_digitado_pelo_usuario = input('Digite algo: ')
print(f'O tipo primitivo desse valor é {type(algo_digitado_pelo_usuario)}')
print(f'Só tem espaços? {algo_digitado_pelo_usuario.isspace()}'... | false |
5a00cec088a18c1dcf20908b1817e5cd08e6f189 | raferti/code_war | /recover_secret_string_from_random_triplets.py | 1,977 | 4.125 | 4 | """
There is a secret string which is unknown to you. Given a collection of
random triplets from the string, recover the original string.
A triplet here is defined as a sequence of three letters such that each
letter occurs somewhere before the next in the given string. "whi" is a
triplet for the string "whatisup".
... | true |
e0fc6db597a2366baa0fd1f924ef2434e32f1410 | raferti/code_war | /calculator.py | 1,395 | 4.40625 | 4 | """
Create a simple calculator that given a string of operators (), +, -, *, /
and numbers separated by spaces returns the value of that expression
Example:
Calculator().evaluate("2 / 2 + 3 * 4 - 6") # => 7
Remember about the order of operations! Multiplications and divisions have
a higher priority and should be per... | true |
5df0a3355c0c64bddb283a5908f95b6f304eaea0 | AfanasAbigor/Python_Basic | /GUI_Turtle_Race.py | 1,412 | 4.1875 | 4 | from turtle import Turtle, Screen
import random
screen = Screen()
screen.setup(width=500, height=500) #Set height & width of Screen
screen.bgcolor("black") #change BackGround Color
line = Turtle("turtle")
line.goto(250, 250)
line.color("white")
line.right(90)
line.forward(500)
user_bet = screen.textinput(title="Mak... | true |
d30eecb90b4125692e7f4512d822ac129e17855f | VilarPedro/Scripts-Python | /exercicios/Ex004.py | 2,641 | 4.46875 | 4 | '''
04) Faça um programa que leia algo pelo teclado e mostre na tela o seu
tipo primitivo e todas as informações possiveis sobre ela.
'''
# n = 'pedro'
# print()
var = input('Digite algo: ')
print('O que você digitou pode ser um numero:',var.isnumeric())
print('O que você digitou pode ser uma string:',var.isalpha(... | false |
b9c93ccdc24fee371cb9a0e2da8de6c0c71bdab8 | mateuspadua/design-patterns | /creational/singleton/refactoring-guru.py | 1,375 | 4.3125 | 4 | from typing import Optional
class Singleton:
"""
The Singleton class defines the `getInstance` method that lets clients
access the unique singleton instance.
"""
_instance: Optional = None
def __init__(self) -> None:
if Singleton._instance is not None:
raise ReferenceErro... | true |
2e27d73c47bd768f5c78a156a4db813ffc2a2fbd | mateuspadua/design-patterns | /advanced_python_topics/inheritance.py | 1,028 | 4.25 | 4 |
class Pet:
""" Base class for all pets """
def __init__(self, name, species):
self.name = name
self.species = species
def get_name(self):
return self.name
def get_species(self):
return self.species
def __str__(self):
return '{} is a {}'.format(self.name, s... | true |
9fce218f362efcd12371809d4ace99df88e07e2e | mateuspadua/design-patterns | /creational/abstract_factory/udemy.py | 1,732 | 4.1875 | 4 | """
Provide an interface for creating
families of related objects without
specifying their concrete classes.
"""
# abstract classes (interfaces)
class Shape2DInterface:
def draw(self):
raise NotImplementedError()
class Shape3DInterface:
def build(self):
raise NotImplementedError()
# conc... | true |
49188346ad80651c8f6072b6e7639f5646bb38ab | paulosrlj/PythonCourse | /Módulo 1 - Python Básico/Aula20 - Listas/aula020.py | 1,144 | 4.125 | 4 | # Listas
'''
append, insert, pop, del, clear, extend
append -> adiciona um elemento
insert -> adiciona um elemento em uma posição
pop -> retira da ultima posição
del -> deleta das posições especificadas
extend -> extende uma lista com outra
'''
# 0 1 2 3 4
lista = ['A', 'B', 'C', 'D', 'E']
# - ... | false |
e0f66b5ac2b3136a38a93187e8a4732d83f744f6 | apurva13/assignment-2 | /answer3.py | 249 | 4.3125 | 4 | #Take the input of 3 variables x, y and z . Print their values on screen.
x=int(input('enter value of x:'))
y=int(input('enter value of y:'))
z=int(input('enter value of z:'))
print ('Value of x:',x)
print ('Value of y:',y)
print ('Value of z:',z)
| true |
5f8cd3f80f15bae62a50d6989c530d06e3453f32 | litvinovserge/WebAcademy | /HomeWork_06/AssertTests/assert_Task_09.py | 665 | 4.34375 | 4 | """
Из одномерного списка удалить все повторяющиеся элементы (дубликаты) так, чтобы каждое значение встречалось в списке
только один раз.
"""
def list_modifier(some_list):
new_list = []
for i in range(len(some_list)):
for j in range(i):
if some_list[j] == some_list[i]:
some... | false |
31e5779cbd41da74ab9a0cb0b9dc07a97290712f | litvinovserge/WebAcademy | /HomeWork_07/HomeTask_01.py | 1,250 | 4.28125 | 4 | """
Создать класс автомобиль, который содержит информацию о автомобилях
Описать метод __str__
***
Пример
>> car1 = Car(‘Audi’, ‘Red’, ‘1999’, ‘$12000’)
>>print(car1)
name: Audi
color: Red
year: 1999
price: $12000
"""
class Car:
def __init__(self, model=None, color=None, year=None, price=None):
self.model... | false |
84acfee70bb3704b36d5b25451362ffee2067c54 | litvinovserge/WebAcademy | /HomeWork_06/Task_16.py | 841 | 4.125 | 4 | """
Программа переводчик из соленого языка.
ПРИМЕР
Посокесемосон -> Покемон
"""
vowels = ['а', 'о', 'и', 'й', 'е', 'ё', 'э', 'ы', 'у', 'ю', 'я']
test_data = 'Приcивеcет, Cаcальсаcа, Посокесемосон!'
def anti_salty_transform(some_phrase):
some_phrase = list(some_phrase)
for i in range(len(some_phrase)):
... | false |
f3615592e3016700b30e2d4d8ba6a540c677fecd | litvinovserge/WebAcademy | /HomeWork_06/AssertTests/assert_Task_11.py | 497 | 4.15625 | 4 | """
Дан список значений. Превратить список в словарь где ключами служат элементы списка,
а значениями квадраты этих элементов.
[1,2,3] -> {1:1, 2:4, 3:9}
"""
def dict_2_list(some_list):
my_dict = {}
for i in range(len(some_list)):
my_dict[some_list[i]] = some_list[i] ** 2
return my_dict
if __nam... | false |
0a059e009e378c9a8354b99674d8ff7ba7ec6d92 | jonggukim/Python-for-Trading | /About Python/about condition.py | 541 | 4.15625 | 4 | ###조건문
# if :
# if and else
if True:
print('this is true results')
# 조건문:2
# if
input = 11
real = 11
if real == input:
print("hello if conditional statement programming")
# else
if real != input:
print("who are you")
'''
more simple code below
else:
print("who are you")
'''
#조건문:3
# 여러가지 조건에 대하여 동작하는... | false |
966665af55225f40fdd4da19c28dd883a43f62ff | davidknoppers/holbertonschool-higher_level_programming | /0x0B-python-input_output/4-append_write.py | 367 | 4.1875 | 4 | #!/usr/bin/python3
"""
One function in this module
append_write opens a file and appends some text to it
"""
def append_write(filename="", text=""):
"""
open file
put some text at the end of it
close that file
"""
with open(filename, mode='a', encoding="utf-8") as myFile:
chars_written... | true |
b34422e86b7dab5bb5166bc8f2db81eae755310f | davidknoppers/holbertonschool-higher_level_programming | /0x06-python-test_driven_development/5-text_indentation.py | 563 | 4.21875 | 4 | #!/usr/bin/python3
"""
text_indentation - inserts newline into a text
Requires a str input, otherwise raises errors
Prints the result, no return value
"""
def text_indentation(text):
"""
Adds newlines to a string based on sep, and prints it
"""
if text is None or not isinstance(text, str) or len(text)... | true |
2ffd661c6dd804ab70294c05204bc7a5fe835a1b | davidknoppers/holbertonschool-higher_level_programming | /0x07-python-classes/100-singly_linked_list.py | 2,312 | 4.125 | 4 | #!/usr/bin/python3
"""
Implementation of a basic singly linked list in Python
Sorted lowest to highest by node value
Offers basic print function
"""
class Node(object):
"""
creates node with next set to None as default
"""
def __init__(self, data, next_node=None):
if type(data) is not int or i... | true |
ed88d540806403c4065e0c86ec650b49d81f01cc | kristocode/30-Days-Of-Python | /12_Day_Modules/day12_level3.py | 884 | 4.15625 | 4 | ## 💻 Exercises: Day 12
### Exercises: Level 3
import random
import string
#1. Call your function shuffle_list, it takes a list as a parameter and it returns a shuffled list
def shuffle_list(lst):
return random.sample(lst, k=len(lst)) # unique items
#return random.choices(lst, k=len(lst)) # repeated items
o... | true |
3f2aaf74de320538b1f37de59c0166a487ded404 | kristocode/30-Days-Of-Python | /06_Day_Tuples/day6_level1.py | 743 | 4.59375 | 5 | ## 💻 Exercises: Day 6
### Exercises: Level 1
# 1. Create an empty tuple
my_tuple = tuple()
# 2. Create a tuple containing names of your sisters and your brothers (imaginary siblings are fine)
sisters = ('Janis Joplin', 'Amy Winehouse')
brothers = ('Brian Jones', 'Jimi Hendrix', 'Jim Morrison', 'Kurt Cobain')
# 3. Jo... | true |
469962a7100b3671df69de5b5897d0a25766b0d5 | kristocode/30-Days-Of-Python | /09_Day_Conditionals/day9_level1.py | 1,750 | 4.40625 | 4 | ## 💻 Exercises: Day 9
### Exercises: Level 1
# 1. Get user input using input(“Enter your age: ”). If user is 18 or older, give feedback:
# You are old enough to drive. If below 18 give feedback to wait for the missing amount of years. Output:
'''sh
Enter your age: 30
You are old enough to learn to drive.
Output:
E... | true |
70e08680dd30b42b73e81517084f828c03f36fce | huilizhou/Leetcode-pyhton | /algorithms/201-300/225.implement-stack-using-queues.py | 2,080 | 4.28125 | 4 | # 用队列实现栈
# class MyStack:
# def __init__(self):
# """
# Initialize your data structure here.
# """
# self.l = []
# def push(self, x):
# """
# Push element x onto stack.
# :type x: int
# :rtype: void
# """
# self.l.append(x)
# ... | true |
9f29346dce506d85d142a63494d270a88db07459 | sloth143chunk/Election_Analysis | /Assisngments/F_String.py | 1,559 | 4.15625 | 4 | # Original concatenation
# my_votes = int(input("How many votes did you get in the election? "))
# total_votes = int(input("What is the total votes in the election? "))
# percentage_votes = (my_votes / total_votes) * 100
# print("I received " + str(percentage_votes)+"% of the total votes.")
# F-String Printing
# my_... | true |
8a6fdcb1907629d142b55fe8759f4d8b266e71f8 | yashsinghal07/Music-Player | /Project_gui/guidemo.py | 1,595 | 4.28125 | 4 | import tkinter
tw=tkinter.Tk()
#tw is refference of tkinter class
#title() and mainloop() are instance members of tkinter class hence refference tw can call them
#title() - changes the title of root window
tw.title("My Gui App")
#next 2 lines changes the logo on the screen
img=tkinter.PhotoImage(file="E:/project... | true |
ab84718b1454e7e99875966a6ee98e0cd3ba7cf2 | theTransponster/Data-Science | /Statistics/Interquartile.py | 1,990 | 4.1875 | 4 | #Basic code to find the interquartile range in python without using libraries
#The objective of this code is to understand the concept of interquartile range from scratch
#Interquartil: (Q3-Q1)
#Reads from STDIN, prints on STDOUT
n = int(input()) #number of elements of the array
numbers = list(map(int, ... | true |
af3f83953f214f2e57d6b624e97078ba98a55194 | thirdeye18/mycode | /iftest/condition02.py | 504 | 4.125 | 4 | #!/usr/bin/env python3
## Program checks the hostname against the expected value
hostname = input("What value should we set for hostname?")
## Notice how the next line has changed
## here we use the str.lower() method to return a lowercase string
if hostname.lower() == "mtg":
print("The hostname matches the expec... | true |
cc9b05fc91cad733e6ff451665f286686fbff3a4 | chaconcarlos/udacity-data-structures-algorithms | /1-introduction/Task0.py | 1,268 | 4.25 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 0:
What is the first record of tex... | true |
4963b5ae16ba641584b71e505b0e62173883b411 | vinhloc30796/calculate_gap_year | /calculate.py | 739 | 4.28125 | 4 | def is_leap_year(year):
"""
Check if input `year` is a leap year
Input:
- year (int)
Output:
- leap (boolean): True if is leap year, False otherwise
"""
if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
return True
return False
def next_five_leap(year):
"""Retur... | false |
ec183b0b74cbc6563b066d89c2008bea6a550a0a | zaarabuy0950/assignment-3 | /assign4.py | 477 | 4.28125 | 4 | #4. Create a list. Append the names of your colleagues and friends to it.
#Has the id of the list changed? Sort the list. What is the first item onthe list?
# What is the second item on the list?
list = []
print(id(list))
list.append('zanda')
list.append('yabin')
list.append('kendra')
print(list)
print(id(list))
print... | true |
0445950df9813809d215cc6f1ce154fdb274c79d | zaarabuy0950/assignment-3 | /assign12.py | 352 | 4.25 | 4 | #12. Create a function, is_palindrome, to determine if a supplied word is the same if the letters are reversed.
asd = input("enter a string:")
qwe = asd[::-1]
print(qwe)
def is_palindrome(asd, qwe):
if asd == qwe:
return f"The Word are Same string"
else:
return f"The word are not same string"
... | true |
4804982df745b4072c909b5e153812cb558f53b5 | satheeshkumars/my_chapter_6_solution_gaddis_book_python | /exception_handling.py | 600 | 4.34375 | 4 | #use the numbers.txt file to practise this piece of code
def main():
try:
open_numbers = open('numbers.txt', 'r')
except IOError:
print('Unable to open file and read data!')
accumulator = 0
counter = 0
for number in open_numbers:
number = number[:-1]
try:
... | true |
e0bbe15a2e57c4d595cc80fee99450361947c23c | harkred/High-School-Programs | /program12.py | 363 | 4.21875 | 4 | #To convert binary no to decimal no
def binary_to_decimal(num):
num = num[::-1]
decimal = 0
for place in range(len(num)):
digit = num[place]
two_expo = 2 ** place
adduct = int(digit) * two_expo
decimal += adduct
return decimal
#__main__
if __name__ == '__main__':
num... | false |
1ff0fe784d7302ca1f5fb1ba4996309ebd84017e | Shivansh-Uppal/python-coursera | /file2.py | 748 | 4.15625 | 4 | #Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form:
#X-DSPAM-Confidence: 0.8475
#Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. Do n... | true |
ea67f5ba2f78d7bfb1007cddbea6ebaa801dea92 | Rockyzsu/StudyRepo | /python/basic/var.py | 464 | 4.1875 | 4 | #/usr/bin/python3.5
#coding: utf-8
#一次赋 多值
v = ('a', 'b', 'e')
x, y, z = v
print(x+', '+y+', '+z)
'''
(1) v 是一个三元素的 tuple,并且 (x, y, z) 是一个三变量的 tuple。将一个 tuple
赋值给另一个 tuple,会按顺序将 v 的每个值赋值给每个变量
'''
#连续值 赋值
range(7)
print(range(7))
(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7)
print(str(MON... | false |
23cfcfeabd2df7ce7a2b04037c4cf23dbc423c7f | Rockyzsu/StudyRepo | /python/basic/testPythonDemo.py | 1,707 | 4.15625 | 4 | #!/usr/bin/python2.7
# -*- coding: utf-8 -*-
#使unicode编码能识别中文
#python是对大小写敏感的
print "hello, Python!";
name = raw_input('please enter your name: ');
#Integer a = (Integer)raw_input('please enter the number: ');
#This variable itself is not a fixed type of language, called a dynamic language, and corresponds to a stati... | false |
f183bd60b67c7d608a547b37595ff7a0d14dbe21 | DamonGeorge/NLP | /project_03/proj3.py | 1,315 | 4.15625 | 4 | '''
WRITTEN FOR PYTHON 3
Team Member #1: Robert Brajcich
Team Member #2: Damon George
Zagmail address for team member 1: rbrajcich@zagmail.gonzaga.edu
Project 3: Extracts tokenized inaugural addresses from pickle file ('proj3.pkl')
and finds the frequency of a word in each address
Due: 9/14/2018
'''
#import necessar... | true |
0df613e039f1764bd2390b69096c65fb16494811 | bhatiakomal/pythonpractice | /Pythontutes/tut8.py | 1,892 | 4.21875 | 4 | mystr="harry is good boy"
print(len(mystr))
#len is used for determine lenght of string and counting is start from 0
print(mystr[0])
print(mystr[0:4])
print(mystr[0:5])
#this is called string slicing
print(mystr[0:18])
print(mystr[0:80])#we don't have string of 80 but system can give us upto its length
print(mystr[0:5:... | true |
f347546a3cc7b50be89816f2772370c661e33a74 | bhatiakomal/pythonpractice | /Pythontutes/NestedIfElseStatement.py | 324 | 4.3125 | 4 | """a=5
b=2
c=6
d=3
if a>b:
print("true")
if c>d:print("c is greater then d")
else:print("d is greater then c")
else:
print("b is greater then a")"""
a=5
b=8
c=6
d=3
if a>b:
print("true")
if c>d:print("c is greater then d")
else:print("d is greater then c")
else:
print("b is greater then... | false |
238a74a3e89f96a59cd779df4181c849f9e5e4eb | bhatiakomal/pythonpractice | /Practice/Practice68.py | 806 | 4.15625 | 4 | def show():
primarycolour1=input("Please enter first colour:")
primarycolour2=input("Please enter second colour:")
if primarycolour1=="red" and primarycolour2=="blue" or \
primarycolour1=="blue" and primarycolour2=="red":
print(primarycolour1+" is mixed with "+primarycolour2+" is purple ... | true |
8d2a5610d4fe6f9fd95a704eb4e7a2056269a8ad | bhatiakomal/pythonpractice | /Pythontutes/GettingInputFromUserInTuple.py | 539 | 4.28125 | 4 | '''a=[]
n=int(input("Enter number of element:"))
for i in range(n):
a.append(int(input("Enter element:")))
print(type(a))
a=tuple(a)
print(type(a))
print("tuples")
for j in a:
print(j)
#Repition in Tuple
print("Repition in Tuple")
a=(10,20,30,40,50)
b=a*5
print(b)
#Aliasing in tuple
print("Aliasing in tuple"... | false |
bf120c4fb558764f85013c8040160517d39f2072 | arxaqapi/99-solutions | /Python/1_01.py | 515 | 4.28125 | 4 | # Find the last element of a list
def find_last_element(given_list):
if given_list == []:
return "given_list is empty"
return given_list[-1]
def find_last_element_2(given_list):
if given_list == []:
return "given_list is empty"
return given_list[len(given_list) - 1]
def find_last_el... | true |
9cf885a250bc9f9a4a2144c2c83fa9691871014d | stjohn/stjohn.github.io | /teaching/cmp/cis166/s15/mines.py | 1,609 | 4.15625 | 4 | from turtle import *
from random import *
""" Sets up the screen with the origin in upper left corner """
def setUpScreen(xMax,yMax):
win = Screen()
win.setworldcoordinates(-0.5, yMax+0.5,xMax+0.5,-0.5)
return win
""" Draws a grid to the graphics window"""
def drawGrid(xMax,yMax):
tic = Turtle()
... | true |
27991d0731342e22aa2081f0e365afa31e732b8c | stjohn/stjohn.github.io | /teaching/cmp/cmp230/s13/squareTurtle.py | 380 | 4.1875 | 4 | import turtle
def main():
daniel = turtle.Turtle() #Set up a turtle named "daniel"
myWin = turtle.Screen() #The graphics window
#Draw a square
for i in range(4):
daniel.forward(100) #Move forward 10 steps
daniel.right(90) #Turn 90 degrees to the right
myWin.exito... | true |
0f9fdc457fa64320e807661486625d905d632758 | stjohn/stjohn.github.io | /teaching/cmp/cmp230/s14/TurtleBall.py | 1,136 | 4.3125 | 4 | #A simple class, demonstrating constructors and methods in python
#Intro Programming, Lehman College, CUNY, Spring 2014
from turtle import *
class TurtleBall:
def __init__(self,color):
__init(self,color,45,-100,-100,100,100)
def __init__(self,color,angle,x1,y1,x2,y2):
self.turtle = Turtle()
... | false |
1eeaffa5201149d55e002072ba5d075dcda5661d | shahazad08/Bridgelabz_Shahazad | /Algorithms/ds.py | 325 | 4.21875 | 4 | def pallindrome():
try:
n = int(input("Entee rthe Nos"))
n1=str(n)
a=n1[::-1]
if(a==n1):
print("Given Nos. is Pallindrome",a)
else:
print("Not the Pallindrome Nos")
#return 0
except ValueError:
print("Enter the Valid String")
pallindr... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.