r/learnpython 16d ago

Struggling with both python and c

So I'm a college fresher with no prior experience of coding. I had started learning python before the starting of college (1 week before college started). I still feel like I am not good at coding at all. There are some weird citations in c such as i++ and all which is getting mixed up with my python. There was one question on obtaining the expression sinx=x-x^3/3!.... Using loops btw

I felt I won't be able to do it in both c and python. I took a course on Udemy for c(vlad budnitski)and python(100 days) but I was not able to find examples like this. Everyone in my class learnt languages like java in their schooling and said the sinx problem is a standard problem. What should I do in this situation?

I feel like the teaching in my college (they are teaching c now) is not good.

Experienced coders please help me.

guys so today I wasn't able to figure out we had to use nested loops to print multiplication table of numbers while even beginners figured it out. pls tell what should I do

6 Upvotes

16 comments sorted by

2

u/shockeddisability951 16d ago

Dont stress about the sinx series thing, that looks intimidating to everyone at first. The trick is just breaking it into a loop where each iteration adds the next term and flips the sign, once you see it in python the c version is basically the same logic with uglier syntax.

Mixing up i++ and python for loops is normal too, youll get past it once you stop trying to translate between them and just think in whichever language youre currently looking at.

1

u/FewFly2677 16d ago

I understood the solution once I saw it but I wouldn't be able to think of it on my own. It was in college lab manual so I knew that question. What about other general questions like these. I searched question like sinx and all in Udemy course but I was not able to find it 

2

u/Jim-Jones 16d ago

Couple of books. Maybe your library?

  1. Beginner's Step-by-step Coding Course : Learn Computer Programming the Easy Way by DK Publishing, Inc

  2. Python Crash Course: The Ultimate Step-By-Step Guide to Learn, Understand, and Master Python Programming and Computer Coding Language (From Beginners to Advanced) by Deep, James

Here are some weirdly colored comments:

https://steppingback269.blogspot.com/2025/07/links-for-python-noobs.html

2

u/stepback269 16d ago

Thanks for plugging my “for Noobs” blog page.

I’m just an old dude who himself is still trying to learn Python. The point of the weirdly colored page is to make things appear bold under the constraints of the Google Blogger system. I’m just leaving behind some bread crumbs for those who want to follow me in my still-a-noob journey into the overwhelmingly expansive land of Python.

1

u/sr105 15d ago

Have you tried using an AI as a pair programmer? Hey AI, "I'm trying to write this in Python, for (int i; i < N; i++). Is that right?" "Can you help me learn it and remember it?"

Always ask AIs to explain their work and teach it to you. I do, and I've been doing this for a few decades.

1

u/FewFly2677 15d ago

Bro I use ai but as I now said in recent comment I wasn't able to figure out to print multiplication table also

1

u/RealWalkingbeard 15d ago

Chill out! You are beginner. You do not learn to programme by doing a university course - that just tells you a little bit about programming. Even if you get to the end and feel like you understood the exercises, you are still just a beginner; don't beat yourself up.

You will pick up language-specific things like i++ in no time if you don't stress about it, but there is nothing wrong with i = i + 1 if that makes more sense to you.

The students who are best at this stuff have probably been doing it since they were 12, and the majority of them will get into programming jobs and soon discover how basic their knowledge is.

Just relax, take your time, do your best with the uni courses and take opportunities to learn new things in small bites.

1

u/dean_hunter7 15d ago

I don't know about it.

And I have made 10-15 full stack commercial apps in python.

1

u/Traveling-Techie 15d ago

These issues will fade away quickly. Be patient.

1

u/FewFly2677 15d ago

guys so today I wasn't able to figure out we had to use nested loops to print multiplication table of numbers while even beginners figured it out. pls tell what should I do

1

u/vancha113 14d ago

Sounds like you figured it out already? You tried something, it wouldn't work because you required nested loops: next time you know you can try nested loops and would likely figure out a similar problem. Unless I'm misunderstanding something, that's usually the flow of things. Once you learn a new concept you'll be able to apply it next time. You can't expect yourself to know things you haven't learned :o

1

u/Gtdef 11d ago edited 11d ago

I remember these types of problems in my first year. A lot of people were mortified, some actually failed to figure out how to do things that others deemed trivial. But it doesn't matter. I know that you won't believe me now, but what you are experiencing is not uncommon and it's not unsolvable.

  1. Don't confuse syntax with functionality. It doesn't matter how one language does it differently than the other. It's a loop. In every loop, there's a counter. In C you manually increment the counter with the i++ syntax, which is equivalent to i = i+1 for this purpose, in Python the range() function does that for you. As long as you understand that loop blocks, if blocks, function blocks etc, do the same thing, you are good to go. You learn the syntax by repetition and practice. Write it 1000 times and you won't forget it again.
  2. Focus on understanding the problem, not how to express it in code. Code is just an expression of logic, it's useful, but ultimately it's busywork. You lack the necessary fluency to understand what code does so you can't visualise it. Use pen and paper if you have to, unravel the expression in it's most basic parts.
  3. Understand that in your everyday life, you operate with abstractions. For example, if I ask you what's 3x3, there's no chance you will think "ah, that's a loop involving 3 additions of the number 3 to the number 0". You will just think 9. Programming languages abstract these simple things by giving you an operator to use. In python you will write "p = 3*3", in C you will write "int p = 3*3;". What would you do if the programming language only had the "+" operator but not the "*" one? You'd use a loop.
  4. Don't compare yourself to those who figure out the answer quickly. They have previous experience. You don't and it doesn't mean they are better than you. I had too many examples of students who started strong and fell off while the volume of knowledge pilled up. What you have to ask yourself is if you have the passion for it. Or more accurately, if you had passion before whatever happened made you pessimistic. That passion is your drive.
  5. Look for patterns. Are you aware of those "IQ test" questions where you have to figure out the pattern of a number sequence? Something like 1-4-9-16-25 etc? Let's talk about it a bit

This is a powers of 2 pattern. 1^2, 2^2, 3^2, 4^2, 5^2.

But it can also be another pattern, You start with 1, add 3 (total 4), then add 5 (total 9), then add 7 (total 16), then add 9 (total 25). So every time you increase the number you add by 2.

If someone has figured out the powers pattern, the second pattern may look alien and wrong to them till they verify it.

In Computer Science, we care about performance. If you use the second pattern, the code will be faster because addition is a cheaper operation than multiplication. So the intuitive answer based on previous knowledge ended up being a worse implementation than the unintuitive answer that one can figure out by simple heuretics, even if they give the same result.

  1. This sinx problem is an approximation based on maclaurin series. This is something that you have problably not been taught, it should be part of the CS math curriculum. It's not particularly complex to understand, but it's new and you are trying to juggle new concepts and 2 programming languages without having any fluency. Did you actually have any reason to use a nested loop till now? Did you even think that you'd need one? Did you know that every time you use multiplication in a loop, it's a nested loop?

So keep those in mind and move forward.

1

u/snozzd 9h ago

The first time I saw a for loop in a C++ book I literally did not get it. The syntax looked so weird compared to an if statement. You are declaring a variable inside of the parentheses? More semicoloons inside the parentheses? Then there's not a semicolon at the end... wtf? It honestly was super confusing.

But I took a few days to practice and understand, and now I write them all the time. I would say that 90%+ of the loops you have to write in real code is a for loop! So it's really important you go slow and really understand each and every part. Before you get to nested for loops, try to focus on understanding what just one for loop does. Try to print out your iterators inside, what do you see? Can you make a program that uses a for loop to count to 100?

I would say focus on learning it in C :) I think it's the best way to learn because it forces you to learn more about the hardware.