Sign In
Not register? Register Now!
Pages:
3 pages/β‰ˆ825 words
Sources:
Check Instructions
Style:
APA
Subject:
IT & Computer Science
Type:
Coursework
Language:
English (U.S.)
Document:
MS Word
Date:
Total cost:
$ 19.44
Topic:

Programming Assignment using Boolean True

Coursework Instructions:

Assignment 3 Q1) Write a python program that reads an integer, n, from user.For all non-negative integers i < n, print i 2 . 10 Points Example n = 3 The list of non-negative integers that are less than 3 is [0,1,2] . Print the square of each number on a separate line. 0 1 4 Test you program for values of n from 1 to 10 . You can use for loop or while loop or a combination Q2) Every four years as February 29, and the day is called a leap day. A leap year contains a leap day. Three conditions are used to identify leap years: • The year can be evenly divided by 4, is a leap year, unless: • The year can be evenly divided by 100, it is NOT a leap year, unless: • The year is also evenly divisible by 400. Then it is a leap year. This means that the years 2000 and 2400 are leap years, while 1900, 2100, 2200, 2300 and 2500 are NOT leap years [https://www.timeanddate.com/date/leapyear.html]. Write program to determine whether it is a leap year. Read the year from the user and pass it as argument to the isleap function, the function return the Boolean True if the year is leap year, otherwise return False. 10 Points Your program should work for any year from 1900 to 2999. Please follow the Test case your program should display the following output as show in the test case below. Test case 1 Enter the year : 1990 The Function returns False Why 1990 is not a multiple of 4 hence it’s not a leap year. Q3) Write a program to print the following pattern.(You have to use a loop) 10 Points * * * * * * * * * *

Coursework Sample Content Preview:

Programming Assignment 3
Name
Institutional Affiliation
Programming Assignment 3
Q#1
n = int(input("Please enter a number between 0 and 10: "))
i = 0
while (n >= 0 and n <= 10) and i < n:
    print (i**2)
    i += 1
Q#2
print("Test case 1")
year = int(input("Enter the year: "))
def isleap(year): 
    if(year%4==0 and year%100!=0 or year%400==0):
        print("The Function returns " + str(boo...
Updated on
Get the Whole Paper!
Not exactly what you need?
Do you need a custom essay? Order right now:

πŸ‘€ Other Visitors are Viewing These APA Coursework Samples:

HIRE A WRITER FROM $11.95 / PAGE
ORDER WITH 15% DISCOUNT!