100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Practice questions for python R50,00   Add to cart

Other

Practice questions for python

 7 views  0 purchase

Questions to practice coding in python. Questions include sample input and output to guide you and show if you got it right.

Preview 1 out of 2  pages

  • May 14, 2023
  • 2
  • 2022/2023
  • Other
  • Unknown
All documents for this subject (2)
avatar-seller
MsDipale
University of the Witwatersrand
Course: Computer science I, Introduction to algorithms and programming
Practices problems for python




1. Create a program that accepts an integer n and prints out the first n Fibonacci numbers. Sample input
and output;

Input: 6

Output: 0 1 1 2 3 5



2. Write a Python program that takes an integer as input and determines whether it is a prime number.

Sample input and output:

Input: 7

Output: True

Input: 12

Output: False



3. Write a program that accepts a list of integers and prints out the maximum and minimum values.
Sample input and output:

Input: [2, 5, 7, 3, 1, 8]

Output: Maximum value: 8, Minimum value: 1



4. Create a program that asks the user for a string and checks whether it is a palindrome or not. Sample
input and output:

Input: "racecar"

Output: True

Input: "hello"

Output: False



5. Write a Python program that takes a list of integers and returns a new list containing only the even
numbers. Sample input and output:

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller MsDipale. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R50,00. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

60904 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R50,00
  • (0)
  Buy now