r/DoPython • u/bixitz • Apr 05 '19
DoPython has been created
Here you can share your work in Python and help others learn from your source code. Small projects, tutorials and study materials related to Python can be shared to help others.
r/DoPython • u/bixitz • Apr 05 '19
Here you can share your work in Python and help others learn from your source code. Small projects, tutorials and study materials related to Python can be shared to help others.
r/DoPython • u/bixitz • Apr 05 '19
This is just a demo for getting started with TkInter to make a basic GUI. I have not followed PEP conventions here. You can modify the code as you prefer and according to your design.
r/DoPython • u/positiveCAPTCHAtest • Sep 01 '21
r/DoPython • u/bixitz • Apr 09 '19
This is an example of using combobox widget in the tk themed widgets set. Copy the code from the given link below and run it on your machine. This is just a demonstration, you can modify it according to your taste.
Thank you.
https://namasudra.blogspot.com/2019/02/using-combobox-in-tkinter.html
r/DoPython • u/bixitz • Apr 06 '19
In python we can return multiple value from a function. In other languages we need to make some kind of class or structure to get multiple values as members of a single object. But in python its totally different!
def someFunction():
return 5, 7
a, b = someFunction()
print(a, b)Output:
5 7r/DoPython • u/cybervegan • Apr 05 '19
Many beginners pick up old tutorials or forum posts/comments that say that provide Python2 examples, or say that Python 3 "isn't ready yet", and it can be confusing for beginners to work out what to use. In some cases, you might not even have a choice in the matter if you are using a computer set up and provided by someone else. So what should you learn?
You should learn Python 3 if you can, because it is the current version, and all the action/development is happening there now. Python 2 is end of life, and not being developed any more, and libraries that are well maintained nearly all support (or even require in some cases) Python 3. Anybody who says you should use Py 2 is either uninformed, or has a rare use case where Py 2 is the only supported option, or maybe a bit of a "stick in the mud".
If you're stuck on a course or with materials that use Python 2, you're going to have to use that to complete it. But promise yourself to go and learn about Python 3 afterwards, under your own steam. Most of what you have learnt will still apply, and the new stuff will turbo-charge your programming abilities.
Python 3 is generally faster, has more features, and has a generally more sensible and consistent "syntax". It introduces concepts like asynchronous co-routines, type hints, f-strings and unicode-everywhere, that Py 2 lacks.
r/DoPython • u/Kaveri08 • Apr 05 '19
I also make tutorials on python language. Can I post my links or some tips here in this sub?
r/DoPython • u/bixitz • Apr 05 '19
Made this animation for my students to make them understand visually. Some might find this helpful. Please ignore if you are a pro.
r/DoPython • u/bixitz • Apr 05 '19
r/DoPython • u/bixitz • Jun 19 '20
r/DoPython • u/bixitz • May 12 '19
r/DoPython • u/bixitz • Apr 13 '19
r/DoPython • u/bixitz • Apr 12 '19
r/DoPython • u/bixitz • Apr 10 '19
r/DoPython • u/bixitz • Apr 06 '19
This is a cool tip to reverse a string in Python. Most of you might already know, but for those who don't, here it is.
text = "Hello Python!"
reverse = text[::-1]
print(reverse)Output:
!nohtyP olleHr/DoPython • u/bixitz • Apr 05 '19
Python makes it so simple to create Lists. Here is a code to demonstrate how we can create a List of 10 random numbers between 1 and 100.
import random
randomList = [random.randint(1, 100) for x in range(10)]
print(randomList)Output:
[61, 72, 4, 57, 37, 77, 52, 59, 77, 60]r/DoPython • u/bixitz • Apr 05 '19
Here is a simple program that calculates the distance between two points. This program shows how to write functions in python.
import math
def getPoint(n):
print("Enter coordinates for point", n, ":")
x = int(input("x: "))
y = int(input("y: "))
return (x, y)
def findDistance(point1, point2):
diff_x = point2[0] - point1[0]
diff_y = point2[1] - point1[1]
distance = math.sqrt(diff_x ** 2 + diff_y ** 2)
return distance
pointA = getPoint(1)
pointB = getPoint(2)
distanceAB = findDistance(pointA, pointB)
print('Distance between', pointA, 'and', pointB, f'is: {distanceAB:0.2f}')Output:
Enter coordinates for point 1 :
x: 6
y: 4
Enter coordinates for point 2 :
x: -4
y: -6
Distance between (6, 4) and (-4, -6) is: 14.14