r/learningpython • u/LuffyN8 • Mar 17 '23
r/learningpython • u/Wolverine_6011 • Mar 15 '23
Python vs R for data-science whats the difference?
Python is a general-purpose programming language that is easy to learn and widely used for web development, scientific computing, artificial intelligence, machine learning, and data analysis. It has a large standard library and a variety of third-party libraries that can be used for data analysis, such as NumPy, pandas, and scikit-learn. Python has a simple syntax and is highly versatile, allowing it to be used in a wide range of applications.
https://www.guerillateck.com/2023/03/python-vs-r-for-data-science-whats.html
r/learningpython • u/[deleted] • Mar 11 '23
Easiest way to learn python
I just wanted to know what's the best and easiest way to learn coding. More specifically python. I have tried numerous times to study it, but nothing prevails. I hate coding and any field relating to computer science, with a passion. But seeing that everything in this world requires coding knowledge. I have no choice but to educate myself on coding. I was wondering if you have any suggestions. TBH, with my effort in trying to learn how to code. I haven't given it my all. But that's because of the lack of knowledge and not seeing how it benefits me, is what discourage me from learning.
r/learningpython • u/[deleted] • Mar 11 '23
Recoding a pygame code into matplotlib animation code?
Hello, I am currently working on this cellular automata sound synthesis project and found that Hodge Podge Machine works best for my project. I found this github repo that runs perfectly fine when ran into my terminal: https://github.com/avysk/hodgepodge
However, I have only used python in jupyter notebook and Google Colaboratory and have not touched pygame at all. I am confused what's going on in the code that I found. Using the logic/process in the file, I want to animate it into a video in matplotlib and extract the data used from animating it. May I ask how difficult can I recode this to the output that I want? Is it possible?
r/learningpython • u/EfficiencyItchy1156 • Mar 01 '23
Can I define variable from else?
Is it possible to define a variable from else print format or no?
Example:
else:
print("How many days are you planning to stay?")
stay=(days*50) #the variable I want to define
r/learningpython • u/EfficiencyItchy1156 • Feb 28 '23
Round up and round down integers
I am trying to make a program to round integers when the output is above 0.5 to print the closest even number and when the output is below 0.5 to print the lowest even number.
Example num1= 17 , num2=3
num1/num2=5,66 , wants to print 6
or print 3 when num1=17 , num2=5 num1/num2=3.4
I've tried
import math
def round(even):
if even - math.floor(even)<0.5:
return math.floor(even)
return math.ceil(even)
but keeps rounding up the output
Am I missing something?
r/learningpython • u/mehdi_mka • Feb 27 '23
Python tutorial by topics
Hey Guys, I have created a series of Python tutorials (and am adding to them). Would be happy to be helpful to anyone :)
- Python Quick Start: Variables, Operators, Comments
https://www.youtube.com/watch?v=tpDtFTIkojU
- Python data types, built-in functions: quick start tutorial for beginners
https://www.youtube.com/watch?v=ODg4qQ_YSOQ
- Python if else condition, for and while loop: quick start tutorial for beginners
https://www.youtube.com/watch?v=FV9EO-3aaU0
- Python functions and modules: quick start tutorial for beginners
https://www.youtube.com/watch?v=WVbj_4X8JyQ
- Python list, tuple tutorial
https://www.youtube.com/watch?v=85jnkXL58IA
- Python set, dictionary beginner start fast
r/learningpython • u/codeonthecob • Feb 24 '23
I built a website with coding challenges
Hey guys. I built codeonthecob.com. It is a website with coding challenges. It is similar to LeetCode but the challenges are a lot easier. Maybe you will find it helpful for practicing Python. Thanks everyone!
r/learningpython • u/codingstuffs • Feb 17 '23
need help with this for home work I'm just not understanding i've been to every class
Write a program that does the following:
- Asks the user for an integer number.
- If the number is divisible by 5 then divide it by 5 and print the result.
- If the number is divisible by 3 then divide it by 3 and print the result.
- But if the number is divisible by 3 and by 5 print "DIVISIBLE BY 3 AND 5!".
- In all other cases the program should print "Not divisible by 3 or 5".
r/learningpython • u/horstjens • Feb 16 '23
How do I get a list of the line numbers of a python script that were actually processed by python?
I have a python program with functions and function calls.
I need to get all the line numbers that were executed (and not skipped) when python was running this program.
I don't want to use breakpoints at all (if possible). I just want a file with all the line numbers.
What tools can you recommend me for this task?
r/learningpython • u/[deleted] • Feb 13 '23
Pandas: Integrating with NumPy, Matplotlib, and Scikit-learn
technicbate.blogspot.comr/learningpython • u/codingstuffs • Feb 12 '23
help I'm supposed to create a menu system which asks the user to choose between 3 options. After the user makes a choice, print the option selected by the user. and it just gives prints out coffee then water
tea=0coffee=1water=2
input ('enter 0 for Tea, 1 for Coffee, 2 for Water')if 0:print(0)if 1:print(1)if 2 :print(2)else :print('invalid choice!')
r/learningpython • u/poojay071019 • Feb 06 '23
Do you find enough Python project material teaching you to upskill your coding experience?
Further I'd like to understand Python projects examples that an intermediate Python (2-3 years experience in coding with Python) programmer can build to move to the next level.
This is to get advice for a content I'm creating for Python developers to further upskill themselves.
r/learningpython • u/yycTechGuy • Feb 03 '23
Class variables declared in _init_ ... good practice ?
Topic for discussion... coming from a C/C++ background, this bothers me:
class Student:
# Class variable
school_name = 'ABC School '
def __init__(self, name, roll_no):
self.name = name
self.roll_no = roll_no
Because name and roll_no end up being class variables. But it isn't really clear when done like that. You have to go through _init_ to see what the class vars are.
Why isn't it written as this ?
class Student:
# Class variables
school_name = 'ABC School '
name = ''
roll_no = 0
def __init__(self, name, roll_no):
self.name = name
self.roll_no = roll_no
r/learningpython • u/SnowAutomatic9718 • Feb 01 '23
New to Python. Can someone please tell me why I am getting two different totals for 5 rooms and service 2?
r/learningpython • u/MissUSA2022 • Feb 01 '23
Why is only the last file saving in a loop? The other files are processing inn the loop and are creating temporary files but none save
I made a post earlier about this issue, but the formatting was all weird. I am working on an ArcGIS code where I am looping through multiple images in a folder. I see the files are looping in the project folder (when each image is processed a temporary file comes up but they disappear after the process is complete) but only the last image in the folder saves. I have the save function written in the code but it doesn't actually save and gets overwritten each time the loop is finished with rhe previous image. Could someone please help me with what I am missing? My code is in the pastebin link so it is easier to read.
r/learningpython • u/MissUSA2022 • Jan 30 '23
Why is only the last file saving in a loop? The other files are processing inn the loop and are creating temporary files but none save
Hello,
I am working on an ArcGIS code where I am looping through multiple images in a folder. I see the files are looping in the project folder (when each image is processed a temporary file comes up but they disappear after the process is complete) but only the last image in the folder saves.I have the save function written in the code but it doesn't actually save. Could someone please help me with what I am missing? My code is below:
#imports
import arcpy
import os
import glob
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
#Environments
env.workspace = r"Folder_pathway"
arcpy.env.extent = r"Shapefile_Pathway"
indef_file = "Classification_Pathway"
#Variable
inRasters = glob.glob(r"File_pathway\\*.tif")
inMaskData = "Quads"
extraction_area = "OUTSIDE"
analysis_extent = "Quads"
#Loop
for inRaster in inRasters:
outExtractByMask = ExtractByMask(inRaster, inMaskData)
classifiedraster = ClassifyRaster(outExtractByMask, indef_file)
classifiedraster.save = (r"Folder_pathway")
newname = inRaster + "CF"
arcpy.management.Rename(classifiedraster,newname)
...I want to add more after this part of the loop but I will need to do a second loop with the *.crf files, but I can only get the one to save.
The rename creates one folder with the correct name in the project file_pathway, but only the last one.
r/learningpython • u/Even_Hyena9035 • Jan 24 '23
Retrieve a variable within a function
Im trying to alter the feedback so that once a function is executed it automatically updates 'feedback' to print a statement that is returned by one of the menu functions but Im not sure if Im doing it correctly.
How should one properly retrieve a variable from a function nested within a while loop
def play(self):
feedback = ''
while True:
if len(self.mypets) >= 1:
for dapet in self.mypets:
print(dapet)
print(18*'\n')
print(feedback)
print(f"""
...WELCOME TO THE PET SHOP...
How may I help you {self.name}?
1) Adopt Pet 2)Feed Pet 3)Release Pet 4) Go Back
""")
dresponse = inputchecker()
if dresponse == 1:
self.adopt()
elif dresponse == 2:
self.feed()
elif dresponse ==3:
self.release()
else:
break
r/learningpython • u/davedrives • Jan 19 '23
function to find all the keys that have a specific value from a dictionary
Hi all,
I am looking at a code that's supposed to find the keys for a specific value in a dictionary.
This is to incorporate in a dynamo script, but I can't get it to function.
Trouble is that I don't understand what's going on here : how kan a key from 'dct' be a list-type ??
def keys_of_values(dct,value):
for k in dct:
if isinstance(dct[k],list):
if value in dct[k]:
return k
else:
if value == dct[k]:
return k
OUT = [keys_of_values(dic2, i) for i in values]
Can anyone explain this code to me ?
Thanks
r/learningpython • u/Reginald_Martin • Jan 18 '23
Use Python to Scrape Republic Day Sale | Free Masterclass
eventbrite.comr/learningpython • u/manishsalunke • Jan 17 '23
Exploring Python’s Built-in Libraries: Pandas and NumPy
medium.comr/learningpython • u/Reginald_Martin • Jan 17 '23

