0% found this document useful (0 votes)
3 views1 page

Practical Python Fundamentals Guide

Uploaded by

aa15514
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Practical Python Fundamentals Guide

Uploaded by

aa15514
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Learn as you do

Course: Practical Python


Topic: Fundamentals of Python

1. Explain the difference between 42 + 2 and “42” + “2”. What is the + operator doing in
each case?

2. Write a series of python statement that will import the math module, read a number from
the user that represents an angle given in radians, and then print s the sine and cosine for the
given angle.

3. Try writing a print statement that uses the escape character\v. What do you think this is
doing? Try placing several characters before and after the \v. Try typing several in a row
after a series of characters.

4. Write a series of python statements that will read three numeric values from the user, and
then print the largest of the three.

5. Write a series of python statements that will read three strings from the user, and then
print them in dictionary order. (Note: you can compare two strings using the relational
operators.)

6. Using a for loop, print of table of powers of X, where X ranges from 1 to 10. For each
value X, print the quantity X, X2 and X3. Use tab characters in your print statement to make the
values line up nicely.

7. Hourly workers typically earn overtime when they work more than 40 hours per week.
For example, overtime pay might be 150 percent of the regular salary for the additional
hours. Write a python program that will ask the user for her hourly wage and then for the
hours she has worked in the past week. With these two values, print the wage earned for the
week.

8. A year is a leap year if it is divisible by 4, unless it is divisible by 100 and not by 400.
Write a function that takes an integer value representing a year and returns to Boolean results
indicating whether or not the year is a leap year.

9. Write a function that takes a positive integer N, and then produces N lines of output. The
first line contains one star, the second two stars and so on until the last line, which should
have N stars. Can you write this using only a single loop? Hint: remember what the
expression ‘+’ *5 does.
Enter a size: 5
+
++
+++
++++
+++++

Email: info@[Link] on web at: [Link]

You might also like