TRENDING NEWS

POPULAR NEWS

I Was Hoping Someone Could Help Me With The Python Code For This

Help writing program to find the 1000th prime number(Python code)(beginner experience)?

So I've been taking MIT opencourseware for computer science as I know nothing about computer science and programming though want to as a possible college option. I've come to the 2nd problem set assignment and it wants me to write a program to find the 1000th prime number(using what I've learned about control flow and iteration *still hazy on those terms*). I finally managed to figure out writing a program to figure out if a number is prime but am still lost on how to FIND a prime number using what I know. And from what I've looked up, all the coding is either more advanced than I KNOW at this point or is put in different words and keywords I don't quite understand. So I was hoping someone could help me by guiding me through this using basic coding language that is relatable/alike to the variables and keywords I am using and know, as I will show underneath here, and help me figure out what to do by learning what I want to do in plain english first and then translating that into code. Go easy on me, computer programming feels like going from algebra 1 straight into calculus so far. Anyways, heres my code for computing if a number is prime:
x=7
x*=1.0
prime=True
for d in range(2,int(x)):
....if x/d==int(x/d):
......prime=False
if prime==False:
....print x, "is composite"
else:
.... print x, "is prime"

Python help! "Input expected at most 1 argument..."?

You're off by one line. Really the problem is here:

  answer = input("What is the correct answer for",animal,"?")

As you can see, this line of your program really is trying to pass three arguments to the 'input' function. Those arguments are the string "What is the correct answer for", the variable whose name is 'animal', and the string "?".

However, as the error report tells you, the 'input' function is willing to accept at most one argument. That argument should be a single string that will be shown as the prompt. So, instead of passing three arguments and hoping that 'input' will stitch them together for you (it won't do that) your program must stitch those three pieces together into a single string and pass that single string as the argument to 'input'. Like this:

  prompt = "What is the correct answer for " + animal + " ?"
  answer = input( prompt )

or, if you don't want to use the extra 'prompt' variable, just:

  answer = input( "What is the correct answer for " + animal + " ?" )

You're probably being tripped up by the fact that the 'print' function *is* willing to accept multiple arguments and it will stitch them together for you. That's certainly convenient, but it's not how most functions behave. Most want only a specific fixed number of arguments and Python will complain if you try to pass them a different number of arguments. ('input' is slightly unusual in its own way, because it can be called with either one argument or zero arguments, but not with more than one.)

I was hoping someone could help me with the python code for this?

A county collects property taxes on the assessment value of property, which is 60 percent of the property’s actual value. For example, if an acre of land is valued at $10,000, its assessment value is $6,000. The property tax is then 64¢ for each $100 of the assessment value. The tax for the acre assessed at $6,000 will be $38.40. Write a program that asks for the actual value of a piece of property and displays the assessment value and property tax.

Exercise 2: Body Mass Index

Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:
BMI = weight * 703 / height2
where weight is measured in pounds and height is measured in inches.

Exercise 3: Paint Job Estimator

A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $20.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon. The program should display the following
data:
The number of gallons of paint required
The hours of labor required
The cost of the paint
The labor charges
The total cost of the paint job

Does knowing python help to learn C++?

Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. Its design philosophy emphasises code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java. There lies a lot of deviation for a programmer in python to code in C++. First thing you may out-struck with is that the library & function availability in C++ is so teensy compared to python, thus, one may feel deprecated enough while making functions in C++ while maintaining its aura syntactically. A script written in python in 2 to 3 months can take a year or more if you are shrewd enough to write it along :). C++ doesn’t support arbitrarily bignum datatypes, so you have to play tactics to glue this fact with your code to conserve it from returning garbage values. There are no lists, no dictionaries, no tuples in C++, hence you can feel the pain.If you are hoping a condolence from python to write C++ programs, trying to travel lightyears on the blackbird, then you are only giving your code’s running time a scratch(say 10 secs) from your time to complete that code in C++(say a day or two).On a serious note, Python can only provide you with a push of knowledge and algorithms in learning c++, and if you are heading for competitive programming, you must befall the change.

Python pygame font initialize error?

hey guys. i have a pygame font error. i have initialized the font and everything else in pygame, but it keeps giving me this:
Traceback (most recent call last):
File "/Users/kids/Documents/Jeevan/Tron2/tron... line 401, in
Stats = pygame.font.Font("Vera", int(Winw * 4))
error: font not initialized

i have the line pygame.font.init() at the beginning of the program in addition to the line pygame.init() so i dont know whats wrong. can you guys help? thanks!

NO TROLLING PLZ

What’s the best way to learn Python, and what will Python help me with?

< PYTHON HIGHLY TOXIC >Being a python lover. I will say that you should not learn python at all.Because it is so lovely and easy that you will find yourself hating every other language.Every language you have learned so far will be wasted because most probably you will not going to use them in future.You will end up your youth in front of a computer learning, web scraping, deep learning and will not be able to recover from that net and as you start exploring it will trap you deep inside it.It will make you a boring person. because then every time you open your mouth you will speak about AI, ML,Big Data and all nerdy stuffBecause it is so addictive that you will feel dopamine flowing in your blood and finally you become a python zombie.You will become useless to others as you will find yourself trying to make automation scripts for every little thing instead of manually doing and waste a lot of time.And if you are competitive programmer then it is even worse because even after knowing that python is slow than c++ you will be using it a lot.In your resume, you will not find much to write because everything you know is python. (because it alone is sufficient to make you a web designer, data analyst, Automater etc… )But If you still wanna learn i don’t know whyThen this is best youtube channel sentdex. And one more worth mentioning is thenewboston it will teach you everything.And learning is incomplete without practice.So Pactice here at Hackerrank Solve Python Code ChallengeAnd Head First Python is the best book to start and For books i have written here Aadish Goel's answer to What are some good books for Python (intermediate to expert)?DisclaimerI don’t want to hurt anybody and not saying by any means that c++ and java are crap. Because i really like standard template library(of c++).Please ignore all my grammatical and spelling mistakes in English. I hope you will get an idea what i want to say..I Know it’s kind a weird Because you all amazing people here have thousands and lakhs of upvotes. But it’s My first answer to get these many upvotes. So,Thank you Everybody for the up votes.

Can anybody help me with this code challenge?

I don’t know python, but the trick to any programming problem is to find a step-by-step method of doing it.So let’s think about the question.It wants all the square numbers, but only the ones under 5000It wants you to write all these numbers outFrom here it should be quite obvious what the process is:Square the numberIf the result is under 5000, print it and incrementrepeat until you get a number over 5000, at which point stop.i = 1;while math.pow(x,2) < 5000:print x;x += 1;Again, I don’t know if this is valid python, but I’m hoping it’s enough for you to figure it out.The basic idea is to break down problems into smaller and smaller pieces until it’s obvious how to do each one.

I always need help when writing Python scripts. Should I just give up programming?

You should seek understanding rather than just practicing. Practicing without understanding of structure and flow will only waste your time. Think of programming like building some automation system in a factory, only you build it with words. And as such you have scopes, namespaces, classes, types, etcetera … just like in any system you would have. Only unlike Engineering, programming is extremely abstract and because of that, much harder to stomach. But if you dabble in Mathematics and logic … you’ll be fine, you just need to be patient and look for the what, where, when, why … not just go at it like a drunk monkey :)

How do I do that color mixer problem in python?

Here is my approach. http://phota.me/3Uhy.jpg

Which language should I know before learning big data (Python/Java/Scala)? What are the technologies that I will have to know (Hadoop or/and Spark)?

I suggest you to go with the Hadoop and you can learn Hadoop with the Python also. Hadoop is written in Java and Apache Spark is written in Scala. But, you already now Python so, don’t waste your time and money to learn new languages.Hadoop is the popular framework of Big data as compared to Apache Spark.How Python helps us to learn Hadoop -Python is easy to learn, user friendly, flexible language, and extremely powerful for end to end advanced analytics applications.We can write programs in MapReduce with Python. Here, we don’t have to translate the code into Java jar files.These are the Python frameworks, which can work with the Hadoop:DumboMrjobPydoopHadoopyHadoop Streaming APIPython offer different libraries, which provide support for the data analytics tasks. Python is used for it versatility and we can use Hadoop Streaming API with other frameworks to deal with Big data problems.Ayushi Deshmukh's answer to Can someone with 2 years of experience in other IT domains learn Hadoop/big data and get a good job?The Hadoop Streaming API offers a user to create and execute Map/Reduce jobs with any script as the mapper or the reducer.If you are still confused among Hadoop vs Spark, you can go through this infographic.Even we can compare both the technologies on their pay scale.Hadoop developer salary in India can be 5 LPA–25 LPAHadoop developer salary in India can be $119,250 - 178,000 ETL$Apache Spark Developer salary in India can be 8LPA -16 LPA.Apache Spark Developer salary in USA can be $92,910 - $132,035 ETL.Ayushi Deshmukh's answer to Is Python still relevant in data science given the rise of Scala (+Spark)?**Companies are using Python with Hadoop**FACEBOOK - For Face Finder ApplicationQUORA - For Search AlgorithmAMAZON - For Product RecommendationLINEROAD - To create a realtime recommendation systemHUBBLE TELESCOPE - to images acquiredYOUTUBE - For video recommendationDISNEY - For managing cluster for image processing and CGI rendering.Many more companies are hiring Python experts to work with Hadoop. So, why are you legging behind?Explore this Hadoop Big data Course, Hope it will help you to get your DREAM JOB:)Please Upvote and share with your friends, hope it will help others.Good Day:)

TRENDING NEWS