Write a console application that prints the next 20 leap years. A leap year is a year in which an extra day is added to the Gregorian calendar, which is used by most of the world. While an ordinary year has 365 days, a leap year has 366 days. ... A leap year comes once every four years. Because of this, a leap year can always be evenly divided by four. [20 marks]
Write a C program for the Fibonacci series of n numbers using array.
Fi = F(i-1) + F(i-2)
Example: if n =5
F1 = 1
F2 = 1
F3 = F2+ F1 = 1 + 1 = 2
F4 = F3 + F2 = 2 + 1 = 3
F5 = F4 + F3 = 3 + 2 = 5
import numpy as np
old = no.array([[1, 1, 1], [1, 1, 1]])
new = old
new[0, :2] = 0
print(old)
Using for loop, how to write a program that accepts a positive integer n, representing the number of seconds before the rocket will launch. The program should then output the numbers from n going down to 0. After the line containing the 0, the program should output another line with the words “Blast Off!”
Write a program which has a class called binary which has a character array to store a binary string. The class decimal derives from class binary and contains an integer data member. Another class called hexadecimal also derives from binary. Each class should contain constructors and appropriate data members to input and display the elements. The display function of binary class displays the binary equivalent, hexadecimal class’s display function displays hexadecimal equivalent whereas decimal class’s display function displays the decimal equivalent.
Write a program which has a function template for sorting an array of given data types.
Write a program which has an abstract class called Number having an integer data member. The class contains a pure virtual function called operation. A class called odd is derived from class called Number. Another class called Even is derived from class Number. Yet another class called prime is derived from Number. Use appropriate constructors and redefine the function called operation to display if the number is odd, even or prime. You may make use of other data members and member functions if needed.
Write a program which has a class named binary which has a character array to store a binary string. The class decimal derives from class binary and contains an integer data member. Another class called octal also derives from binary. Each class should contain constructors and appropriate data members to input and display the elements. The display function of binary class displays the binary equivalent, octal class’s display function displays octal equivalent whereas decimal class’s display function displays the decimal equivalent.
Type the expressions below in python interactively, and try to explain what's happening in each case: a. 2 ** 16 2 / 5, 2 / 5.0 b. "spam" + "eggs" S = "ham" "eggs " + S S * 5 S[:0] "green %s and %s" % ("eggs", S) c. ('x',) [0] ('x', 'y') [1] d. L = [1,2,3] + [4,5,6] L, L[:], L[:0], L[-2], L[-2:] ([1,2,3] + [4,5,6]) [2:4] [L[2], L[3]] L.reverse(); L L.sort(); L L.index(4)
1.Use a for loop and the list append method to generate the powers of 2 to produce the following result [1, 2, 4, 8, 16, 32, 64, 128]
2.Write a for loop that prints a dictionary's items in sorted (ascending) order