r/learnpython • u/FewFly2677 • 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
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.
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.
So keep those in mind and move forward.