0x01. Python - if/else, loops, functions Tasks 0. Positive anything is better than negative nothing mandatory Score: 0.0% (Checks completed: 0.0%) This program will assign a random signed number to the variable number each time it is executed. Complete the source code in order to print whether the number stored in the variable number is positive or negative.
You can find the source code here
The variable number will store a different value every time you will run this program
You don’t have to understand what import, random. randint do. Please do not touch this code
The output of the program should be:
The number, followed by
if the number is greater than 0: is positive
if the number is 0: is zero
if the number is less than 0: is negative
followed by a new line
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
-4 is negative
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
0 is zero
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
-3 is negative
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
-10 is negative
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
10 is positive
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
-5 is negative
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
6 is positive
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
7 is positive
guillaume@ubuntu:/0x01$ ./0-positive_or_negative.py
5 is positive
guillaume@ubuntu:/0x01$
Repo:
GitHub repository: alx-higher_level_programming Directory: 0x01-python-if_else_loops_functions File: 0-positive_or_negative.py
- The last digit mandatory Score: 0.0% (Checks completed: 0.0%) This program will assign a random signed number to the variable number each time it is executed. Complete the source code in order to print the last digit of the number stored in the variable number.
You can find the source code here
The variable number will store a different value every time you will run this program
You don’t have to understand what import, random.randint do. Please do not touch this code. This line should not change: number = random.randint(-10000, 10000)
The output of the program should be:
The string Last digit of, followed by
the number, followed by
the string is, followed by the last digit of number, followed by
if the last digit is greater than 5: the string and is greater than 5
if the last digit is 0: the string and is 0
if the last digit is less than 6 and not 0: the string and is less than 6 and not 0
followed by a new line
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of 4205 is 5 and is less than 6 and not 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of -626 is -6 and is less than 6 and not 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of 1144 is 4 and is less than 6 and not 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of -9200 is 0 and is 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of 5247 is 7 and is greater than 5
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of -9318 is -8 and is less than 6 and not 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of 3369 is 9 and is greater than 5
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of -5224 is -4 and is less than 6 and not 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of -4485 is -5 and is less than 6 and not 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of 3850 is 0 and is 0
guillaume@ubuntu:/0x01$ ./1-last_digit.py
Last digit of 5169 is 9 and is greater than 5
guillaume@ubuntu:/0x01$
Repo:
GitHub repository: alx-higher_level_programming Directory: 0x01-python-if_else_loops_functions File: 1-last_digit.py
- I sometimes suffer from insomnia. And when I can't fall asleep, I play what I call the alphabet game mandatory Score: 0.0% (Checks completed: 0.0%) Write a program that prints the ASCII alphabet, in lowercase, not followed by a new line.
You can only use one print function with string format
You can only use one loop in your code
You are not allowed to store characters in a variable
You are not allowed to import any module
guillaume@ubuntu:/0x01$ ./2-print_alphabet.py
abcdefghijklmnopqrstuvwxyzguillaume@ubuntu:/0x01$
Repo:
GitHub repository: alx-higher_level_programming Directory: 0x01-python-if_else_loops_functions File: 2-print_alphabet.py
- When I was having that alphabet soup, I never thought that it would pay off mandatory Score: 0.0% (Checks completed: 0.0%) Write a program that prints the ASCII alphabet, in lowercase, not followed by a new line.
Print all the letters except q and e
You can only use one print function with string format
You can only use one loop in your code
You are not allowed to store characters in a variable
You are not allowed to import any module
guillaume@ubuntu:/0x01$ ./3-print_alphabt.py
abcdfghijklmnoprstuvwxyzguillaume@ubuntu:/0x01$
Repo:
GitHub repository: alx-higher_level_programming Directory: 0x01-python-if_else_loops_functions File: 3-print_alphabt.py
- Hexadecimal printing mandatory Score: 0.0% (Checks completed: 0.0%) Write a program that prints all numbers from 0 to 98 in decimal and in hexadecimal (as in the following example)
You can only use one print function with string format
You can only use one loop in your code
You are not allowed to store numbers or strings in a variable
You are not allowed to import any module
guillaume@ubuntu:/0x01$ ./4-print_hexa.py
0 = 0x0
1 = 0x1
2 = 0x2
3 = 0x3
4 = 0x4
5 = 0x5
6 = 0x6
7 = 0x7
8 = 0x8
9 = 0x9
10 = 0xa
11 = 0xb
12 = 0xc
13 = 0xd
14 = 0xe
15 = 0xf
16 = 0x10
17 = 0x11
18 = 0x12
...
96 = 0x60
97 = 0x61
98 = 0x62
guillaume@ubuntu:/0x01$
Repo:
GitHub repository: alx-higher_level_programming Directory: 0x01-python-if_else_loops_functions File: 4-print_hexa.py
- 00...99 mandatory Score: 0.0% (Checks completed: 0.0%) Write a program that prints numbers from 0 to 99.
Numbers must be separated by ,, followed by a space Numbers should be printed in ascending order, with two digits The last number should be followed by a new line You can only use no more than 2 print functions with string format