Starting from:
$30

$24

CSC1001 Assignment 2 Solved


Question 1

    1. This code is saved in 2_1.py

    2. The program prompts the user to enter a positive number and output the approximation of its square root.

    3. The input can be anything, but only positive number input can be executed.

    4. Execute as followings:










Question 2

    1. This code is saved in 2_2.py

    2. The program displays the first 100 emirps. And it displays 10 numbers per line and align the numbers properly.
    3. No need to input.

    4. Execute as followings:










Question 3

    1. This code is saved in 2_3.py

    2. The program prompts the user to enter a credit card number as an integer. And it displays whether the number is valid or invalid. The valid credit card number should begin with 4 or 5 or 37 or 6. And it should pass “Luhn check”.

    3. The input can be anything, but only a positive integer number input can be judged whether it is valid or not. If user input includes alphabet, it will prompt user to input a positive integer number again.
    4. Execute as followings:















Question 4

    1. This code is saved in 2_4.py

    2. The program prompts the user to enter two strings and, if they are anagrams, displays ‘is an anagram’; otherwise, it displays ‘is not an anagram’.
    3. The all input be words.

    4. Execute as followings:



Question 5

    1. This code is saved in 2_5.py

    2. The program tells user that after all the students have passed through the building and changed the lockers, which lockers are open.
    3. No need to input.

    4. Execute as followings:





Question 6

    1. This code is saved in 2_6.py

    2. The program will print a solution of Queen Puzzle randomly. Queens puzzle is to place eight queens on a chessboard (8*8) such that no two queens can attack each other (i.e., no two queens are in the same row, same column, or same diagonal).

    3. No need to input.

    4. Execute as followings:

More products