alx-higher_level_programming

所属分类:Python编程
开发工具:C
文件大小:0KB
下载次数:0
上传日期:2023-11-28 23:19:56
上 传 者sh-1993
说明:  Python编程
(Python Programming)

文件列表:
py (149, 2023-12-06)
0-print_list_integer.py (109, 2023-12-06)
0x00-python-hello_world/ (0, 2023-12-06)
0x00-python-hello_world/0-run (28, 2023-12-06)
0x00-python-hello_world/1-run_inline (33, 2023-12-06)
0x00-python-hello_world/10-check_cycle.c (428, 2023-12-06)
0x00-python-hello_world/10-linked_lists.c (1116, 2023-12-06)
c (986, 2023-12-06)
0x00-python-hello_world/100-write.py (118, 2023-12-06)
0x00-python-hello_world/101-compile (47, 2023-12-06)
0x00-python-hello_world/102-magic_calculation.py (73, 2023-12-06)
0x00-python-hello_world/2-print.py (80, 2023-12-06)
0x00-python-hello_world/3-print_number.py (67, 2023-12-06)
0x00-python-hello_world/4-print_float.py (66, 2023-12-06)
0x00-python-hello_world/5-print_string.py (74, 2023-12-06)
0x00-python-hello_world/6-concat.py (108, 2023-12-06)
0x00-python-hello_world/7-edges.py (230, 2023-12-06)
0x00-python-hello_world/8-concat_edges.py (220, 2023-12-06)
0x00-python-hello_world/9-easter_egg.py (31, 2023-12-06)
0x00-python-hello_world/cycle (17112, 2023-12-06)
0x00-python-hello_world/lists.h (472, 2023-12-06)
0x00-python-hello_world/main.py (40, 2023-12-06)
0x00-python-hello_world/main.pyc (123, 2023-12-06)
0x00-python-hello_world/q (58, 2023-12-06)
0x01-python-if_else_loops_functions/ (0, 2023-12-06)
0x01-python-if_else_loops_functions/0-positive_or_negative.py (206, 2023-12-06)
0x01-python-if_else_loops_functions/1-last_digit.py (416, 2023-12-06)
0x01-python-if_else_loops_functions/10-add.py (51, 2023-12-06)
py (110, 2023-12-06)
0x01-python-if_else_loops_functions/100-print_tebahpla.py (117, 2023-12-06)
py (275, 2023-12-06)
0x01-python-if_else_loops_functions/101-remove_char_at.py (140, 2023-12-06)
0x01-python-if_else_loops_functions/102-magic_calculation.py (140, 2023-12-06)
py (146, 2023-12-06)
0x01-python-if_else_loops_functions/11-pow.py (52, 2023-12-06)
0x01-python-if_else_loops_functions/12-fizzbuzz.py (319, 2023-12-06)
py (91, 2023-12-06)
0x01-python-if_else_loops_functions/13-insert_number.c (677, 2023-12-06)
c (562, 2023-12-06)
... ...

0x03. Python - Data Structures: Lists, Tuples ###Tasks ##0. Print a list of integers #mandatory Write a function that prints all integers of a list. Prototype: def print_list_integer(my_list=[]): Format: one integer per line. See example You are not allowed to import any module You can assume that the list only contains integers You are not allowed to cast integers into strings You have to use str.format() to print integers ##1. Secure access to an element in a list #mandatory Write a function that retrieves an element from a list like in C. Prototype: def element_at(my_list, idx): If idx is negative, the function should return None If idx is out of range (> of number of element in my_list), the function should return None You are not allowed to import any module You are not allowed to use try/except ##2. Replace element #mandatory Write a function that replaces an element of a list at a specific position (like in C). Prototype: def replace_in_list(my_list, idx, element): If idx is negative, the function should not modify anything, and returns the original list If idx is out of range (> of number of element in my_list), the function should not modify anything, and returns the original list You are not allowed to import any module You are not allowed to use try/except ##3. Print a list of integers... in reverse! #mandatory Write a function that prints all integers of a list, in reverse order. Prototype: def print_reversed_list_integer(my_list=[]): Format: one integer per line. See example You are not allowed to import any module You can assume that the list only contains integers You are not allowed to cast integers into strings You have to use str.format() to print integers ##4. Replace in a copy #mandatory Write a function that replaces an element in a list at a specific position without modifying the original list (like in C). Prototype: def new_in_list(my_list, idx, element): If idx is negative, the function should return a copy of the original list If idx is out of range (> of number of element in my_list), the function should return a copy of the original list You are not allowed to import any module You are not allowed to use try/except ##5. Can you C me now? #mandatory Write a function that removes all characters c and C from a string. Prototype: def no_c(my_string): The function should return the new string You are not allowed to import any module You are not allowed to use str.replace() ##6. Lists of lists = Matrix #mandatory Write a function that prints a matrix of integers. Prototype: def print_matrix_integer(matrix=[[]]): Format: see example You are not allowed to import any module You can assume that the list only contains integers You are not allowed to cast integers into strings You have to use str.format() to print integers ##7. Tuples addition #mandatory Write a function that adds 2 tuples. Prototype: def add_tuple(tuple_a=(), tuple_b=()): Returns a tuple with 2 integers: The first element should be the addition of the first element of each argument The second element should be the addition of the second element of each argument You are not allowed to import any module You can assume that the two tuples will only contain integers If a tuple is smaller than 2, use the value 0 for each missing integer If a tuple is bigger than 2, use only the first 2 integers ##8. More returns! #mandatory Write a function that returns a tuple with the length of a string and its first character. Prototype: def multiple_returns(sentence): If the sentence is empty, the first character should be equal to None You are not allowed to import any module ##9. Find the max #mandatory Write a function that finds the biggest integer of a list. Prototype: def max_integer(my_list=[]): If the list is empty, return None You can assume that the list only contains integers You are not allowed to import any module You are not allowed to use the builtin max() ##10. Only by 2 #mandatory Write a function that finds all multiples of 2 in a list. Prototype: def divisible_by_2(my_list=[]): Return a new list with True or False, depending on whether the integer at the same position in the original list is a multiple of 2 The new list should have the same size as the original list You are not allowed to import any module ##11. Delete at #mandatory Write a function that deletes the item at a specific position in a list. Prototype: def delete_at(my_list=[], idx=0): If idx is negative or out of range, nothing change (returns the same list) You are not allowed to use pop() You are not allowed to import any module ##12. Switch #mandatory Complete the source code in order to switch value of a and b You can find the source code here Your code should be inserted where the comment is (line 4) Your program should be exactly 5 lines long guillaume@ubuntu:~/py/0x03$ ./12-switch.py a=10 - b=89 guillaume@ubuntu:~/py/0x03$ wc -l 12-switch.py 5 12-switch.py guillaume@ubuntu:~/py/0x03$ Repo: GitHub repository: alx-higher_level_programming Directory: 0x03-python-data_structures File: 12-switch.py ##13. Linked list palindrome #mandatory Technical interview preparation: You are not allowed to google anything Whiteboard first Write a function in C that checks if a singly linked list is a palindrome. Prototype: int is_palindrome(listint_t **head); Return: 0 if it is not a palindrome, 1 if it is a palindrome An empty list is considered a palindrome ##14. CPython #0: Python lists #advanced CPython is the reference implementation of the Python programming language. Written in C, CPython is the default and most widely used implementation of the language. Since we now know a bit of C, we can look at what is happening under the hood of Python. Let’s have fun with Python and C, and let’s look at what makes Python so easy to use. Create a C function that prints some basic info about Python lists. Prototype: void print_python_list_info(PyObject *p); Format: see example Python version: 3.4 Your shared library will be compiled with this command line: gcc -Wall -Werror -Wextra -pedantic -std=c99 -shared -Wl,-soname,PyList -o libPyList.so -fPIC -I/usr/include/python3.4 100-print_python_list_info.c OS: Ubuntu 14.04 LTS Start by reading: listobject.h object.h Common Object Structures List Objects

近期下载者

相关文件


收藏者